article

Friday, July 29, 2016

Get URL and URL Parts in JavaScript

Get URL and URL Parts in JavaScript

http://tutorial101.blogspot.com/get-url-and-url-parts-in-javaScript

window.location.protocol = "http:"
window.location.host = "tutorial101.blogspot.com"
window.location.pathname = "get-url-and-url-parts-in-javaScript"

full URL path in JavaScript:
var newURL = window.location.protocol + "//" + window.location.host + "/" + window.location.pathname;

get the get url parts
var pathArray = window.location.pathname.split( '/' );
var geturlparts = pathArray[2];
alert(geturlparts);

Related Post