gpt4 book ai didi

javascript - document.open 如何影响历史?

转载 作者:行者123 更新时间:2023-11-30 06:37:42 24 4
gpt4 key购买 nike

我无法理解参数 replace 的作用。来自文档:

Optional. If set, the history entry for the new document inherits the history entry from the document which opened this document

这是否意味着如果没有 replace,新打开的文档将连同其状态一起添加到历史记录中?这就是我打开它的方式:

var newDoc = document.open("text/html");
newDoc.write(file);
newDoc.close();

基本上我想要的是让历史记录按钮记住这些。我一直在使用 history.js,想知道这是否可以节省我一些时间。

最佳答案

您似乎在引用 w3schools ,即 not very reliable . MDN documentation page甚至没有提到那个论点,W3C specification声明 document.open 不接受任何参数(甚至不包括您作为第一个参数传递的内容类型)。因此,为 replace 传递值跨浏览器工作的希望不大。

话虽如此,我从引用的摘录中了解到的内容与您所说的完全相反:如果您传递 true,则新页面将继承 opener 文档的历史;如果你不这样做,它会启动一个新的历史线程。有道理吗?

关于javascript - document.open 如何影响历史?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13491823/

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