Get path and query string from URL using javascript

后端 未结 5 1268
失恋的感觉
失恋的感觉 2020-12-08 06:08

I have this:

http://127.0.0.1:8000/found-locations/?state=--&km=km

I want this:

found-locations/?state=--&km=km
<         


        
5条回答
  •  暖寄归人
    2020-12-08 06:32

    Use location.pathname and location.search:

    (location.pathname+location.search).substr(1)
    

提交回复
热议问题