How to get current URL in jQuery?

Today, We want to share with you get current url jquery.In this post we will show you i can also get current domain, hostname, pathname, protocol, port, hash and other components of thefull page URL., hear for how to get the current URL of the page in JavaScript or JQUERY. we will give you demo and example for implement.In this post, we will learn about javascript get current url with an example.

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 window.location object.

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

hash #tab2

search ?foo=789

Usage :

port 8082

protocol http:

pathname index.php

how to get host in jQuery

Example 1:
For getting the current website URL you can use attr() method or window.location.



url - how to get host in jQuery
   
   


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.

Leave a Comment