我正在使用 jQuery。如何获取当前 URL 的路径并将其分配给变量?
示例网址:
http://localhost/menuname.de?foo=bar&number=0
最佳答案
要获取路径,可以使用:
var pathname = window.location.pathname; // Returns path only (/path/example.html)
var url = window.location.href; // Returns full URL (https://example.com/path/example.html)
var origin = window.location.origin; // Returns base URL (https://example.com)
关于javascript - 使用 jQuery 获取当前 URL?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/406192/