Javascript Location
Javascript location(redirect) is nothing but a mechanism of sending search engines and users on a different URL from the original one.
Some examples:
- location.href – href (URL) of the current page.
- location.hostname – domain name of the web host.
- location.pathname – path and filename of the current page
- location.protocol – web protocol used (http: or https:).
- location.assign() – loads a new document.
EXAMPLE:
<html>
<head>
<script type = "text/javascript">
function page_redirect(){
window.location = "https://i2tutorials.com/";
}
</script>
</head>
<body>
<h2> This is an example of the page redirection </h2>
<p> Click the following button to see the effect. </p>
<form>
<input type = "button" value = "Redirect" onclick = "page_redirect()" />
</form>
</body>
</html>
OUTPUT:
