Get current URL in JavaScript?

I am using jQuery. How do I get the path of the current URL and assign it to a variable?

Example URL:

Text Copied From
on : Fri, Jan 02, 2009 Views : 1725621

Accepted Answer

To get the path, you can use:

var pathname = window.location.pathname;
// Returns path only var url
   = window.location.href;

// Returns full URL 
Text Copied From
on : Fri, Jan 02, 2009

Ask Question

If you want to ask question you must LogIn or SignUp
Login SignUp

Quick Links



Total Followers
Study Group Created
Study Group Joined
Following Teacher
Following Organization
Blog Articles Added
Questions Asked
Questions Answered
Jobs Posted
Total Members in Group
Questions asked by members
Tasks added in this Group

Please wait..


Login to Open ESchool OR Create your account    Login   SignUp