To redirect page using jQuery we can use the various methods such as
In JQuery we can use location object which as multiple attribute such as host, hostname, href, origin, protocol etc, and we can set the href attribute to our custom URL, which redirect to the page which we have specified.
Example :
$(location).attr('href',"http://findnerd.com");
window.location.href : This will return the current URl, but by assigning your custom URL or Page Name, you can redirect to another page.
Example :
window.location.href = 'Home.aspx';
window.location.replace : This can be used as a method and we can pass our custom URL as it's parameter, and call this method, which will replace the current url and than your can not go back to previous page that you might have accessed.
Example :
window.location.replace('Home.aspx');
window.location.assign: This can also be used as a method and we can pass our custom URL as it's parameter, and call this method, which will assign a new url and redirect to new page.
0 Comment(s)