Empowering a brighter world through superior education is our commitment.

Online Calculators & Tools

jQuery redirect

How to redirect a page to URL with jQuery.

Search engines use the 301 status code to transfer the page rank from the old URL to the new URL.

jQuery redirection return http response status code: 200 OK.

So jQuery redirection, like Javascript redirection, is not search engine friendly and it is better to use other redirection methods that return status code of 301 Moved Permanently.

jQuery redirect

Replace old page with redirection code with the URL of the page you want to redirect to.

old-page.html:

<!DOCTYPE html>
<html>
<body>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
<script type="text/javascript">
   // jQuery URL redirection
   $(document).ready( function() {
      url = "http://www.mydomain.com/new-page.html";
      $( location ).attr("href", url);
  });
</script>
</body>
</html>

jQuery redirect example

jquery-redirect-test.htm

<!DOCTYPE html>
<html>
<body>
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
<script type="text/javascript">
   $(document).ready( function() {
      url = "https://www.calcmagics.com/web/dev/jquery-redirect.htm";
      $(location).attr("href", url);
  });
</script>
</body>
</html>

 

 

Javascript redirection