In this example we will see how to redirect one web page to another web page using javascript. we need to set the redirect url to window.location.href, then the web page will be redirect to given url.
Syntax: window.location.href = "url here";
Source Code
<html>
<head>
<title></title>
<script language="javascript">
function redirectwebsite() {
var url = document.getElementById("txtwebsiteurl").value;
window.location.href = url;
}
</script>
</head>
<body>
Redirect this web site to
<input type="text" id="txtwebsiteurl" value="http://www.dotnetlearners.com" style="width: 410px;" />
<input type="button" value="Redirect" onclick="redirectwebsite();" />
</body>
</html>