The following is an example of redirecting current page to another website after 3 seconds. Redirecting a URL in JavaScript is nothing but sending the user from a URL to another URL. In Javascript, window.location function is used to redirect to a URL.

<br>
A redirect automatically sends your website's visitors to a chosen destination, either a different location within the same site or a new site entirely. For example, you can redirect visitors from your domain root to a content sub-directory, such as a blog.
<br>
Content (files and folders) under the redirect path can be redirected to the destination domain root or the same path on the destination domain or not redirected at all.

Redirect a Web Page Using Meta Tag

To add meta tags in a web page, you need to edit the <head> section of the HTML file. There are two methods you can use to edit HTML files


<!DOCTYPE html>
<html>
<head>
<title>HTML Meta Tag</title>
<meta http-equiv = "refresh" content = "3; url = http://www.example.com" />
</head>
<body>
<p>Redirecting to another URL</p>
</body>
</html>

Redirect a Web Page Using Javascript


<!DOCTYPE html>
<html>
<head>
<title>Redirect url in Javascript</title>
</head>
<body>
<script>
var url= "http://www.example.com";
window.location = url;
</script>
</body>
</html>

LEAVE A REPLY

Please enter your comment!
Please enter your name here

four + 17 =