Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

window.onunload

Status
Not open for further replies.

stewartwebb

Programmer
Jan 6, 2004
92
GB
Hi All,

I have a problem with window.onunload.
I have put the 'window.onunload' in our global javascript file and there is also a 'window.onunload' on the page. The problem is that it will perform the function from the page but not the function in the global javascript.
When I remove the function from the page the global function will then work.
It seems you can only have 1 'window.onunload' per page, is there a way round this to have 1 on the page and 1 on the global javascript?

Thanks

Stewart.
 
Sorry i'll explain a bit more.

We have a website (which has quite a few pages) and we now want to save a cookie everytime a user exits a page and read the cookie everytime a user enters a page.

So I tried to use the window.onload and window.onunload in the global javascript file. This is when I found that if the page the user is on already uses onload and onunload, the calls from the global javascript are ignored.

It would be a lot of work to change every page thats why i've tried to do the change using the global javascript file. So, is it not possible to achieve what i'm trying to do?

Thanks

Stewart.
 
I don't believe so. From what I remember javascript follows an hierarchy tree when events are fired by a page. And will only fire to the event at the lowest point in the tree.

If I am wrong maybe someone else can give you a hand. I believe however that you are going to need to put the other javascript function in an include and then either call the included function within your page level method or chain the method calls together within the event itself.



 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top