我有输入 type="text"、选择和其他用于过滤器的元素。更改其中任何一个后,我需要使用所有 url 参数刷新页面。我需要读取所有 URL 参数,处理它们并构建新的 URL 字符串以进行重定向。
在 PHP 中这很简单,就像这样:
$domain = 'index.php?';
foreach($_GET as $key => $value){
$domain .= $key.'='.$value.'&'; // there I can do changes what I need
}
$domain = substr($domain, 0, strlen($domain)-5); // $domain contents full URL with changed parameters
如何在 JavaScript 中做同样的事情?
window.history.pushState(null, '', '/index.php?test=qwe')
//then
location.reload();