get document.location and redirect

JavaScript and client side scripting.

Moderator: General Moderators

Post Reply
Nay
Forum Regular
Posts: 951
Joined: Fri Jun 20, 2003 11:03 am
Location: Brisbane, Australia

get document.location and redirect

Post by Nay »

I want to have a favorite that I can click on, that will take the page's location and register as a variable and redirect.

Like the favorite's location is:

Code: Select all

javascript:var=document.location;document.location="http://locahost/parse.php?url="+var
Apparently that didn't do anything at all. I'm using Mozilla 1.5.

-Nay
User avatar
scorphus
Forum Regular
Posts: 589
Joined: Fri May 09, 2003 11:53 pm
Location: Belo Horizonte, Brazil
Contact:

Post by scorphus »

var is a JavaScript keyword used to declare variables. Try this:

Code: Select all

var loc = document.location;
document.location = "http://locahost/parse.php?url=" + loc;
Regards,
Scorphus.
User avatar
scorphus
Forum Regular
Posts: 589
Joined: Fri May 09, 2003 11:53 pm
Location: Belo Horizonte, Brazil
Contact:

Post by scorphus »

Or you could use only one line:

Code: Select all

document.location = "http://localhost/parse.php?url=" + document.location;
Nay
Forum Regular
Posts: 951
Joined: Fri Jun 20, 2003 11:03 am
Location: Brisbane, Australia

Post by Nay »

Thanks a lot dude! My final is:

Code: Select all

javascript:document.location = "http://localhost/scripts/xanga/override.php?url=" + document.location;
Thanks again, the override.php with do a $_GET['url'] and do some other stuff lol.

-Nay
Post Reply