gpt4 book ai didi

html5-history - 页面标题不会被 history.pushState 改变

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

我刚刚在 Google Chrome 中打开了一个带有少量基本标签(如 html、body、head 等)的空白 HTML 页面,并尝试在控制台中执行以下命令:

history.pushState(null, 'my test title', '/test/url');

历史事件工作正常,但页面标题保持不变。可以吗?我应该每次都手动更改吗?如果我应该,为什么 pushState() 方法中有这样的参数,如标题?

最佳答案

似乎当前的浏览器不支持 pushState 标题属性。您可以通过在 JS 中进行设置来轻松实现相同的功能。

document.title = "This is the new page title.";

关于html5-history - 页面标题不会被 history.pushState 改变,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13955520/

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