5

How to get current url Jquery vanilla Javascript

 2 years ago
source link: https://codepedia.info/get-current-url-jquery-vanilla-javascript
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.

How to get current url Jquery vanilla Javascript

Satinder Singh / January 09, 2021 / 0 Comments

JavasSript get current url: Get current web page URL in jQuery and javascript. This is most common think while developing websites where we need to fetch page URL for performing further function i.e get pathname, hostname, query string etc.

Example:

My page URL is  http://localhost:2239/Default2.aspx?id=5&name=SatinderSingh

var getCurrentURL =window.location.href; //http://localhost:2239/Default2.aspx?id=5&name=SatinderSingh
var getHostname=window.location.hostname; //localhost
var getPathName=window.location.pathname  // Default2.aspx
var getPortNo=window.location.port        // 2239
var getQueryString=window.location.search //?id=5&name=SatinderSingh 

Thank you for reading, pls keep visiting this blog and share this in your network. Also, I would love to hear your opinions down in the comments.

PS: If you found this content valuable and want to do a favor, then Buy me a coffee


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK