JS opening two windows instead of one

D

Display Name

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" >
</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
 
L

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.
 
@

@SM

Lee a *crit :
Display Name said:

change the name of your popup

document.SendScore.method = "get"

document.SendScore.target = "subWin"
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,height=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:[email protected]
Aide aux Pages Perso (images & couleurs, formulaire, CHP, JS)
http://perso.wanadoo.fr/stephanemoriaux/internet/
**************************************************************
 
D

Display Name

Stephane...
you're the man. your edits worked even w/o having to adjust the target
parameters. thanks a lot!
M
 

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,770
Messages
2,569,584
Members
45,077
Latest member
SangMoor21

Latest Threads

Top