简体   繁体   English

阻止iframe重新加载父窗口

[英]Prevent iframe from reloading the parent window

Is it possible to prevent an iframe from reloading the parent window? 是否可以阻止iframe重新加载父窗口?

The sandbox attribute without allow-top-navigation prevents redirection but doesn't prevent reloading. 没有allow-top-navigationsandbox属性会阻止重定向,但不会阻止重新加载。

PS: I need the sandbox to allow both allow-scripts and allow-same-origin . PS:我需要沙箱允许allow-scriptsallow-same-origin

See the findings here, it was a question asked previously. 看到这里的发现,这是一个先前提出的问题。 It experiments with stopping the page reload using preventDefault() 它试验使用preventDefault()停止页面重新加载

$(window).bind({
    beforeunload: function(ev) {
        ev.preventDefault();
    },
    unload: function(ev) {
        ev.preventDefault();
    }
});

Original Answer 原始答案

Prevent refreshing / reloading a page with JavaScript 使用JavaScript阻止刷新/重新加载页面

Note: This can be done using Javascript also with a bit more work. 注意:这可以使用Javascript完成,还可以完成更多工作。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM