Before I start, jQuery is a JavaScript library used for DOM manipulation. So you should not be using jQuery for a page redirect.

A quote from

While jQuery might run without major issues in older browser versions, we do not actively test jQuery in them and generally do not fix bugs that may appear in them.

It was found here:

So jQuery is not an end-all and be-all solution for backwards compatibility.

The following solution using raw JavaScript works in all browsers and have been standard for a long time so you don't need any libraries for cross browser support.

This page will redirect to Google after 3000 milliseconds

<!DOCTYPE html> <html> <head> <title>example</title> </head> <body> <p>You will be redirected to google shortly.</p> <script> setTimeout(function(){ window.location.href=""; // The URL that will be redirected too. }, 3000); // The bigger the number the longer the delay. </script> </body> </html>

Different options are as follows:

window.location.href="url"; // Simulates normal navigation to a new page window.location.replace("url"); // Removes current URL from history and replaces it with a new URL window.location.assign("url"); // Adds new URL to the history stack and redirects to the new URL window.history.back(); // Simulates a back button click window.history.go(-1); // Simulates a back button click window.history.back(-1); // Simulates a back button click window.navigate("page.html"); // Same as window.location="url"

When using replace, the back button will not go back to the redirect page, as if it was never in the history. If you want the user to be able to go back to the redirect page then use window.location.href or window.location.assign. If you do use an option that lets the user go back to the redirect page, remember that when you enter the redirect page it will redirect you back. So put that into consideration when picking an option for your redirect. Under conditions where the page is only redirecting when an action is done by the user then having the page in the back button history will be okay. But if the page auto redirects then you should use replace so that the user can use the back button without getting forced back to the page the redirect sends.

You can also use meta data to run a page redirect as followed.

META Refresh

<meta http-equiv="refresh" content="0;url=" />

META Location

<meta http-equiv="location" content="URL=" />

BASE Hijacking

<base href="" />

Many more methods to redirect your unsuspecting client to a page they may not wish to go can be found on this page (not one of them is reliant on jQuery):

I would also like to point out, people don't like to be randomly redirected. Only redirect people when absolutely needed. If you start redirecting people randomly they will never go to your site again.

The next part is hypothetical:

You also may get reported as a malicious site. If that happens then when people click on a link to your site the users browser may warn them that your site is malicious. What may also happen is search engines may start dropping your rating if people are reporting a bad experience on your site.

Please review Google Webmaster Guidelines about redirects:

Here is a fun little page that kicks you out of the page.

<!DOCTYPE html> <html> <head> <title>Go Away</title> </head> <body> <h1>Go Away</h1> <script> setTimeout(function(){ window.history.back(); }, 3000); </script> </body> </html>

If you combine the two page examples together you would have an infant loop of rerouting that will guarantee that your user will never want to use your site ever again.

Related news

Que hago para dormirme rapido
Gamsberg accommodation henties bay namibia air
Na monarquia brasileira quem governava era of warring
Boer war battles bloemfontein accommodation
Madura indonesia accommodation in durban
Baqueira beret tarifas forfait sfr
Modality worklist scucisd
Moda capelli 15/16 in decimal