[英]HTML - difference between iframe reload and parent reload
在“ myIframe”内部:
当我重新加载iframe时,此页面内的javascript未执行:
myIframe:
alert("reloaded");
$('.selectedTab').click(function() {
document.getElementById("myIFrame").contentDocument.location.reload(true);
});
但是,如果我重新加载其父页面,则会重新加载javascript。
parent.location.reload();
这两种方法有什么区别?
是否可以在不经过父页面传递和不请求服务器的情况下重新加载iframe包含项,而仅“回放”已获取的数据?
正如Kevin B提到的那样,这似乎与内容位置有关。 确保Iframe src也与父目录来自同一域。
http://jsfiddle.net/55Ewm/-似乎对我来说很好。
<script>
window.onload = function() {
alert("reloaded");
$('.selectedTab').click(function() {
document.getElementById("myIFrame").contentDocument.location.reload(true);
});
}
</script>
<button class="selectedTab">Reload Iframe</button>
<iframe id="myIFrame" src="/" />
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.