469,282 Members | 2,000 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,282 developers. It's quick & easy.

window.open() opens two windows

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
Jul 23 '05 #1
13 8447
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);

Jul 23 '05 #2
Lee wrote on 28 apr 2005 in comp.lang.javascript:
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);


The same effect can be reached by just:

<script>
function openit(){
document.f1.target="_blank";
document.f1.submit();
}
</script>
--
Evertjan.
The Netherlands.
(Replace all crosses with dots in my emailaddress)

Jul 23 '05 #3


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

*** Sent via Developersdex http://www.developersdex.com ***
Jul 23 '05 #4
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.

*** Sent via Developersdex http://www.developersdex.com ***
Jul 23 '05 #5
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.

--
Evertjan.
The Netherlands.
(Replace all crosses with dots in my emailaddress)

Jul 23 '05 #6
MPH

Evertjan. wrote:
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.

--
Evertjan.
The Netherlands.
(Replace all crosses with dots in my emailaddress)

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

Jul 23 '05 #7
MPH wrote on 29 apr 2005 in comp.lang.javascript:

Evertjan. wrote:
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.

--
Evertjan.
The Netherlands.
(Replace all crosses with dots in my emailaddress)

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>

--
Evertjan.
The Netherlands.
(Replace all crosses with dots in my emailaddress)

Jul 23 '05 #8
MPH
"Evertjan." <ex**************@interxnl.net> wrote in message news:<Xn********************@194.109.133.29>...
MPH wrote on 29 apr 2005 in comp.lang.javascript:

Evertjan. wrote:
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.

--
Evertjan.
The Netherlands.
(Replace all crosses with dots in my emailaddress)

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>

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.
Jul 23 '05 #9
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?

--
Evertjan.
The Netherlands.
(Replace all crosses with dots in my emailaddress)

Jul 23 '05 #10
MPH

Evertjan. wrote:
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?

--
Evertjan.
The Netherlands.
(Replace all crosses with dots in my emailaddress)


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.

Jul 23 '05 #11
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.

--
Evertjan.
The Netherlands.
(Replace all crosses with dots in my emailaddress)

Jul 23 '05 #12
MPH

Evertjan. wrote:
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.

I know, this wasnt what I meant.

--
Evertjan.
The Netherlands.
(Replace all crosses with dots in my emailaddress)


Jul 23 '05 #13
MPH wrote on 04 mei 2005 in comp.lang.javascript:
Evertjan. wrote:
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.

I know, this wasnt what I meant.


So I gathered, but I could not resist. ;-}

Terrible, isn't it|?

--
Evertjan.
The Netherlands.
(Replace all crosses with dots in my emailaddress)

Jul 23 '05 #14

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

6 posts views Thread by Les | last post: by
10 posts views Thread by David McCulloch | last post: by
3 posts views Thread by Mehmet Gunacti | last post: by
7 posts views Thread by E Michael Brandt | last post: by
8 posts views Thread by Dominic Tocci | last post: by
4 posts views Thread by Brian Shannon | last post: by
4 posts views Thread by MrMike | last post: by
4 posts views Thread by arajunk | last post: by
1 post views Thread by CARIGAR | last post: by
reply views Thread by zhoujie | last post: by
reply views Thread by suresh191 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.