What is the easiest way to read/manipulate query string params using javascript?

后端 未结 7 1895
余生分开走
余生分开走 2020-12-05 11:45

The examples I\'ve seen online seem much more complex than I expected (manually parsing &/?/= into pairs, using regular expressions, etc). We\'re using asp.net

7条回答
  •  旧时难觅i
    2020-12-05 12:09

    If there's any possibility of encountering repeated parameters (e.g. ?tag=foo&tag=bar), most libraries out there won't be sufficient. In that case, you might want to consider this library that I developed from Jan Wolter's very comprehensive parser. I added .plus() and .minus() functions and roundtripping:

    https://github.com/timmc/js-tools/blob/master/src/QueryString.js

提交回复
热议问题