Get current URL with jQuery
The current Website URL displays a full page URL.
You can also redirect the current page URL to other addresses with the properties of
Methods to get different Website Domain components of the URL
how to get host in jQuery?
window.location.host #returns host
how to get hostname in jQuery?
window.location.hostname #returns hostname
window.location.path #return path
How to get Full current URL?
window.location.href #returns full current url
how to get port in jQuery?
window.location.port #returns the port
how to get protocol in jQuery?
window.location.protocol #returns the protocol
i take a sample my best Website URL URL to step by step understand the full components of a URL. The current active URL comprises the bellow some useful components.
Example URL : http://www.pakainfo.com:8082/index.php#tab2?foo=789
host www. pakainfo .com:8082
hostname www. pakainfo .com
href http://www. pakainfo .com:8082/index.php#tab2
how to get host in jQuery
For getting the current website URL you can use attr() method or window.location.
I hope you get an idea about get current url jquery.
I would like to have feedback on my infinityknow.com blog.
Your valuable feedback, question, or comments about this article are always welcome.
If you enjoyed and liked this post, don’t forget to share.