Redirection Script

Last Updated: Nov. 09

Have you just changed your site’s domain and want visitors to be automatically redirected to your new site? Perhaps you just want to redirect the old URL of a page to the new URL of the page. Well, you’ve come to the right place to see how.

Below are three main types of redirection scripts using JavaScript. Use them (without spaces) anywhere within your html tags.

Automatic – Redirect Without Telling Visitor

< script >
location = “http://YOURURL.com”;
< /script >

Alert – Redirect With Messege to Visitor

< script >
alert( “This site is now at whatever.com. Please click OK to be redirected.”);
location = “http://YOURURL.com”;
< /script >

Confirmation – Allows Visitor to Move Forward or Cancel

< script >
if(confirm( “This page has moved. Would you like to be redirected?”))
{
location = “http://YOURURL.net/whatever-page”;
}
else {
history.back();
}
< /script >

Credits: Inspire Design

Bookmark and Share