【发布时间】:2014-03-07 00:06:00
【问题描述】:
我正在使用实时编辑器并使用HTML5 localstorage 将一些重要数据存储在我的Main Page 上,
我的Main Page 上有一个Iframe,它在同一个域上工作,用于显示编辑器的结果,这里的问题是,每当我编写 JS 代码时:
喜欢:
localStorage.clear();
到我的编辑器并在我的 iframe 上运行它,然后它也会清除我的 localStorage 主页。
我如何纠正这个问题?
我正在使用字符串将我的代码发送到iframe,
iframe.contentWindow.document.head.appendChild(Script);
Script 包含一个带有User Code 的script tag,它只会在iframe 中运行!
但是为什么我的localStorage.clear(); 还有clear 存储的主页数据?
答案将非常感谢!
【问题讨论】:
标签: javascript html iframe local-storage