Monday, May 19, 2014

How to get the current URL in javascript?

Problem:

I am using jQuery. How do I get the path of the current URL and assign it to a variable?
Example URL:
http://localhost/menuname.de?foo=bar&number=0
Solution:
To get the path, you can use:
var pathname = window.location.pathname;
 

No comments:

Post a Comment