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 would use both meta, and JavaScript code and would have a link just in case.
For completeness, I think the best way, if possible, is to use server redirects, so send a 301 status code. This is easy to do via
.htaccess
files using Apache, or via numerous plugins using WordPress. I am sure there are also plugins for all the major content management systems. Also, cPanel has very easy configuration for 301 redirects if you have that installed on your server.I found a problem while working with a jQuery Mobile application, where in some cases my Meta header tag wouldn't achieve a redirection properly (jQuery Mobile doesn't read headers automatically for each page so putting JavaScript there is also ineffective unless wrapping it in complexity). I found the easiest solution in this case was to put the JavaScript redirection directly into the body of the document, as follows:
This seems to work in every case for me.
Use this code:
Please pay attention: put it in the head tag.
You can auto redirect by HTTP Status Code 301 or 302.
For PHP:
Try using:
Note: Place it in the head section.
Additionally for older browsers if you add a quick link in case it doesn't refresh correctly:
<p><a href="http://example.com/">Redirect</a></p>
Will appear as
Redirect
This will still allow you to get to where you're going with an additional click.
You don't need any JavaScript code for this. Write this in the
<head>
section of the HTML page:As soon as the page loads at 0 seconds, you can go to your page.