window.open() opens two windows

M

MPH

Problem:
using a named window as target, a new window is opened anyway. Also, both
windows have the same name. This happens on SOME machines only

env:
XP sp2
ie6.0.2900.2180
+ sp2

Replicate with these two files, "test1.html"

<HTML><BODY>
<script>
function openit(){
var addlookup=open('about:blank','addlookup');
document.f1.target="addlookup";
document.f1.submit();
}
</script>

<form name=f1 action="test2.html" >
<input type=button onclick="openit();" value="open">
</form>

</BODY></HTML>

.... and "test2.html"

<HTML><BODY>
<script>
function showname(){
alert(self.name);
}
</script>
</HEAD>
<BODY>
Click this is to see window name <input type=button onclick="showname();">
</BODY>
</HTML>

--------

if you use
var addlookup=open('test2.html','addlookup');
then you can see the same name being used twice.

We've had this problem on a few machines here (about 3 out of 20), which all
appear to have identical explorer settings.
A few posts here seem to have the same problem but no follow ups have
helped.

Hope someone can help.
Mike
 
L

Lee

MPH said:
Problem:
using a named window as target, a new window is opened anyway. Also, both
windows have the same name. This happens on SOME machines only
<script>
function openit(){
var addlookup=open('about:blank','addlookup');
document.f1.target="addlookup";
document.f1.submit();
}
</script>

The open() method returns immediately, without waiting for the
windowing system to actually create the window. If that happens
to take a little longer on some machines, the new window won't
exist yet when you submit the form. Since no window exists by
the name "addlookup", a new one is created.

setTimeout("document.f1.submit()",1000);
 
E

Evertjan.

Lee wrote on 28 apr 2005 in comp.lang.javascript:
MPH said:


The open() method returns immediately, without waiting for the
windowing system to actually create the window. If that happens
to take a little longer on some machines, the new window won't
exist yet when you submit the form. Since no window exists by
the name "addlookup", a new one is created.

setTimeout("document.f1.submit()",1000);

The same effect can be reached by just:

<script>
function openit(){
document.f1.target="_blank";
document.f1.submit();
}
</script>
 
M

Mike Hammett

Hi Lee,

Thanks for your quick response, however on replacing
"document.f1.submit();"with "setTimeout("document.f1.submit()",1000);",
two windows are still displayed. What happens now is that the specified
window appears straight away with no content and a full browser window
appears with the content after the time specified in the second
parameter of settimeout().

Thanks

MPH
 
M

mph

Thanks Evertjan, however the problem is still the same two pop-up
windows are still being created. This is strange as the code has worked
correctly for the last couple of years and I have not changed the code
at all, but since a couple of days ago I have had this problem.
 
E

Evertjan.

mph wrote on 28 apr 2005 in comp.lang.javascript:
Thanks Evertjan, however the problem is still the same two pop-up
windows are still being created. This is strange as the code has worked
correctly for the last couple of years and I have not changed the code
at all, but since a couple of days ago I have had this problem.

Please quote, this is usenet, mnot email.
the problem is still

impossible with my code, please try again.
 
M

MPH

Evertjan. said:
mph wrote on 28 apr 2005 in comp.lang.javascript:


Please quote, this is usenet, mnot email.


impossible with my code, please try again.


My apologies Evertjan, as you rightly point out the code suggested by
yourself does only create the one required window. However I need to
use window.open() as this will allow me to determine the attributes of
the new window, it will also give me a window handle which I can use to
close the window elsewhere in my code.
Are you aware of a way that I may be able to achieve this?

Thanks
 
E

Evertjan.

MPH wrote on 29 apr 2005 in comp.lang.javascript:
My apologies Evertjan, as you rightly point out the code suggested by
yourself does only create the one required window. However I need to
use window.open() as this will allow me to determine the attributes of
the new window, it will also give me a window handle which I can use to
close the window elsewhere in my code.
Are you aware of a way that I may be able to achieve this?

I don't think you can submit to 'about:blank'

But try this, works fine here:

========== test.html ===============

<script type='text/javascript'>
var addlookup=open('','blah');

function openit(){
setTimeout('submitIt()',1000)
}

function submitIt(){
document.forms.f1.submit();
}

openit()
</script>

<form name=f1 target='blah' action='test2.html'>
<input name=a value=b>
</form>
 
M

MPH

Evertjan. said:
MPH wrote on 29 apr 2005 in comp.lang.javascript:


I don't think you can submit to 'about:blank'

But try this, works fine here:

========== test.html ===============

<script type='text/javascript'>
var addlookup=open('','blah');

function openit(){
setTimeout('submitIt()',1000)
}

function submitIt(){
document.forms.f1.submit();
}

openit()
</script>

<form name=f1 target='blah' action='test2.html'>
<input name=a value=b>
</form>


Thanks for the example, yes it does work for me, but it does not give
me any control over when the child window is created, this is a
problem because of the way child windows are used on my website.

As mentioned before myself and others have been using the current code
for the last couple of years without a problem, but I can no longer
get the current code to work, and I have not knowingly made any
changes.

Is the behaviour shown in the code symptomatic of any obvious settings
in windows or IE?

Thanks for your help.
 
E

Evertjan.

MPH wrote on 03 mei 2005 in comp.lang.javascript:
Is the behaviour shown in the code symptomatic of any obvious settings
in windows or IE?

I don't know. Possibly the/a popup blocker is interfering?
 
M

MPH

Evertjan. said:
MPH wrote on 03 mei 2005 in comp.lang.javascript:


I don't know. Possibly the/a popup blocker is interfering?

This was one of the first things I looked at, all pop-up blockers are
inactive on my site.

I have checked all my Internet Explorer settings against a colleagues
machines that is able to run the code and there is no difference, so I
am really at a loss over this.
 
E

Evertjan.

MPH wrote on 04 mei 2005 in comp.lang.javascript:
This was one of the first things I looked at, all pop-up blockers are
inactive on my site.

Of course.

Popup blockers don't reside on sites, but on clientside computers.
 
M

MPH

Evertjan. said:
MPH wrote on 04 mei 2005 in comp.lang.javascript:

Of course.

Popup blockers don't reside on sites, but on clientside computers.
I know, this wasnt what I meant.
 

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
473,756
Messages
2,569,533
Members
45,007
Latest member
OrderFitnessKetoCapsules

Latest Threads

Top