脚本化 iFrame 在当前页面而不是 iFrame 内加载内容

发布于 2024-08-27 08:12:51 字数 381 浏览 4 评论 0原文

我试图将网页加载到 iFrame 中,同时将内容栏保留在顶部,但对于我尝试加载到 iFrame 中的某些页面,内容会加载,就像我导航到该页面一样。

我使用以下代码动态加载 iframe:

$('#my_iFrame').attr("src","http://www.nytimes.com/2010/03/26/opinion/26ryan.html");

看起来这些页面上有一个脚本,用于检查它是否正在加载到 iframe 中,如果是,则将 document.location 更改为其自己的 url。

有什么方法可以绕过这样的黑客攻击,以便我可以将该网站加载到 iFrame 中吗?也许有某种方法可以保护 window.location 的值?

I'm trying to load a webpage into an iFrame while keeping a content bar on top, but for some pages that I try to load into the iFrame the contents is loaded as if I navigated to that page.

I use the following code to dynamically load an iframe:

$('#my_iFrame').attr("src","http://www.nytimes.com/2010/03/26/opinion/26ryan.html");

It looks like there is a script on these pages that checks to see if it is being loaded into an iframe and changes the document.location to it's own url if so.

Is there any way around a hack like this so that I can load that site into an iFrame? Maybe some way to protect the value of window.location?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

再浓的妆也掩不了殇 2024-09-03 08:12:51

通过谷歌搜索,我发现了这一点:

<script>
function StopLoading()
{
if (!document.all)
{
window.stop();
}
else
{
window.document.execCommand('Stop');
}
}
</script>

<iframe onload="StopLoading()" src="http://www.someaddress.com">

但是,如果它位于不同的域中,它似乎不起作用。
您可以尝试在同一域和不同域上的页面吗?

来源:http://www.steadyhealth.com/Web_Hosting_Anti_Frame_Breaker_solution_t53346.html

By Googling, I found this:

<script>
function StopLoading()
{
if (!document.all)
{
window.stop();
}
else
{
window.document.execCommand('Stop');
}
}
</script>

<iframe onload="StopLoading()" src="http://www.someaddress.com">

However, it seems it does not work if it is in a different domain.
can you try it for a page on same domain and a different domain?

source: http://www.steadyhealth.com/Web_Hosting_Anti_Frame_Breaker_solution_t53346.html

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文