469,951 Members | 2,681 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

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

IE form submission cannot change location.href?

Hi, I have a form that I want to click a button on and cause the
location.href to change. this is what I used:

the function:

function testform(){
location.href="http://www.google.com"

}

the form:
<form >
<INPUT TYPE=submit NAME=foo VALUE=Proto onClick="testform()">
</form>

I have of course done variations of the above, this works in firefox
and mozilla, in IE it does nothing, what is the bug or feature I am
dealing with here?
Jul 23 '05 #1
1 3322

"Bryan" <br*@itnisk.com> wrote in message
news:9e************************@posting.google.com ...
Hi, I have a form that I want to click a button on and cause the
location.href to change. this is what I used:

the function:

function testform(){
location.href="http://www.google.com"

}

the form:
<form >
<INPUT TYPE=submit NAME=foo VALUE=Proto onClick="testform()">
</form>

I have of course done variations of the above, this works in firefox
and mozilla, in IE it does nothing, what is the bug or feature I am
dealing with here?


I think the problem is that you're using type="submit". The function works,
but the button also submits the form which seems to override the window.href
call. Change it to type="button" and it should work. Or leave it as submit
if you need to, and change the onclick to "testform(); return false;"

Incidentally, a nicer way to do this without even using javascript would be
to specify the href in the form's action

<form action="http://www.google.com" method="get">
<input type="submit" value="Proto"/>
</form>
Jul 23 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

6 posts views Thread by Jeff Dunnett | last post: by
1 post views Thread by Display Name | last post: by
2 posts views Thread by JHB | last post: by
27 posts views Thread by Chris | last post: by
8 posts views Thread by yawnmoth | last post: by
2 posts views Thread by rpjd | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.