Page 1 of 1
onunload not working in frames
Posted: Sat May 29, 2004 2:36 pm
by Pyrite
Hey people,
I have a Site with 3 frames, and in one of them I load a php page that I want to use an onunload event to save some stuff to the database. The problem is that the onunload event is never called. I have it in the body tag, and to test it am using <body onunload="alert('test')" and I never see an alert box when I navigate away from that page (by loading a different page into that frame). Any ideas. I've tried it using IE6 and Firefox 0.8 . No worky.

Posted: Sun May 30, 2004 1:22 am
by scorphus
Hi, please post the code so I can try it out and give some feed back.
1. You could check in Mozilla's "JavaScript console" (that old JavaScript debugger) and look for some error.
2. Maybe when you load a new page to the frame it does not get "unloaded".
3. Did you try the page with the <body onUnload="...> stand alone? Does it works as expected?
Hope I can help,
Scorphus.
Posted: Sun May 30, 2004 2:54 am
by Pyrite
Well what code should I post? I pasted exactly the onunload I'm using.
I tried opening the page that normally loads in a frame in a new window, and it doens't work there either. In IE at least opening the page in a new window doens't show any javascript errors. I'll try the console debugger though, thanks for the idea.
Hope you can help too.
-Py
Posted: Sun May 30, 2004 4:15 pm
by scorphus
Hi Pyrite,
I got it working take a look at
http://scorphus.no-ip.com/lab/html/frame/frameset.html and see if it works for you. You can download all the pages packed here:
http://scorphus.no-ip.com/lab/html/fram ... set.tar.gz
Regards,
Scorphus.
Posted: Sun May 30, 2004 6:40 pm
by Pyrite
I found out what is causing the problem, I am doing it right, but the php page I'm trying to use it in has an "htmlarea", and apparently there is a bug about that already.
http://www.interactivetools.com/forum/g ... +Flat+Mode
*UPDATE*
And I fixed it by commenting out their Htmlarea Function on Line 666 of htmlarea.js . Thanks for helping me think through this!
Um forte abraço