Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

window location

document.getElementById("demo").innerHTML = 
"The full URL of this page is:<br>" + window.location.href;
//Result
//The full URL of this page is: https://www.w3schools.com/js/tryit.asp?filename=tryjs_loc_href

document.getElementById("demo").innerHTML =
"Page hostname is " + window.location.hostname;
//Result
//Page hostname is www.w3schools.com

document.getElementById("demo").innerHTML =
"Page path is " + window.location.pathname;
//Result
//Page path is /js/js_window_location.asp
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #window #location
ADD COMMENT
Topic
Name
3+5 =