"Bryan" <br*@itnisk.com > wrote in message
news:9e******** *************** *@posting.googl e.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="testfo rm()">
</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>