How to set “default” value for history.pushState a

2019-02-28 08:11发布

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:

enter image description here

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

enter image description here

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.)

1条回答
地球回转人心会变
2楼-- · 2019-02-28 08:48

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;
查看更多
登录 后发表回答