好的,我在页面上使用 iframe。 iframe 中的内容我无法控制,并且正在与 Adobe Flash 程序一起使用。
但是一旦表单在 iframe 中被提交(同样我无法控制),它会加载一个页面,我确实有控制权,但该页面在 IFRAME 中而不是在 iframe 上中断那个页面。如何仅在该页面上跳出 iframe?
我假设需要一些 Javascript,但这段代码并不好:
if (top.location != self.location) {
top.location = self.location;
}
使用此代码加载站点的主索引页面。我需要它在提交表单后加载页面并退出它。同样,在 iframe 中提交表单后,我可以访问在 iframe 中加载的页面。
请帮帮我。
也许涉及一种棘手的方法?例如,在加载页面时?或者以某种方式检查 iframe 是否已提交?我控制我网站上的两个页面(最初包含 iframe 的页面和 iframe 提交到的页面),而不是 iframe 内容。
谢谢:)
最佳答案
我相信你想要这个
if(this != top){
top.location.href = this.location.href;
}
爆发
它可能还需要文档引用...我不在电脑前检查。
if(this != top){
top.document.location.href = this.document.location.href;
}
关于javascript - iframe中内容提交后需要跳出iframe,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6158903/