简体   繁体   English

打破iframe

[英]break out of iframe

I have an iframe that displays a flash banner ad which has clickable links. 我有一个iframe,显示一个包含可点击链接的Flash横幅广告。 Is there anyway to force the links to open in parent window, without putting JS on the page that opens or changing the flash file? 无论如何强制链接在父窗口中打开,而不将JS放在打开的页面或更改Flash文件?

For example, is there something i can do to the iFrame to force links to open in its parent? 例如,我可以对iFrame做些什么来强制链接在其父级中打开?

No, you absolutely cannot do this. 不,你绝对不能这样做。 Your ad is likely served from a domain different than the rest of the page outside of the iframe. 您的广告可能来自与iframe之外的其他网页不同的域。 The only security restriction applied to JavaScript is called same origin execution. 应用于JavaScript的唯一安全限制称为相同的原始执行。 A browser will not execute any JavaScript that originates in a domain different than that of the effect page/window. 浏览器不会执行任何源自不同于效果页面/窗口的域的JavaScript。 As a result JavaScript is not your answer. 因此,JavaScript不是您的答案。

This little snippet should do it: 这个小片段应该这样做:

   if (top.location != location) {
     top.location.href = document.location.href ;
   }

If the links were HTML, yes. 如果链接是HTML,是的。 But since the links are embedded in the SWF itself, there is no way to change their targt, AFAIK. 但由于链接嵌入在SWF本身,因此没有办法改变它们的targt,AFAIK。

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

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