我需要添加或,如果它已经存在,修改URL查询字符串的一个参数。javascript/jquery修改查询字符串参数
如果我例如要设置param
的价值newvalue
,
http://example.org/file.php
应导致http://example.org/file.php?param=newvalue
http://example.org/file.php?abc=def
应导致http://example.org/file.php?abc=def¶m=newvalue
http://example.org/file.php?param=oldValue
应导致http://example.org/file.php?param=newvalue
我知道关于URI.js库,但它'最小的21kb大小(非gziped)对我来说太大了。
我正在寻找一个小型库来修改url-query-strings或一小段代码,它为我做到了这一点。
如果你只是做它对于一个特定的参数,只需使用字符串操作或正则表达式。 –
我在想,当file.php完成加载后,调用一个ajax调用file.php?... blabla ...&param = new value,但它会循环,除非您检查$ _GET param = newvalue。 ..我不知道如何快速编写这个想法 –
你需要改变url的外观或者真正的重新指引和重新运行脚本吗? –