Is it possible to set up a basic HTML page to redirect to another page on load?
相关问题
- Views base64 encoded blob in HTML with PHP
- Is there a way to play audio on a mobile browser w
- HTML form is not sending $_POST values
- implementing html5 drag and drop photos with knock
-
Why does the box-shadow property not apply to a
The simple way which works for all types of pages is just to add a
meta
tag in the head:Put the following code in the
<head>
section:You could use a META "redirect":
or JavaScript redirect (note that not all users have JavaScript enabled so always prepare a backup solution for them)
But I'd rather recommend using mod_rewrite, if you have the option.
If you are looking forward to follow modern web standards, you should avoid plain HTML meta redirects. If you can not create server-side code, you should choose JavaScript redirect instead.
To support JavaScript-disabled browsers add a HTML meta redirect line to a
noscript
element. Thenoscript
nested meta redirect combined with thecanonical
tag will help your search engine rankings as well.If you would like to avoid redirect loops, you should use the
location.replace()
JavaScript function.A proper client-side URL redirect code looks like this (with an Internet Explorer 8 and lower fix and without delay):
Just use the onload event of the body tag: