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 Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Devide the reload and close window actions

Status
Not open for further replies.

olegkot

Programmer
Aug 28, 2001
31
IL
Hi!

When I put code into the onunload= hendler I get the problem conserning the close and refresh window actions.

Situation: when I close window with my "close" button on the page, some code dealing with closing child windows goes, but to get the same functionality with closing through standard "x" window button - I need to put the same code (function) to onunload= body tag. Here the problem :-( that the window.location.reload (which I use on the same page as well) function is also pushes the "onunload=" event. So it also closes the window...

Any ideas?
 
when you fire window.location.reload, also set a flag to whatever (say : true)
then onunload, check if this flag is true, if it is, don't close, if it's not, close - and don't forget to turn it to false again
 
Pls explain more.
Actualy I fire reload method from child window to parent:
opener.location.reload.

So how to pass that flag?

oleg
 
take a look at thread216-127820

but may be iza has something to add? :) Victor
 
Victor!

Everything you recomended is working perfect. Only the "F5" (refresh) is still making problems! It calls first of all handler for onUnload event which is closing the window, because theFlag = false (we change theFlag when we call rl() function) ??

Any ideas..? s-)
 
well, i have just few 'words' in my mind:
may be you should set this unload handler when you really need it to run (after some actions you have to do or something) & then it would look like this:
if you're done, let'em hit F5 in their pleasure, but then they would delete these child windows handy, & if you are still in your actions, then reload won't do anything to your window, & 'child reminder' would do it's job

here is a faq on seting/deleting event handlers for this forum (follow the link in the right bottom corner of this (or any) post) Victor
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top