By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
429,190 Members | 2,204 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 429,190 IT Pros & Developers. It's quick & easy.

JS opening two windows instead of one

P: n/a
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
Share this Question
Share on Google+
3 Replies


P: n/a
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

P: n/a
@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

P: n/a
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.