This site uses cookies from Google to deliver its services, to personalize ads and to analyze traffic. Information about your use of this site is shared with Google. By using this site, you agree to its use of cookies. Learn More

Get Url And Url Parts In Javascript

Get Url And Url Parts In Javascript Web-development (jquery) Get Url And Url Parts In Javascript Get URL and URL Parts in JavaScriptGet 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

Contact

Nama

Email *

Pesan *