Detect popup window in IE6

L

lrlebron

I am using the following to detect if a popup window is already open.
I only want to open a new window if it does not exist or has been
closed.
<HTML>
<HEAD>
<script language="JavaScript" type="text/javascript">
<!--
var myPage;
function openMyPage() {
if (!myPage || myPage.closed){
myPage=window.open("default.aspx", "_blank");
}
else {
alert("NFSL1 is already opened");
}
}
//-->
</script>

</HEAD>
<BODY>
<FORM>
<INPUT TYPE="button" onClick="openMyPage();" VALUE="open MyPage">
</FORM>
</BODY>
</HTML>


The code works correctly in Firefox, but IE6 opens a new window every
time.

Any ideas?

thanks,

Luis
 
R

Randy Webb

Janwillem Borleffs said the following on 6/13/2007 4:48 PM:
The second argument should be the name (myPage) not a target (_blank).

And it should be opening a window with the name of "_blank" - which it
is - but IE <gasp> gets it right and opens a new blank window each time.

Solution: give it a different name other than _blank.
 
R

Roger

Randy said:
Janwillem Borleffs said the following on 6/13/2007 4:48 PM:

And it should be opening a window with the name of "_blank" - which it
is - but IE <gasp> gets it right and opens a new blank window each time.

Solution: give it a different name other than _blank.

Also, if you give the window a name the first time it is opened, you do
not have to bother testing to see if the window is still open. Just
request another new window using the same name and any existing window
with the requested name will get reused.

Roger
 

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

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,537
Members
45,023
Latest member
websitedesig25

Latest Threads

Top