强制iframe加载全帧 [英] Force iframe to Load Full Frame

查看:118
本文介绍了强制iframe加载全帧的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个HTML页面(称为welcome.html),其中包含一个iframe,我无法控制它(比如说app.html)。用户使用iframe中的应用程序执行一些操作,然后单击提交。一旦他们这样做,他们将被带到一个新的页面(称为thanks.jsp),该页面加载在iframe中。有一种方法,我可以强制thanks.jsp加载全帧,而不是iframe一旦提交被点击?请记住,我无法控制提交按钮或app.html背后的逻辑。不过,我确实可以控制welcome.html和thanks.jsp。如果可能的话,我想坚持使用HTML和/或JavaScript。提前感谢您。

解决方案

您可能希望使用一个基础目标,以防万一它失败。 >

第一:

如果 thanks.jsp

然后:


是通过一个post请求 - 重定向来请求的,所以它显示了该页面作为对get请求的响应。

包含framebuster JavaScript:

 < script type =text / javascript> 
if(self!= top){top.location.replace(location); }
< / script>

最后:

如果用户没有启用JavaScript,请确保它们不再留在框架中,然后他们必须:

 < base target =_ top>  


I have an HTML page (say welcome.html) which contains an iframe to a page I have no control over (say app.html). The user performs some actions using the app within the iframe and clicks submit. Once they do this, they are taken to a new page (say thanks.jsp), which loads within the iframe. Is there a way in which I can force thanks.jsp to load in the full frame and not the iframe once submit is clicked? Remember, I have no control over the logic behind that Submit button or app.html. I do however have control over welcome.html and thanks.jsp. If possible, I would like to stick with HTML and/or JavaScript. Thank you in advance.

解决方案

You probably want to use a framebuster, with a base target in case it fails.

First:

If thanks.jsp is requested via a post request - redirect so it you present the page as the response to a get request.

Then:

Include framebuster JavaScript:

<script type="text/javascript">
   if (self != top) { top.location.replace(location); }
</script>

Finally:

In case the user doesn't have JavaScript enabled, make sure they don't stay in the frame any longer then they have to:

<base target="_top">

这篇关于强制iframe加载全帧的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆