PDA

View Full Version : Javascript onunLoad problem



esencan
21 Jan 2010, 02:23 PM
I know, i know this has been covered over and over again but I've run into something which I haven't been able to find reference to.

Here is the situation. There is a data list in the parent window. When a user clicks to edit it opens a child window (a real window) in which they edit. The child window has a onUnload function which tells the parent to update its data when the window is closed.

Firefox, no problem. IE 7, the event doesn't fire.

I tested the unOnload event on its own, outside of any scripts and it fires fine but in the context of all the other scripts it doesn't fire. My frist thought was that some other script is throwing an error preventing the unload (or overwriting the onunload). I commented out all the other scripts and sure enough the event fired. I started bringing back the scripts one by one until the event stopped.

I looked at the script where the event stopped and started commenting out the majority of it and uncommenting functions. However here is what happened. The functions I uncommented had nothing to do with causing the event to fire or not fire. When i uncommented a certain amount of code (from the beginning or end) the event stopped.

So I tested this with the other scripts and sure enough the event only stopped firing when the total length of the scripts passed some threshold - some sort of overflow problem?

Can anyone comment or confirm this? Is this a known issue? Any resolution? Or have I overlooked something obvious? I would like the event to fire.

Nothing fancy about the event itself it looks like


<script type='text/javascript'>
self.onunload = function() { do something.... }
</script>

and it's located within the head.