Get Current URL In JavaScript




Here we consider how to Get the Current URL In JavaScript. If you are using Jquery or JavaScript, we can do this easily. For getting the Full URL write the following code.

var CurrentUrl = window.location.href;


If you need only the path, write the following code.

var PathName = window.location.pathname;


In Jquery we can get the URl in the following method also.

var URL = $(location).attr('href');