JavaScript – Redirect to another web page

The below code shows you how to redirect users to another web page using JavaScript/jQuery.

1. If you want to simulate someone clicking on a link, use this:

  • pure JavaScript
window.location.href = 'https://bytenota.com';
  • jQuery
$(location).attr('href', 'https://bytenota.com')

 

2. If you want to simulate an HTTP redirect, use this:

  • pure JavaScript
window.location.replace('https://bytenota.com');

0 0 vote
Article Rating
guest
0 Comments
Inline Feedbacks
View all comments
0
Would love your thoughts, please comment.x
()
x