Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/421.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/ember.js/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 如何防止iframe自身统一_Javascript_Jquery - Fatal编程技术网

Javascript 如何防止iframe自身统一

Javascript 如何防止iframe自身统一,javascript,jquery,Javascript,Jquery,我们使用iFrame展示网站的设计(征得他们的同意)。问题是,有些网站有如下脚本: if (top != self) top.location.replace(self.location.href); 这会导致浏览器“跳转”到其网站。我们如何抑制这些脚本?有办法吗 在上找到: var prevent_bust = 0; // Event handler to catch execution of the busting script. window.onbeforeunload = fun

我们使用iFrame展示网站的设计(征得他们的同意)。问题是,有些网站有如下脚本:

if (top != self) top.location.replace(self.location.href); 
这会导致浏览器“跳转”到其网站。我们如何抑制这些脚本?有办法吗

上找到:

var prevent_bust = 0;

// 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 = 'http://server-which-responds-with-204.example.com/';
  }
}, 1);
这似乎是最可靠的方法,但你必须使用它,看看你的情况是否适合,然后在这里报告。祝你好运


PS-如果你想做更多的研究,该页面上还有其他内容。

相关的(可能会有答案,请参阅“事实证明,你的框架破坏代码可以被破坏…”),称为框架破坏程序。据说有一些能破镜重圆的东西。请看:(但是,我想问,如果你得到了网站的同意,那么他们为什么要使用frame Buster?@Pekka웃 - 原来还有一个叫汤姆的-