Get current URL with jQuery?

后端 未结 30 2281
你的背包
你的背包 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:28

    You can log window.location and see all the options, for just the URL use:

    window.location.origin
    

    for the whole path use:

    window.location.href
    

    there's also location.__

    .host
    .hostname
    .protocol
    .pathname
    

提交回复
热议问题