Reopen Pop-Up Window After User Closes It?

J

Jonathan Atkinson

Hi,

I have a very simple function to open a help window:

function help_window(url, width, height) {
help_window = open('/Help/'+url,
'help_window','toolbar=0,directory=0,status=0,menubar=0,scrollbars=1,resizable=0,width='+width
+',height='+height);
help_window.focus();
}
 
J

Jonathan Atkinson

Sorry, my message was truncated.

Anyway, the function is supposed to open a pop-up window, which it
does. But it only seems to work once. If you close the pop-up window,
then click the link again, nothing happens. I got the same result in
both Safari and Google Chrome.

Is there some code I need to add to check if a window has been
previously opened and closed?

Thanks in advance for your time.

Regards,
Jonathan
 
M

Martin

Sorry, my message was truncated.

Anyway, the function is supposed to open a pop-up window, which it
does. But it only seems to work once. If you close the pop-up window,
then click the link again, nothing happens. I got the same result in
both Safari and Google Chrome.

Is there some code I need to add to check if a window has been
previously opened and closed?

Thanks in advance for your time.

Regards,
Jonathan

Looks like the function overwrites itself when it is first executed.

After being executed, help_window is no longer your function but a
handle to the pop-up window which was opened.

warwound.
 
T

Thomas 'PointedEars' Lahn

Yes said:
Looks like the function overwrites itself when it is first executed.

After being executed, help_window is no longer your function but a
handle to the pop-up window which was opened.

Exactly, that is correct. A solution is to declare a differently named
variable and assign to that variable instead; the variable should be global
if the Window instance is reused, otherwise local.

It should also be window.open(...), and "resizable[=1]" ("=1" is optional).
It is possible that none of the other settings take effect. Be extra
careful with setting `width' and `height', and feature-test the focus()
method before you call it (search for "isMethod OR isHostMethod", maybe you
even need to catch exceptions).

<https://developer.mozilla.org/en/DOM/window.open>


PointedEars
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
474,034
Messages
2,570,356
Members
47,002
Latest member
RobertoLip

Latest Threads

Top