Get Url And Url Parts In Javascript Web-development (jquery) Get Url And Url Parts In Javascript Get URL and URL Parts in JavaScript
JavaScript can access the current URL
http://venifah.blogspot.com/example/currenturl
window.location.protocol = "http"
window.location.host = "venifah.blogspot.com"
window.location.pathname = "example/currenturl"
full URL path in JavaScript:
var newURL = window.location.protocol + "//" + window.location.host + "/" + window.location.pathname;
breath up the pathname, for example a URL like http://venifah.blogspot.com/example/currenturl, you can split the string on "/" characters
<script> var pathArray = window.location.pathname.split( '/' ); var secondLevelLocation = pathArray[2]; //access the different parts by the parts of the array alert(secondLevelLocation); //results = currenturl </script>
0 Response to "Get Url And Url Parts In Javascript"
Posting Komentar