我正在尝试使用 _GET 方法动态获取查询参数。
我的功能看起来像这样:
var baseURL = "http://example.org";
// clears the last query params
history.pushState("", document.title, baseURL);
// retrieves the value from the HTML code
var value = document.getElementById('id').value;
// URL with updated query params
var updatedURL = document.URL + "?value=" + value;
// pushing the new URL without refreshing the page.
history.pushState("", document.title, updatedURL);
// URL looks something like this "http://example.org?value=1"
但是当我尝试使用_GET['value']从 URL 检索值时,它只获取页面初始化的值并且不会动态更新,有没有什么方法可以在不刷新页面的情况下检索这个值?
森林海