I have a function that opens a pop up window:
function popUp(url)
{ leftPos = 0
topPos = 0
if (screen) {
leftPos = (screen.width / 2) - 150
topPos = (screen.height / 2) - 250
} 开发者_如何学运维
newWindow=window.open(url,'name','height=300,width=500,left='+leftPos+',top='+topPos);
if (window.focus) {newWindow.focus()}
when the user closes this window I need to fire this code:
Javascript:document.quoteform.submit()
Can anyone give me a simple solution to return a boolean from the popup when closed to be able to fire my JS. Any help is appreciated I'm having a brain fart today I know this should be easy.
You can access the window that opens current through window.opener
So you can do window.opener.document.quoteform.submit()
from new window;
The window object has a property window.closed
when when the popup window closes, is set to true
. You can use that to determine if the window was closed. More on window.closed here
Using this property and the fact that popups can access the window that opened them, you can devise a mechanism to communicate to the parent window via popup when to check for this property.
e.g.
Popup window's onunload
can be used to pass on a message to opening window to check if the window was closed.
Note that onunload will be called even if the popup window page is refereshed. You don't want to use that as a means for submitting the form, because the window will not be closed.
精彩评论