【发布时间】:2017-01-12 08:17:10
【问题描述】:
我有这个页面 https://jsfiddle.net/r91bLb7r/9/,我用它来显示这个 iframe https://jsfiddle.net/r91bLb7r/8/。
父页面在本地存储中有一个值,我想从 iframe 访问它。
这是父母的代码:
$(document).ready(function () {
$( "#top" ).click(function() {
localStorage.setItem("parent", "one");
alert('I am the top page');
});
});
这是 iframe 代码:
$(document).ready(function () {
$( "#map" ).click(function() {
var mode = localStorage.getItem("parent");
alert('I am the iframe'+mode);
});
});
如何从 iframe 访问父级的本地存储值?
【问题讨论】:
标签: javascript jquery html iframe