Javascript Page Redirect

Javascript web page redirect means, taking user to new location. Many website use redirect for many different reasons, e.g. Many website use redirect for many different reasons, e.g. Some website redirect user from old domain to new domain, some redirect from one page to another e.g. a more relevant. In JavaScript, you script a redirect using the same code you use to load a page.

Javascript Page Redirect

How to do a redirect to an HTTP POST Request with Javascript? There are different ways to redirect web page from one page to another page or one site to another. Most commanly used ways are described below.

Javascript Page Redirect Example 1

<html>
<head>
<title>Javascript Page Redirect Example</title>
<SCRIPT LANGUAGE="JavaScript">
window.location.href="login.php?backurl="+window.location.href;
</SCRIPT>
</head>
<body>
</body>
</html>

Javascript Page Redirect Example 2

<html>
<head>
<title>Javascript Page Redirect Example</title>
<SCRIPT LANGUAGE="JavaScript">
window.history.back(-1);
</SCRIPT>
</head>
<body>
</body>
</html>

Javascript Page Redirect Example 3

<html>
<head>
<title>Javascript Page Redirect Example</title>
<SCRIPT LANGUAGE="JavaScript">
window.navigate("index.php");
</SCRIPT>
</head>
<body>
</body>
</html>

Javascript Page Redirect Example 4

<html>
<head>
<title>Javascript Page Redirect Example</title>
<SCRIPT LANGUAGE="JavaScript">
self.location="index.php";
</SCRIPT>
</head>
<body>
</body>
</html>

Javascript Page Redirect Example 5

<html>
<head>
<title>Javascript Page Redirect Example</title>
<SCRIPT LANGUAGE="JavaScript">
top.location="error.php";
</SCRIPT>
</head>
<body>
</body>
</html>