gpt4 book ai didi

Javascript - 在页面加载时运行 PushState 脚本

转载 作者:行者123 更新时间:2023-12-03 03:08:24 25 4
gpt4 key购买 nike

我尝试在页面加载时运行以下脚本,以便将查询字符串值推送到页面加载时,但不确定如何组合这两个参数。

window.history.pushState('{ }','','?semester=March');
return false;

window.onload = window.history.pushState('{ }','','?semester=March');
return false;

最佳答案

您当前正在将执行 pushState() 函数的结果(未定义)分配给 window.onload。但是您必须为其分配一个回调函数,该回调函数将在 onload 事件触发时触发。

window.onload = function() {
window.history.pushState('{ }','','?semester=March');
}

关于Javascript - 在页面加载时运行 PushState 脚本,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47060386/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com