如何嵌入具有反嵌入javascript代码的网页?

发布于 2024-11-25 07:32:53 字数 418 浏览 0 评论 0原文

我想使用“iframe”将网页嵌入到我自己的 html 中。 但我发现有些网页不希望自己被嵌入。他们有一些反嵌入的javascript代码,例如:

if(top !== self)

{

top.location.href = self.location.href;

}

如何将这些页面嵌入到我自己的html中?

我尝试将 html 中的“top”更改为 iframe 窗口。

var ifr = document.frames ? document.frames("ifr_1") : 
document.getElementById("ifr_1").contentWindow;
window.top = ifr;

但没有成功。

谁能帮助我吗?

I want to embed a web page into my own html with 'iframe'.
But I find that some web pages dont want themselves to be embeded. They have some anti-embed javascript code such as:

if(top !== self)

{

top.location.href = self.location.href;

}

how to embed these pages in my own html?

I try to change "top" to the iframe window in my html.

var ifr = document.frames ? document.frames("ifr_1") : 
document.getElementById("ifr_1").contentWindow;
window.top = ifr;

but it didn't work.

can anyone help me?

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

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

发布评论

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

评论(1

爱的那么颓废 2024-12-02 07:32:53

从技术上讲,这是不可能直接实现的。

也许您可以尝试使用代理来获取内容并禁用使用代理获取的 HTML 代码中的脚本。并显示在您的 iframe 中。但这是不可取的。

Technically it is not possible directly possible.

May be you could try using proxy to fetch the content and disable the script in the HTML code obtained using proxy. and display in your iframe. But it is not advisable.

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