在iFrame中打开站点,避免框架损坏

在iFrame中打开站点,避免框架损坏,iframe,popup,framebusting,Iframe,Popup,Framebusting,我正在尝试在iFrame中打开一些作为弹出窗口打开的站点。 有些站点不允许自己在iFrame中打开(框架破坏) 我已经找过了。我有一些解决办法也像 $(window).bind('beforeunload', function (event) { return 'Custom message.'; }); beforeunload对我不起作用,因为即使在我的站点中导航,它也会运行 我也试过了 // Event handler to catch executi

我正在尝试在iFrame中打开一些作为弹出窗口打开的站点。 有些站点不允许自己在iFrame中打开(框架破坏)

我已经找过了。我有一些解决办法也像

$(window).bind('beforeunload', function (event) {

        return 'Custom message.';
        });
beforeunload对我不起作用,因为即使在我的站点中导航,它也会运行

我也试过了

 // Event handler to catch execution of the busting script.
        window.onbeforeunload = function () { prevent_bust++ };

        // Continuously monitor whether busting script has fired.
        setInterval(function () {
        if (prevent_bust > 0) {  // Yes: it has fired. 
        prevent_bust -= 2;     // Avoid further action.
        // Get a 'No Content' status which keeps us on the same page.

        window.top.location.href = 'http://mysiteurl/#';
        }
        }, 1);
上面的也不起作用,它将重定向到正在iFrame中打开的url

那么,在IFrame中是否有任何开放站点(具有Frame Buster)的解决方案呢

问候,,
Sagar Joshi

对于IE,请在您的帧中使用此security=“restricted”


编辑:我有同样的问题,但我需要脚本等运行在我的框架,所以安全限制是不好的。尝试使用sandbox=“…”

  • 允许表单允许表单提交
  • 允许弹出窗口允许弹出窗口
  • 允许指针锁定允许指针锁定
  • 允许相同来源允许文档保持其来源
  • 允许脚本允许JavaScript执行,还允许自动触发功能
  • 允许顶部导航允许文档通过导航顶级窗口脱离框架
顶部导航是您想要阻止的,因此请将其忽略,否则它将不被允许。任何遗漏的内容都将被阻止


<iframe id="frame_id" name="frame_name" security="restricted" src="page.html">  
</iframe>
        <iframe sandbox="allow-same-origin allow-scripts allow-popups allow-forms" src="http://www.example.com"</iframe>