954,561 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

Redirecting a browser with Javascript....

Hello everyone. Does anyone know if it is possible to redirect a browser with Javascript? If it is, could someone please give me a clue as to how it is done? I have searched the w3schools tutorial where I started learning Javascript but can't find anything on this. Any help would be appriciated. Thanks.

Steven.

Mushy-pea
Posting Whiz in Training
275 posts since Jun 2006
Reputation Points: 47
Solved Threads: 1
 

A Google for "javascript redirect" would have answered yor question much quicker than posting here.

window.location="http://www.yourdomain.com/";
Lafinboy
Junior Poster
172 posts since Jul 2004
Reputation Points: 16
Solved Threads: 7
 

There is also the window.replace() method, which takes a string inside the parantheses. The difference between the .replace() method and the .location property, is that .replace() doesn't store the new page in the browser history.

tgreer
Made Her Cry
Team Colleague
2,118 posts since Dec 2004
Reputation Points: 227
Solved Threads: 37
 

This code is used specifically to redirect one Web page to another (i.e. if your Web site has moved, put this code at the old location)

<html>
<head>
<title>Redirect JavaScript-browsers</title>

<script language="JavaScript">
<!-- Beginning of JavaScript --------
this.location = "http://www.newsite.com";
// -- End of JavaScript code -------------- -->
</script>

</head>

<body>
This site is now located at <a href="http://www.newsite.com">http://www.newsite.com</a>.
</body>
</html>

I hope that helps you out.

FC Jamison
Posting Pro in Training
Team Colleague
446 posts since Jun 2004
Reputation Points: 92
Solved Threads: 21
 

Thanks guys.

Steven.

Mushy-pea
Posting Whiz in Training
275 posts since Jun 2006
Reputation Points: 47
Solved Threads: 1
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You