Page redirection

Best method: ask the user to click. Safe and looks seriously. See this example (on this page, you can study the pull-down menu, containing only text, and active resize of the picture in the page header (Javascript) and of the arrow to the new location (pure html, just 95% width of the client).

Redirect after 3 second (a "meta" tag):

<html>
<head>
<title>A web page that points a browser to a different page after 3 seconds</title>
<meta http-equiv="refresh" content="3; URL=http://example.com/examplepage/">
</head>
<body>
If your browser doesn't automatically go there within a few seconds, 
you may want to go to 
<a href="http://example.com/examplepage/">the destination</a> 
manually.
</body>
</html>

Javascript:

<script language="javascript" type="text/javascript">
<!--
window.setTimeout('window.location("http://example.com/examplepage/","The new window")',3000);
// -->
</script>

Javascript:

<script language="javascript" type="text/javascript">
<!--
window.setTimeout('window.location.href("http://example.com/examplepage/","The new window")',3000);
// -->
</script>

Other Javascript commands to redirect:

window.location="url"; // simplified - the next:
window.location.href="url"; // Simulates normal navigation to a new page
window.location.replace("url"); // Removes current URL from history and replaces it with a new URL
window.location.assign("url"); // Adds new URL to the history stack and redirects to the new URL

window.history.back(); // Simulates a back button click
window.history.go(-1); // Simulates a back button click

Default part of the window.location object to receive a string is the ".href" property.

window.location.replace(...) is better than using window.location.href, because replace() does not keep the originating page in the session history, meaning the user won't get stuck in a never-ending back-button fiasco.

If you want to simulate someone clicking on a link, use location.href

If you want to simulate an HTTP redirect, use location.replace

HTML - redirect afrer 3 second

In the first example of this page:

META Refresh

<meta http-equiv="refresh" content="3;url=http://evil.com/" />

META Location (no time specified, so immediately)

<meta http-equiv="location" content="url=http://evil.com" />


https://css-tricks.com/redirect-web-page/ :
On the server, in .htaccess: (general for root, "/", or one line for each page)

Redirect 301 / http://www.new-website.com
Redirect 301 /old-page.html http://www.new-website/new-page.html 

The server can have allowed to have .htaccess in all the directories, or just in all the home directories, or only at the server root (inaccessible to users). Depends on server setting.

php redirects:
With php we can use the header function, which is quite straightforward:

<?php 
header('Location: http://www.new-website.com');
exit;
?>

This has to be set before any markup or content of any other sort, however there is one small hitch. By default the function sends a 302 redirect response which tells everyone that the content has only been moved temporarily. Considering our specific use case we'll need to permanently move the files over to our new website, so we'll have to make a 301 redirect instead:

<?php
header('Location: http://www.new-website.com/', true, 301);
exit();
?>

https://www.jakpsatweb.cz/presmerovani.html :

<?php
header("HTTP/1.1 301 Moved Permanently");
header("Location: http://www.wholeaddress.com");
header("Connection: close");
?>

 

Google notes:
https://support.google.com/webmasters/

 

Timer function

In Javascript, you can postpone calling a function by using the SetTimeout function. If the called function contains another SetTimeout setting to call itself, it can regularly repeat:

function myTest() {
  ChangeImage();
  setTimeout("myTest()", 3000);
};

//*** first initiation of the timer:
setTimeout("myTest()", 1000);

The blue part contains the function declaration. It is not executed, just declared for later use.
The red line is just a Javascript command, and is executed during processing the page. It sets the timeout, so the previously declared function is called after 1000 ms.
The blue part can contain other code, here is calling a function. Then it sets the timeout to 3000 ms, referencing itself.

Similar code is used, for example, here and here, see the source code.

Timer function with a state variable

If you need to pass a list of a situations, the best solution is to remember a number of the next state. This method is used for the traffic lights simulation. In this case, each step has a different time delay.

 


Try to find some other solutions on the web. Try to construct your own program using them.