Problem with window.open and form, help me.

C

Cooper

Hello, i have a little problem; i have a form so defined:

<form id="form1" method="post" action="mypage.php" target="mytarget"
onsubmit="return false;">
<input type="submit" name="join" value="Click
Here!"
onclick="window.open('about:blank', this.form.target,
'width=320,height=240,resizable=no,
toolbar=no,location=no,directories=no,menubar=no');
setTimeout ("this.form.submit()", 10000); " />
</form>

The problem is that i click on "Click Here!" a new window is opened, but not
every content of "mypage.php" is in this window opened, in sense that
sometime is in window "mytarget" and othertime in browser, and page of
"mytarget" window remain blank.
As i can solve this problem, in mode that ALL TIME content of "mypage.php"
is put in "mytarget" window? and not in browser?
Thanks, for all and Good Christmas.
Cooper:
 
T

Thomas 'PointedEars' Lahn

Cooper said:
[...] i have a form so defined:

<form id="form1" method="post" action="mypage.php"

What would the `id' attribute be for here?
target="mytarget"

Why not use a sensible window name?
onsubmit="return false;">
<input type="submit" name="join" value="Click
Here!"
onclick="window.open('about:blank', this.form.target, ^
'width=320,height=240,resizable=no,
toolbar=no,location=no,directories=no,menubar=no');
setTimeout ("this.form.submit()", 10000); " />
[1]^^^^^[2] ^[3]

Never ever do that in a form.

[1] Syntax error, see also <http://validator.w3.org/>.

[2] In the setTimeout() string, `this' likely refers to the same object
as `window', not to the object representing the element that caused
the event. General workaround:

"window.setTimeout('document.forms[\'...\']....', 10000);"

or

"var o = this;
window.setTimeout(function() { o.form....; o = null}, 10000);"

[3] HTML or XHTML?
The problem is that i click on "Click Here!" a new window is opened, but not
every content of "mypage.php" is in this window opened, in sense that
sometime is in window "mytarget" and othertime in browser, and page of
"mytarget" window remain blank.
As i can solve this problem, in mode that ALL TIME content of "mypage.php"
is put in "mytarget" window? and not in browser?

You might not need setTimeout() (which should be window.setTimeout()) if
you used the `onsubmit' attribute properly:

<form id="form1" method="post" action="mypage.php" target="mytarget"
onsubmit="return !window.open('', this.target,
'width=320,height=240,resizable,scrollbars,toolbar=no,directories=no,menubar=no')">
<input type="submit" name="join" value="Click Here!">
</form>

Note that the `resizable' and `scrollbars' options have been set and the
`locationbar' option not used intentionally (the latter is ignored by
recent browsers anyway), to allow for an window that conforms with
accessibility guidelines and legislation.


PointedEars
 
S

SAM

Le 12/18/08 11:14 PM, Cooper a écrit :
Hello, i have a little problem; i have a form so defined:

<form id="form1" method="post" action="mypage.php" target="mytarget"
onsubmit="return false;">
<input type="submit" name="join" value="Click
Here!"
onclick="window.open('about:blank', this.form.target,
'width=320,height=240,resizable=no,
toolbar=no,location=no,directories=no,menubar=no');
setTimeout ("this.form.submit()", 10000); " />
</form>

Popup is bad

'target' is deprecated

'toolbar=no,location=no,status=no,title=no'
are no more accepted by last IE
(the popup will not fire if one of these fixing is present)
(I think ... )
The problem is that i click on "Click Here!" a new window is opened, but
not every content of "mypage.php" is in this window opened, in sense

Normal with : onsubmit="return false;" in the tag form
No?


<form id="form1" method="post" action="mypage.php" target="mytarget"
onsubmit="window.open('','mytarget','width=320,height=240');">

blah

<input type=submit value="Click Here!">
</form>
 

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,772
Messages
2,569,591
Members
45,100
Latest member
MelodeeFaj
Top