Redirect website after specified amount of time
<meta http-equiv="refresh" content="3;url=http://www.google.com/" />
Page Redirect after X seconds wait using JavaScript
It looks you are almost there. Try:
if(error == true){
// Your application has indicated there's an error
window.setTimeout(function(){
// Move to a new location or you can do something else
window.location.href = "https://www.google.co.in";
}, 5000);
}
Page redirect after certain time PHP
header( "refresh:5;url=wherever.php" );
this is the php way to set header
which will redirect you to wherever.php
in 5 seconds
Remember that header() must be called before any actual output is sent, either by normal HTML tags, blank lines in a file, or from PHP. It is a very common error to read code with include, or require, functions, or another file access function, and have spaces or empty lines that are output before header() is called. The same problem exists when using a single PHP/HTML file. (source php.net)
JavaScript redirect to another page when time reaches 5 minutes to top of hour
setTimeout() happens after a specified amount of time, where you have it defined to fire after 1 second (1000 milliseconds = 1 second) and then it will stop, unless you trigger the timeout again.
One solution is to check the timeout every 1 second using setInterval, and as soon as the minutes reach 55 minutes, do the redirect. You could also change this to trigger less frequently, say every 15 or 30 seconds (15000, 30000).
// function that triggers at the intervalfunction checkTimeout() {var now = new Date(); var minutes = now.getMinutes(); console.log(minutes); if (minutes >= 55) { location.href = 'https://www.google.com'; }}
setInterval(checkTimeout, 1000); // check interval every 1 second
How to redirect automatically after short delay on Error 404 page?
You should use a client side redirection method to apply the proper delay. If you want to support browsers with disabled JavaScript, just paste a META refresh
into a noscript
element. It is better to place it inside a noscript
element because search engines give a penalty for usual META refresh
links.
If the redirect is permanent, I suggest you to use the canonical
tag too to keep the link-juice of missing pages.
This JavaScript redirect generator is a good way to go. The code pasted from there. It also has an IE 8 and lower fix to pass the HTTP referer, which is useful for traffic analysis.
<!-- Pleace this snippet right after opening the head tag to make it work properly -->
<!-- This code is licensed under GNU GPL v3 -->
<!-- You are allowed to freely copy, distribute and use this code, but removing author credit is strictly prohibited -->
<!-- Generated by http://insider.zone/tools/client-side-url-redirect-generator/ -->
<!-- REDIRECTING STARTS -->
<link rel="canonical" href="https://example.com/"/>
<noscript>
<meta http-equiv="refresh" content="5;URL=https://example.com/">
</noscript>
<!--[if lt IE 9]><script type="text/javascript">var IE_fix=true;</script><![endif]-->
<script type="text/javascript">
var url = "https://example.com/";
var delay = "5000";
window.onload = function ()
{
setTimeout(GoToURL, delay);
}
function GoToURL()
{
if(typeof IE_fix != "undefined") // IE8 and lower fix to pass the http referer
{
var referLink = document.createElement("a");
referLink.href = url;
document.body.appendChild(referLink);
referLink.click();
}
else { window.location.replace(url); } // All other browsers
}
</script>
<!-- Credit goes to http://insider.zone/ -->
<!-- REDIRECTING ENDS -->
How to redirect the user to another site after some time?
With a mix of both answer before I start looking at wordpress functions docs. I found something and add it to my header.php on my wordpress site.
<?php if ( is_page('Page Title') ) { ?>
<script type="text/javascript">
window.setInterval(customRedirect, 3000);
function customRedirect() {
window.location = "http://www.google.com";
}
</script>
<?php } >
So whenever the user enters a page with that title it will make the redirect. Thanks.
How can I redirect the user after an amount of time using PHP and codeigniter?
I don't believe this can be done with PHP alone. You have two options in HTML.
A <meta http-equiv="refresh">
tag in your <head>
can be used to reload or redirect the user after a specified number of seconds. Wikipedia has a couple of examples:
Place inside
<head>
to refresh page after 5 seconds:<meta http-equiv="refresh" content="5">
Redirect to
http://example.com/
after 5 seconds:<meta http-equiv="refresh" content="5; url=http://example.com/">
Redirect to
http://example.com/
immediately:<meta http-equiv="refresh" content="0; url=http://example.com/">
The other option is to use JavaScript to redirect the user. You can do this by modifying the window.location
property, using the setTimeout
function to delay the call for, for example, five seconds (5000 miliseconds).
var redirect = function() {
window.location = "/index.html";
};
setTimeout(redirect, 5000);
The <meta>
redirect should work for almost all visitors, while the JavaScript won't work if they have JavaScript disabled. However, these don't conflict in any way so you could just include both on your page to be safe.
How to redirect after a certain amount of time using Slim framework?
The way you are using redirect i presume, you are doing a web page and not an api, so you will probaly have the possitbility of going the Javascript route. Which for what i know, is the only way to solve your problem.
If you echo this into your html, it will redirect after 10 seconds. Be aware that the timeout argument is in milliseconds.
<script>
function redirect(page) {
setTimeout(function () {
window.location.href = page;
}, 5000);
}
redirect("/new_project/contact");
</script>
This is probaly not what you are looking for, but is the only way to solve your initial problem statement.
Related Topics
When Should One Use HTML Entities
How to Escape < and > Inside <Pre> Tags
Why Are Frames Deprecated in HTML
Html/CSS - Best Practice for Preserving White Space on Certain Elements
Html5 Localstorage Size Limit for Subdomains
How to Display Vertical Text in Table Headers with Auto Height/Without Text Overflow
Redirect Website After Specified Amount of Time
Position Absolute and Overflow Hidden
How Do HTML Parses Work If They'Re Not Using Regexp
Font Rendering/Line-Height Issue on MAC/Pc (Outside of Element)
CSS - Make Divs Align Horizontally
What Are the Different Doctypes in HTML and What Do They Mean
How to Style a Mouseover on an Image Map Using CSS
How to Have Two Fixed Width Columns With One Flexible Column in the Center