Coder Perfect

After a certain amount of time, redirect the website.


What must I do to have a function on a website that claims to reroute you to the site in 3 seconds or less?

Asked by codedude

Solution #1

<meta http-equiv="refresh" content="3;url=" />

Answered by Darin Dimitrov

Solution #2

Most likely, you’re seeking for the meta refresh tag:

        <meta http-equiv="refresh" content="3;url=" />
        <h1>Redirecting in 3 seconds...</h1>

Note that while using meta refresh is deprecated and frowned upon these days, it is sometimes the only viable alternative (for example, if you can’t generate HTTP redirect headers server-side and/or you need to support non-JavaScript clients).

Answered by LukeH

Solution #3

You can use javascript instead of the meta tag if you want more control. This would allow you to have some sort of display, such as a countdown.

Here’s how to use setTimeout in a very basic way ()

Answered by mbrevoort

Solution #4

Here’s a thorough (yet simple) example of refreshing a counter div while redirecting after X seconds:

The counter div’s initial content is the number of seconds to wait.

Answered by noamtm

Solution #5

The simplest method is to use the HTML META element, which looks like this:

<meta http-equiv="refresh" content="3;url=" />


Answered by Ehsan

Post is based on