Closed Thread Icon

Topic awaiting preservation: auto-close a pop up window with opener (Page 1 of 1) Pages that link to <a href="https://ozoneasylum.com/backlink?for=8995" title="Pages that link to Topic awaiting preservation: auto-close a pop up window with opener (Page 1 of 1)" rel="nofollow" >Topic awaiting preservation: auto-close a pop up window with opener <span class="small">(Page 1 of 1)</span>\

 
norm
Paranoid (IV) Inmate

From: [s]underwater[/s] under-snow in Juneau
Insane since: Sep 2002

posted posted 01-19-2004 09:11

this should be simple, but I've googled and thumbed thru O'Reilly with no joy.....

I want to close a window that I have opened automaticly when my main window closes.

I opened it with:

var pop=window.open('new.html','new1','height=100px,width=100px');

So I thought I could close it with: pop.close()..... but nope doesn't work.

any advice? please.......

/* Sure, go ahead and code in your fancy IDE. Just remember: it's all fun and games until someone puts an $i out */

Yossi Admon
Bipolar (III) Inmate

From: Israel
Insane since: Nov 2001

posted posted 01-19-2004 13:54

Hi,
The case you just mentioned looks very strange.
It looks to me that there are some options:
1) You have a JS RT error before the call to the "pop.close()";
2) The "pop" is null when you call the close method (opener refreshed itself...);
3) The "pop" is a local variable of a method.

following code will demonstrate the action you are trying to achive.

code:
<HTML>
<SCRIPT language="javascript">
var _oChildWin = null;
function doOpen(){
_oChildWin = window.open('http://www.yahoo.com');
}
function doClose(){
try{
_oChildWin.close();
} catch(e){}
}
</SCRIPT>
<BODY onunload="doClose();">
<input type="button" value="open" onClick="doOpen()">
<input type="button" value="close" onClick="doClose()">
<input type="button" value="Refresh" onClick="window.location.reload();">
</BODY>
</HTML>




Tyberius Prime
Paranoid (IV) Mad Scientist with Finglongers

From: Germany
Insane since: Sep 2001

posted posted 01-19-2004 16:53

the back of my head claims that you can only close a window if it hasn't been navigated to a different page from the one you open()ed it with...

Yossi Admon
Bipolar (III) Inmate

From: Israel
Insane since: Nov 2001

posted posted 01-19-2004 19:36

I've tryed the code above and although i've navigated through the lenks, refreshing the opener closed the child.

norm
Paranoid (IV) Inmate

From: [s]underwater[/s] under-snow in Juneau
Insane since: Sep 2002

posted posted 01-19-2004 20:38

Yossi Admon & Tyberius Prime :

Thanks to both of you for looking at this. It turns out my code DID work....just not in the browser I was testing it in,Safari.

Safari has done this to me in the past, I think it may have something to do with #2 on Yossi's list. Last time Safari did some strange looping in a PHP app, perhaps due to refreshing...

The funny thing is, I should not have been testing in Safari because this is part of a work around to support Netscape 4.7 and it's lack of iframes. Ilayers was not working for passing variables to the rest of the document during a PHP remote procedure call, so I resorted to poping up this window and then blurring it.

Netscape 4.7 users deserve pop-up windows anyway, it's just part of their punishment for not using a real browser.......



/* Sure, go ahead and code in your fancy IDE. Just remember: it's all fun and games until someone puts an $i out */

Yossi Admon
Bipolar (III) Inmate

From: Israel
Insane since: Nov 2001

posted posted 01-19-2004 21:21

I've opened a thread (with no luck) a few weeks ago regarding modal windows in Mozilla1.5 and NS7.1 (regression with "modal" attribute); do you know about any solution for this problem?

Regards,
Yossi Admon

norm
Paranoid (IV) Inmate

From: [s]underwater[/s] under-snow in Juneau
Insane since: Sep 2002

posted posted 01-19-2004 21:44

I just looked at your thread...I'm not sure what the problem you are trying to solve is. Could you explain what it is you are trying to accomplish that is not happening?

Sorry, I can be a bit slow on the uptake sometimes!



/* Sure, go ahead and code in your fancy IDE. Just remember: it's all fun and games until someone puts an $i out */

Yossi Admon
Bipolar (III) Inmate

From: Israel
Insane since: Nov 2001

posted posted 01-19-2004 21:54

If you are opening a window in NS7.0 using the "modal" attribute (window.open(url, winname, options +";modal=1")) the window will be open as modal window (user can't go back to the opener window) from NS7.1 and Mozilla1.5 the new window opened is modless (the user can interact with both windows just like any window.open...)

norm
Paranoid (IV) Inmate

From: [s]underwater[/s] under-snow in Juneau
Insane since: Sep 2002

posted posted 01-19-2004 22:32

According to what I found with google searches, Modal windows just aren't supported any more.... as you have noticed.

Maybe this would do it; try assigning an id to the body of the new window, then use this function with addEventListener and DOMFocusOut:

dontGoaway(){
self.focus;
}

/* Sure, go ahead and code in your fancy IDE. Just remember: it's all fun and games until someone puts an $i out */

Yossi Admon
Bipolar (III) Inmate

From: Israel
Insane since: Nov 2001

posted posted 01-19-2004 22:39

I know some workarownds but i was interesting with any native attribute/function in order to achive modality.

« BackwardsOnwards »

Show Forum Drop Down Menu