Saturday 29 March 2014

How to create a redirect page using JS/JQUERY

Problem definition

I am owner of two domains and want to redirect my traffic from one website to another,

http://www.raymn.in drive traffic to http://www.raymn.com.

Previous JQuery posts and related terms, Create redirect page form js/jqueryModify URL without reloading

Solution

The window.location object can be used to get the current page address (URL) and to redirect the browser to a new page.

OR 

You can use window.location.replace(URL).

The difference between window.location and window window.location.replace(URL), is that replace() removes the URL of the current document from the document history, meaning that it is not possible to use the "back" button to navigate back to the original document.

Example

window.location = "http://www.raymn.com";

OR

window.location.replace("http://www.raymn.com");


Tag and Related Topics

What is Jquery/js Location Href,
URL Redirect Javascript,



No comments:

Post a Comment