I am trying to extract the base of the url:
http://google.com/something --> http://google.com
http://127.0.0.1:8000/something --> http://127.0.0.1:8000
When I try and use the following:
var pathArray = window.location.pathname;
alert(pathArray);
I get pathArray = undefined. Note: using location.hostname does work here. Why is .pathname returning undefined, and how would I get the url base here? Thank you.
Update: I used var pathArray = 'http://' + window.location.
http://example.com/a/b.html,window.location.pathnamereturns/a/b.html. Why not usewindow.location?