是否可以使用js防止iframe内容转移到主页面? [英] is it possible to prevent iframe content from escaping into main page using js?
本文介绍了是否可以使用js防止iframe内容转移到主页面?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
通常由以下代码完成:
if ( window.parent.frames.length>0 ) {} // check how many frames, if none do nothing
else {
window.location="[new destination]"; // else change the current location
}
但我想阻止iframe内容知道它在iframe上。
我正在编写一个php代理,内容将来自同一个域,我知道我可以选择使用服务器端代码逐个删除转义代码的实例,但也许可以选择在js中执行此操作。
But I want to prevent iframe content from knowing that it is on the iframe. I am writing a php proxy and content will be from the same domain and I know that I have an option to remove instances of escaping code one by one using server side code but maybe is there an option to do it in js.
推荐答案
这个问题甚至还有自己的维基百科页面 http://en.wikipedia.org/wiki/Framekiller
The problem even has it's own wikipedia page http://en.wikipedia.org/wiki/Framekiller
这篇关于是否可以使用js防止iframe内容转移到主页面?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文