Go Back   CodingForums.com > :: Client side development > JavaScript programming

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 08-06-2008, 09:58 PM   PM User | #1
ArnoldR
New to the CF scene

 
Join Date: Aug 2008
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
ArnoldR is an unknown quantity at this point
Question How to change the location.href

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 is offline   Reply With Quote
Old 08-06-2008, 10:33 PM   PM User | #2
ArnoldR
New to the CF scene

 
Join Date: Aug 2008
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
ArnoldR is an unknown quantity at this point
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.
Code:
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 is offline   Reply With Quote
Old 08-06-2008, 11:09 PM   PM User | #3
ninnypants
Regular Coder

 
ninnypants's Avatar
 
Join Date: Apr 2008
Location: Utah
Posts: 504
Thanks: 10
Thanked 47 Times in 47 Posts
ninnypants is an unknown quantity at this point
you should just be able to use the 'action' attribute
Code:
<form name="queryForm" method="get" action="http://www.google.com/">
ninnypants is offline   Reply With Quote
Old 08-06-2008, 11:12 PM   PM User | #4
binaryWeapon
Regular Coder

 
Join Date: Sep 2007
Location: AZ, USA
Posts: 685
Thanks: 6
Thanked 46 Times in 46 Posts
binaryWeapon is on a distinguished road
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?
binaryWeapon is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 02:24 AM.


Advertisement
Log in to turn off these ads.