Want a free Ebook & latest Update Subscribe Now
  [email protected]      beta

How to get current url Jquery vanilla Javascript

Overview: 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.


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


Satinder Singh

Hi all, am Founder and Author of Codepedia.info, also atypical polyglot programmer from Bombay, India. I have a passion to create, solve, and deploy software applications.
       ForEach ( minute in MyLife ) { myExperience++ ; }

2 comments on “How to get current url Jquery vanilla Javascript”

Post Comment

Your email address will not be published. Required fields are marked *