Loading Please Wait...
The window.location object can be used to get the current page address (URL) and to redirect the browser to a new page.
The window.location object can be written without the window prefix.
Some examples:
The window.location.href property returns the URL of the current page.
alert(window.location.href);
The window.location.hostname property returns the name of the internet host (of the current page).
alert(window.location.hostname);
The window.location.pathname property returns the pathname of the current page.
alert(window.location.pathname);
The window.location.protocol property returns the web protocol of the page.
Most browsers will not display default port numbers (80 for http and 443 for https).
alert(window.location.protocol);
The window.location.port property returns the number of the internet host port (of the current page).
alert(window.location.port);
The window.location.assign() method loads a new document.
<html>
<head>
<script>
function newDoc() {
window.location.assign("https://lynxsia.com");
}
</script>
</head>
<body>
<input type="button" value="Load new document" onclick="newDoc()">
</body>
</html>
The window.location.reload() method reloads the current document.
<html>
<body>
<input type="button" value="Reload Current Document" onclick="window.location.reload();">
</body>
</html>
How you feel about this blog:
Share this blog on:
If you find any error in the turtorials, or want to share your suggestion/feedback, feel free to send us email at: info@lynxsia.com
Contact UsWe are concern with various development process like website design & development, E-commerce development, Software development, Application development, SMS & Bulk SMS Provider, PWA Development, and many more..
Copyright ©
, Lynxsia IT Solutions, All rights reserved