How to Auto-Redirect a Web Page with HTML or JavaScript

There are two easy ways to send visitors from one web page to another automatically: an HTML meta refresh tag, or a few lines of JavaScript.

Redirect with an HTML Meta Refresh

This page points the browser to a different page after 2 seconds. The number in content is the delay in seconds. It’s good practice to include a manual link in case the browser doesn’t follow the redirect.

<html>
<head>
<title>A web page that points a browser to a different page after 2 seconds</title>
<meta http-equiv="refresh" content="2; URL=http://example.com/services/computing/">
<meta name="keywords" content="automatic redirection">
</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/">the destination</a>
manually.
</body>
</html>

Redirect with JavaScript

You can also do it with JavaScript. This example opens the new site in a new browser window after a 4.5-second (4500 ms) delay:

<script type="text/javascript">
  window.setTimeout('window.open("http://example.com/","newsite")', 4500);
</script>