How To Use Javascript Redirect To Another Web Page

How to use Javascript or JQuery to redirect the user from one page to another web page

  • Javascript:
    Can use window.location.replace which is similar behavior as an HTTP redirect

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

    or use window.location.href which is similar behavior as clicking on a link

    window.location.href("http://softwarehtec.com");
  • Jquery:
    Can use the location’s href attribute to do the redirection

    $(location).attr("href", "http://softwarehtec.com/");
0 0 votes
Article Rating
Subscribe
Notify of
guest
0 Comments
Inline Feedbacks
View all comments