对于使用 title param的浏览器,我们应该使用什么值来告诉浏览器使用其默认值?
在Safari 5.1.7(7534.57.2) 中,如果我将 null c> $ 作为 title param,它使用浏览器默认值:
img src =i.stack.imgur/dFnjh.pngalt =enter image description here>
但是,Opera 12.16 分别使用字符串null和undefined
>
$在Opera上,我们如何设置为defaultif null和undefined无效?
( MDN的历史 docs 似乎没有太多关于 History.pushState / replaceState 的允许值的信息s参数。)
解决方案不确定是否有一种将其设置为默认标题的具体方法,应该在所有浏览器中工作的标题设置为 location.href
document.title = location.href;
For browsers that use the title param, what value should we use to tell the browser to use its default?
In Safari 5.1.7 (7534.57.2), if I put null or undefined as the title param, it uses the browser default:
However, Opera 12.16 uses the string "null" and "undefined" respectively:
What's supposed to be the "correct" behavior?
On Opera, how can we set to "default" if "null" and "undefined" doesn't work?
(MDN's History docs doesn't seem to have much info regarding the allowed values for History.pushState/replaceState's parameters.)
解决方案Not sure if there is a specific way of setting it to a default title, but a safe way which should work in all browsers is setting the title to the location.href
document.title = location.href;
更多推荐
如何设置“默认” history.pushState和replaceState的值?
发布评论