onunload not working in frames

JavaScript and client side scripting.

Moderator: General Moderators

Post Reply
User avatar
Pyrite
Forum Regular
Posts: 769
Joined: Tue Sep 23, 2003 11:07 pm
Location: The Republic of Texas
Contact:

onunload not working in frames

Post 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. :(
User avatar
scorphus
Forum Regular
Posts: 589
Joined: Fri May 09, 2003 11:53 pm
Location: Belo Horizonte, Brazil
Contact:

Post 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.
User avatar
Pyrite
Forum Regular
Posts: 769
Joined: Tue Sep 23, 2003 11:07 pm
Location: The Republic of Texas
Contact:

Post 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
User avatar
scorphus
Forum Regular
Posts: 589
Joined: Fri May 09, 2003 11:53 pm
Location: Belo Horizonte, Brazil
Contact:

Post 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.
User avatar
Pyrite
Forum Regular
Posts: 769
Joined: Tue Sep 23, 2003 11:07 pm
Location: The Republic of Texas
Contact:

Post 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
Post Reply