469,946 Members | 1,831 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

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

JS opening two windows instead of one

When this form's being submitted, two windows are opening instead of only
one
here is the function I'm using:

function subForm(){
//insert form validation here
//if form is valid, open a pop-window & submit
subWin =
window.open("http://www.smoochya.com/books.html","subWin","width=550,height=
350,address=no")
document.SendScore.action = "tellafriend_quiz1.php"
document.SendScore.method = "post"
document.SendScore.target = subWin
document.SendScore.submit()
}

here is the form in the HTML body:
<FORM NAME="SendScore" >
<INPUT TYPE="hidden" name="numbercorrect" value="">
<INPUT TYPE="IMAGE" onClick="subForm()" SRC="/images/passitalong_quiz.jpg"

</FORM>

the only other thing going on which probably is not interfering is the fact
that I'm making that "hidden" variable switch to a javascript variable from
being submitted by another form page that comes before this one.
I'm calling it in the BODY tag using onLoad="javascript:
SwitchNumberRight();" which calls this function:

function SwitchNumberRight(){
document.SendScore.numbercorrect.value = numberright;
}

anyway the code can be viewed by going to http://www.smoochya.com/quiz1.html
and picking some answers (or not picking any) on the quiz. You'll notice
that one of the windows gives you your score while the other one (without
any toolbars) doesn't. Can't seem to get it to open only one window with the
score included.

Any help greatly appreciated..
Thanks,
M
Jul 20 '05 #1
3 1535
Lee
Display Name said:

When this form's being submitted, two windows are opening instead of only
one
here is the function I'm using:

function subForm(){
//insert form validation here
//if form is valid, open a pop-window & submit
subWin =
window.open("http://www.smoochya.com/books.html","subWin","width=550,height=
350,address=no")
document.SendScore.action = "tellafriend_quiz1.php"
document.SendScore.method = "post"
document.SendScore.target = subWin
document.SendScore.submit()
}


You're getting a second window because the window you open()
is not being set as the target of the form.

document.SendScore.target = "subWin"

The value of the target attribute is the name of the window, not
a reference to the window.

Jul 20 '05 #2
@SM


Lee a *crit :
Display Name said:

When this form's being submitted, two windows are opening instead of only
one
here is the function I'm using:

function subForm(){
//insert form validation here
//if form is valid, open a pop-window & submit
change the name of your popup
subWin =

popWin=
window.open("http://www.smoochya.com/books.html","subWin","width=550,height=
350,address=no")
document.SendScore.action = "tellafriend_quiz1.php"
document.SendScore.method = "post"
document.SendScore.method = "get"
document.SendScore.target = subWin
document.SendScore.target = "subWin"
document.SendScore.submit()
}


You're getting a second window because the window you open()
is not being set as the target of the form.


and this window has same name as target ...
document.SendScore.target = "subWin"

The value of the target attribute is the name of the window, not
a reference to the window.


I think (but I could bad understand you) that the 'target'
is the target included in the window
truc = window.open('url','target','attributes');
or with :
truc=window.open('page.htm','chose','width=300,hei ght=300,resizable=0');

onclick="truc.location = 'page_2.htm';"
would work as
<a href="page_2.htm" target="chose">page 2</a>
--
************************************************** ************
Stéphane MORIAUX : mailto:st*********************@wanadoo.fr
Aide aux Pages Perso (images & couleurs, formulaire, CHP, JS)
http://perso.wanadoo.fr/stephanemoriaux/internet/
************************************************** ************
Jul 20 '05 #3
Stephane...
you're the man. your edits worked even w/o having to adjust the target
parameters. thanks a lot!
M

"@SM" <st**************@wanadoo.fr> wrote in message
news:3F***************@wanadoo.fr...


Lee a *crit :
Display Name said:

When this form's being submitted, two windows are opening instead of onlyone
here is the function I'm using:

function subForm(){
//insert form validation here
//if form is valid, open a pop-window & submit
change the name of your popup
subWin =


popWin=

window.open("http://www.smoochya.com/books.html","subWin","width=550,height

=
350,address=no")
document.SendScore.action = "tellafriend_quiz1.php"
document.SendScore.method = "post"
document.SendScore.method = "get"
document.SendScore.target = subWin
document.SendScore.target = "subWin"
document.SendScore.submit()
}


You're getting a second window because the window you open()
is not being set as the target of the form.


and this window has same name as target ...
document.SendScore.target = "subWin"

The value of the target attribute is the name of the window, not
a reference to the window.


I think (but I could bad understand you) that the 'target'
is the target included in the window
truc = window.open('url','target','attributes');
or with :
truc=window.open('page.htm','chose','width=300,hei ght=300,resizable=0');

onclick="truc.location = 'page_2.htm';"
would work as
<a href="page_2.htm" target="chose">page 2</a>
--
************************************************** ************
Stéphane MORIAUX : mailto:st*********************@wanadoo.fr
Aide aux Pages Perso (images & couleurs, formulaire, CHP, JS)
http://perso.wanadoo.fr/stephanemoriaux/internet/
************************************************** ************

Jul 20 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

14 posts views Thread by D. Alvarado | last post: by
2 posts views Thread by Matt Hamilton | last post: by
3 posts views Thread by =?Utf-8?B?TGllbGE=?= | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.