...

View Full Version : How to change the location.href



ArnoldR
08-06-2008, 10:58 PM
This is a simplified example of what I'm trying to do:

function myURL()
{
alert("function myURL executing");
alert(location);
location.href="http://www.google.com";
alert(location);
}
---
<form name="queryForm" onSubmit="myURL()">
<input type="submit" value="run myURL function">

ArnoldR
08-06-2008, 11:33 PM
New to list, sorry. I cannot get the javascript to change the URL. I've dumbed down what I'm trying to do but even that doesn't work. I've tried rewriting the location.href, using location.reload() too but can't make it change. Any ideas? Thanks.


function myURL()
{
alert("function myURL executing");
alert(location);
location.href="http://www.google.com";
alert(location);
}
---
<form name="queryForm" onSubmit="myURL()">
<input type="submit" value="run myURL function">

ninnypants
08-07-2008, 12:09 AM
you should just be able to use the 'action' attribute


<form name="queryForm" method="get" action="http://www.google.com/">

binaryWeapon
08-07-2008, 12:12 AM
It is working for me. Both alerts execute before the page changes to google.com, and therefore both say the same thing, but then it goes to google.com successfully. What are you trying to make it do?



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum