Note: Implement either of the following codes inside <head>…</head> section. Don’t forget to remove the comment tags( ‘<!—’ ,‘–>’ ,’//’and ‘/*…*/’) before you save the changes after implementation.
Method 1: Simple redirection
This method has simple code of redirecting to new website’s URL. Copy the code below and paste it in the <head>…</head> section. Replace http://www.newlocation.com with your new website’s URL.
<script type="text/javascript"> <!-- window.location="http://www.newlocation.com"; //--> </script>
Method 2: Show message before redirection
This method of redirecting features a popup message in old webpage. You can customize the message in the code below before implementing it in your website/blog. To do so, replace you will be redirected to main page in 10 sec with the text of your wish.
<script type="text/javascript"> <!-- function Redirect() { window.location="http://www.newlocation.com"; } document.write("You will be redirected to main page in 10 sec."); setTimeout('Redirect()', 10000); //--> </script>
Did you figure out why it takes 10 seconds to your page to redirect to the new URL? The part of the code setTimeout(‘Redirect()’,10000) is responsible for that delay. It actually means that the function Redirect() would be redirected after ten seconds of timeout. You can change this timeout delay also to the time you wanted.
Remember, 1 second here represented as 1000 and so it was specified as 10000 for 10 seconds of timeout. Keep that in mind before setting the timeout.
Method 3: Redirecting based on their browsers
This method of redirection allows the old website to be redirected to particular URL based on the web browser it is opened in. See the code below,
<script type="text/javascript"> <!-- var browsername=navigator.appName; if( browsername == "Netscape" ) { window.location="http://www.location.com/ns.htm"; } else if ( browsername =="Microsoft Internet Explorer") { window.location="http://www.location.com/ie.htm"; } else { window.location="http://www.location.com/other.htm"; } //--> </script>
You can customize the URL’s based on the compatibility of the browsers it is opened in. The URLs in window.location are supposed to be customizable.
Don’t forget to remove the comment tags before saving the changes after implementation of the codes above.
Post a Comment