Brian Vallelunga wrote:
I'm working on an asp.net site and am trying to implement a popup help
window. I want the window to close when the user advances to the next page
in our application. The thing is, I'm doing this on a component basis and I
don't have access to the body tag from within my help component, so I can't
add the onunload tag. Is there some other way of achieving what I want? Can
I add an eventhandler to the body tag through javascript?
Thanks,
Brian
<script type="text/javascript">
function myUnloadHandler() {
// do something
}
window.onunload = myUnloadHandler;
</script>
The problem of course is that when the unload event fires, I'm not sure if the
function is still in scope on the page. What you may need to do is put the
unload event handler function in the opener, then invoke it from the popup:
<script type="text/javascript">
function popupUnloadHandler() {
if (window.opener && window.opener.unloadHandler) {
window.opener.unloadHandler();
}
}
window.onunload = popupUnloadHandler;
</script>
--
| Grant Wagner <gw*****@agricoreunited.com>
* Client-side Javascript and Netscape 4 DOM Reference available at:
*
http://devedge.netscape.com/library/...ce/frames.html
* Internet Explorer DOM Reference available at:
*
http://msdn.microsoft.com/workshop/a...ence_entry.asp
* Netscape 6/7 DOM Reference available at:
*
http://www.mozilla.org/docs/dom/domref/
* Tips for upgrading JavaScript for Netscape 6/7 and Mozilla
*
http://www.mozilla.org/docs/web-deve...upgrade_2.html