Today, I will let you know example of get current page url. let’s discuss about path. I would like to share with you host and hash using jquery. This post will give you simple example of getting url hash location. you will do the following things for and using it in jquery.
To get the current page URL, path, host and hash using jQuery, you can use the following code:
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>How To Get Current Page URL, Path, Host and hash using jQuery? - NiceSnippets.Com</title>
var currentPageUrl = window.location.href;
// Get current page path
var currentPagePath = window.location.pathname;
// Get current page host
var currentPageHost = window.location.host;
// Get current page hash
var currentPageHash = window.location.hash;
You can then use these variables to manipulate or display the current page information as needed.