Get current URL with jQuery?

后端 未结 30 2237
你的背包
你的背包 2020-11-22 02:44

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&nu         


        
30条回答
  •  别跟我提以往
    2020-11-22 03:13

    You can simply get your path using js itself, window.location or location will give you the object of current URL

    console.log("Origin - ",location.origin);
    console.log("Entire URL - ",location.href);
    console.log("Path Beyond URL - ",location.pathname);

提交回复
热议问题