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
I use a script which redirects the user from index.html to Login Page
This is a sum up of every previous answers plus an additional solution using HTTP Refresh Header via .htaccess
1. HTTP Refresh Header
First of all, you can use .htaccess to set a refresh header like this
This is the "static" equivalent of using the
header()
function in PHPNote that this solution is not supported by every browser.
2. JavaScript
With an alternate URL:
Without an alternate URL:
Via jQuery:
3. Meta Refresh
You can use meta refresh when dependencies on JavaScript and redirect headers are unwanted
With an alternate URL:
Without an alternate URL:
Using
<noscript>
:Optionally
As recommended by Billy Moon, you can provide a refresh link in case something goes wrong:
If you are not redirected automatically:
<a href='http://example.com/alternat_url.html'>Click here</a>
Resources
Wikipedia Meta refresh
The Performance Impact of META REFRESH
Refresh (reload) a page once using jQuery?
The following meta tag, placed between inside the head, will tell the browser to redirect:
Replace seconds with the number of seconds to wait before it redirects, and replace URL with the URL you want it to redirect to.
Alternatively, you can redirect with JavaScript. Place this inside of a script tag anywhere on the page:
Just for good measure:
Make sure there are no echo's above the script otherwise it will be ignored. http://php.net/manual/en/function.header.php
Place the following code between the <HEAD> and </HEAD> tags of your HTML code:
The above HTML redirect code will redirect your visitors to another web page instantly. The
content="0;
may be changed to the number of seconds you want the browser to wait before redirecting.JavaScript
Meta tag