Get current url in jquery

get host name,page url, port number,hash with javascript.

write in console window.location

URL: http://localhost:1723/home.html

get host name in javascript

window.location.host

ex. localhost:1723

get current page url in javascript

window.location.href

ex. http://localhost:1723/home.html

get current page url relative path in javascript

window.location.pathname

ex. /home.html

get port number form url in javascript

window.location.port

ex. 1723

get protocol form url in javascript

window.location.protocol

ex. http

get hash string from url in javascript
URL: http://localhost:1723/home.html#top

window.location.hash

ex. #top

Get host name using jquery


Get current url in jquery Get current url in jquery Reviewed by Bhaumik Patel on 7:51 PM Rating: 5