Click here to Skip to main content
15,915,501 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi,
How can i get value and event from child popup window to parent using java script
i have used one popup window using java script. but am used get back only one value and click event. now i need text changed event ???
what should i do for geting that text changed event in java cript....
Posted

1 solution

Hi.

You can take advantage of DOM Event Bubbling and use a Cross-Browser listener because you've got 2 DOM in the worst case (inherited, but a new DOM structure). A classic implementation of the event listener (in your case 'onClick' event) is :

C#
function AddEvent(html_element, event_name, event_function)
{
   if(html_element.attachEvent) //IE
      html_element.attachEvent("on" + event_name, function() {event_function.call(html_element);});
   else if(html_element.addEventListener) //Firefox
      html_element.addEventListener(event_name, event_function, false); 
}

And you can use it simply by including this 'JS' code :

C#
AddEvent(document.getElementById('your_Div_Element'), 'click', function()
{
   alert('Working as designed');
});


Regards
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900