如何为history.pushState和replaceState设置“默认”值?

2023-12-09

对于使用的浏览器titleparam,我们应该使用什么值来告诉浏览器使用其默认值?

In Safari 5.1.7 (7534.57.2), if I put null or undefined as the title param, it uses the browser default:

enter image description here

However, Opera 12.16 uses the string "null" and "undefined" respectively:

enter image description here

什么应该是“正确”的行为?

在 Opera 上,我们如何设置为“默认”"null" and "undefined"不起作用?

(MDN's History docs似乎没有太多关于允许值的信息History.pushState/replaceState的参数。)


不确定是否有特定的方法将其设置为默认标题,但在所有浏览器中都应该有效的安全方法是将标题设置为location.href

document.title = location.href;
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

如何为history.pushState和replaceState设置“默认”值? 的相关文章