简体   繁体   English

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

[英]how to embed a web page that has anti-embed javascript code?

I want to embed a web page into my own html with 'iframe'.我想用“iframe”将 web 页面嵌入到我自己的 html 中。 But I find that some web pages dont want themselves to be embeded.但是我发现有些 web 页面不希望自己被嵌入。 They have some anti-embed javascript code such as:他们有一些反嵌入 javascript 代码,例如:

if(top !== self)

{

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

}

how to embed these pages in my own html?如何将这些页面嵌入到我自己的 html 中?

I try to change "top" to the iframe window in my html.我尝试在我的 html 中将“顶部”更改为 iframe window。

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?谁能帮我?

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.可能您可以尝试使用代理来获取内容并禁用使用代理获得的 HTML 代码中的脚本。 and display in your iframe.并显示在您的 iframe 中。 But it is not advisable.但这是不可取的。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM