如何嵌入具有反嵌入javascript代码的网页?
我想使用“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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
从技术上讲,这是不可能直接实现的。
也许您可以尝试使用代理来获取内容并禁用使用代理获取的 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.