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 redirection is actually Javascript redirection. Redirecting with jQuery is considered overkill becuase you can do pure Javascript redirection with less code.

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.justfreetools.com/en/web-design/web-development/jquery-redirect-test.htm";
      $(location).attr("href", url);
   });
</script>
</body>
</html>

Press this link to redirect from jquery-redirect-test.htm back to this page:

jQuery redirect test

Javascript redirection »


Currently, we have around 935 calculators, conversion tables and usefull online tools and features to make your life easier or simply help you to do your work or duties faster and in more effective way. These below are the most commonly used by many users at all

And we are still developing more. Our goal is to become the one-stop, go-to site for people who need to make quick calculations or who need to find quick answer for basic conversions.

Additionally, we believe the internet should be a source of free information. Therefore, all of our tools and services are completely free, with no registration required. We coded and developed each calculator individually and put each one through strict, comprehensive testing. However, please inform us if you notice even the slightest error – your input is extremely valuable to us. While most calculators on Justfreetools.com are designed to be universally applicable for worldwide usage, some are for specific countries only.


This website uses cookies to improve your experience, analyze traffic and display ads. Learn more