I'm using javascript and localStorage
to redirect.
But I have found that there are a lot of ways to do that. Here are a few:
document.location
document.location.href
window.open(url,how)
window.location
top.location
window.navigate() //not sure that this works
and the html meta way
<meta http-equiv="REFRESH" content="0;url=http://www.google.com"/>
I am just interested which of the above (or any other code) will redirect faster. As for info I will use it to redirect (to a website) google chrome when new tab is opened.
From the drop-down menu select Settings then scroll down and click Advanced. In the Privacy & security section choose Content settings > Pop-ups and redirects then ensure that the Allowed option is turned off.
To redirect a webpage after 5 seconds, use the setInterval() method to set the time interval. Add the webpage in window. location. href object.
Complete HTML/CSS Course 2022 To redirect URL to a different website after few seconds, use the META tag, with the content attribute. The attributes set the seconds. The following is an example of redirecting current page to another website in 10 seconds. The content attribute sets the seconds.
Meta redirect is an awful hack and it breaks the back button. Never use it.
The rest is basically equivalent. window.location
is most common.
The fastest way may be not to redirect from JS, but to use <a href>
(with a click handler if you need to perform some operation before navigation), which e.g. enables browsers to prefetch DNS.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With