jQuery redirect page, with javascript alternative

· kalpesh

jQuery javascript frameworkjQuery redirect one page to another using the following code:

var your_url = http://ka.lpe.sh/’; //change this to your url  
$(location).attr(href,your_url);

Above code works to redirect page in jQuery, but javascript code is good alternative here.

Using javascript to redirect your page using below code, which is better than jQuery, will do the job:

window.location.replace(http://ka.lpe.sh/”);

Another javascript approach which will mock as if the URL is being clicked to redirect is:

window.location.href = http://ka.lpe.sh/”;

Even this will do the trick in javascript, which sets your URL in a window object and assigns it to anchor tag’s href attribute automatically:

window.location = http://ka.lpe.sh/”;

#jquery #redirect