I have a URL like below :
http://localhost:1692/fa/Help.aspx#Help
the code below returns that :
alert(document.URL);
I only want to get the http://localhost:1692
part of this URL.
How can I get it with jQuery or JavaScript?
I have a URL like below :
http://localhost:1692/fa/Help.aspx#Help
the code below returns that :
alert(document.URL);
I only want to get the http://localhost:1692
part of this URL.
How can I get it with jQuery or JavaScript?
Try this:
alert( location.protocol + "//" + location.host )
location.protocol + '//' + location.host
And, if you want, you have these other properties:
hash
search
- url querystringhostname
- only the hostname (without port)port
- only the port numberpathname
- the local url