leejeok

The Remarkable Everyday

Auto Redirect by Javascript

Posted by leejeok on March 12, 2008

Reason to implement the “redirect pages” is to redirect your visitor to the proper page.

You may need it when:-

 

  • redirect to a new domain name – you have a new domain name and you would like to inform your visitor about this.
  • redirect visitor to another website hosted at another web server – you have another web server to keep website within it. Not only the web server easy to manage but also reducing the trafic and processing time for each server.
  • placing time-delay of your website – you may want to display some timeout message to visitor. Such as thank you or downloading timeout.
  • refresh the website – to keep your content updated frequently base on timeout.

Here are the simple code to auto redirect:

<script type=”text/javascript”>

<!–

window.location = “http://hotname.com/&#8221;

//–>

</script>

 

Here are the simple code to auto redirect your user by using timeout of 5 seconds. 

<html>

<head>

<script type=”text/javascript”>

<!-

function dodelay() {   

window.location = “http://hostname.com&#8221;

}

//–>

</script>

</head>

<body onLoad=”setTimeout(‘dodelay()’, 5000)”>

<p>

You will be redirect to our new website in 5 seconds.

Click <a href=”http://hostname.com”>here</a&gt; to go immediately.

</p> 

</body>

</html>

Advertisements

One Response to “Auto Redirect by Javascript”

  1. Deden said

    How if i want to redirect to blank pages??? what is the code???

    Please share with me. I really need it

    Thanks.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

 
%d bloggers like this: