Forum Moderators: open

Message Too Old, No Replies

URL Forwarding

Script for URL forwarding?

         

alex_cross

12:26 am on Oct 1, 2003 (gmt 0)

10+ Year Member



I need a URL Forwarding Script that still allows a user to back out of the page. If anyone has one, it would be appreciated.

tedster

3:03 am on Oct 1, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Instead of setting location.href to be equal to a new URL, you can use the javascript replace() method:

location.replace(http://www.example.com/newpage.html)

This overwrites, or replaces the current URL in the browser history with your new URL, and loads the new page as well. That means the Back Button will work as the user expects it to instead of trapping them in a circle.

[edited by: tedster at 3:15 pm (utc) on Oct. 1, 2003]

alex_cross

11:52 am on Oct 1, 2003 (gmt 0)

10+ Year Member



Where can I find a script like this? Thanks.

Jeeek

3:03 pm on Oct 1, 2003 (gmt 0)

10+ Year Member



put an onload into your body-tag

could look like that:

<body onload="javascript:location.replace('http://www.yoururl.com')">

(use full URL, no relative links - Opera will cause problems with rel. links in location.replace)

hope that helps

tedster

3:16 pm on Oct 1, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Thanks, Jeeek, for adding the bit about using the full URL. I edited my first post so future users can get that right off the bat.

alex_cross

8:00 pm on Oct 1, 2003 (gmt 0)

10+ Year Member



Thanks. That worked well!