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
转载于:https://stackoverflow.com/questions/406192/get-current-url-with-jquery
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
转载于:https://stackoverflow.com/questions/406192/get-current-url-with-jquery
To get the path, you can use:
var pathname = window.location.pathname; // Returns path only
var url = window.location.href; // Returns full URL
var origin = window.location.origin; // Returns base URL