Force iframe to Load Full Frame

↘锁芯ラ 提交于 2019-12-09 06:10:29
Quentin

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">

On thanks.jsp you can put in the following JS:

// Parent window not the same as this one
if (self !=top) 
{
    top.location.href = self.location.href;
} 

This will work provided that you have thanks.jsp on the same server as the original page containing the frame, due to the same origin policy.

The above code checks the url of the page you're on, then the one of the page it's executing on (thanks.jsp) - if they don't match you're sent to the thanks.jsp url. This method works fine when thanks.jsp is a static page, but won't carry postdata etc across with it.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!