Get path and query string from URL using javascript

后端 未结 5 1277
失恋的感觉
失恋的感觉 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:31

    window.location.pathname + window.location.search
    

    Will get you the base url /found-locations plus the query string ?state=--&km=km

提交回复
热议问题