使用javascript从其他HTML页面禁用javascript和meta标记

使用javascript从其他HTML页面禁用javascript和meta标记,javascript,html,Javascript,Html,我在一台服务器上有一个HTML文件,在不同的服务器上有两个文件,如下所示: a.html-服务器1 <html><head></head><body><iframe src="http://server2/b.html"></iframe></body></html> b.html-服务器2 <script type="text/javascript">/* <![CDATA[

我在一台服务器上有一个HTML文件,在不同的服务器上有两个文件,如下所示:

a.html-服务器1

<html><head></head><body><iframe src="http://server2/b.html"></iframe></body></html>

b.html-服务器2

<script type="text/javascript">/* <![CDATA[ */if (top == self ||  parent != top ||  document.location.hostname != document.domain) {  top.location.replace("c.html");}/* ]]> */</script>
<!DOCTYPE html><html lang="en" id="myworld" class="no_js"> 
<head><meta charset="utf-8" />
<script type="text/javascript">/* <![CDATA[ */if (top == self ||  parent != top ||  document.location.hostname != document.domain) {  top.location.replace("c.html");}/* ]]> */</script><noscript> <meta http-equiv="refresh" content="0; URL=b.html?st=1" /> </noscript>
</head><body>text is here</body></html>
<html><head></head><body>Please visit later.</body></html>
/**/
/*  */  
文本在这里
c.html-服务器2

<script type="text/javascript">/* <![CDATA[ */if (top == self ||  parent != top ||  document.location.hostname != document.domain) {  top.location.replace("c.html");}/* ]]> */</script>
<!DOCTYPE html><html lang="en" id="myworld" class="no_js"> 
<head><meta charset="utf-8" />
<script type="text/javascript">/* <![CDATA[ */if (top == self ||  parent != top ||  document.location.hostname != document.domain) {  top.location.replace("c.html");}/* ]]> */</script><noscript> <meta http-equiv="refresh" content="0; URL=b.html?st=1" /> </noscript>
</head><body>text is here</body></html>
<html><head></head><body>Please visit later.</body></html>
请稍后访问。
当我打开
http://server1/a.html
,我被重定向到
http://website2/c.html
,因为如果主机不同,它会使用JavaScript和元标记进行重定向

我想做的是:我根本不希望
b.html
运行它的JavaScript来重定向和将meta标记刷新到
c.html


如何使用code
a.html
仅在iframe中呈现
b.html
?因此,它应该禁用
b.html
的javascript和meta标记。

听起来服务器2是第三方所有的,您无法控制它。不幸的是,您看到的javascript中有一个“frame breakout”脚本,它是专门为防止页面嵌入iframe而设计的,正如您所尝试的那样

一种方法是直接从web服务器发出HTTP请求来加载页面
b
,然后去掉javascript并将其作为页面的一部分


编辑:你真的应该征求其他网站的许可,因为如果你这样做,你基本上是在重新发布他们的内容。

是的,没错,但我有一个问题要问你;如果我可以在服务器2中加载a代码,我如何剥离?我不能触摸b.html和c.html文件,但我只想使用a.html。你不能从Javascript中进行操作-你必须在自己的web服务器上下载页面
b
,这样才能工作。您需要在自己的服务器上运行一些服务器端代码(例如Python、ASP.NET)。很高兴它能工作。如果你觉得我回答了你的问题,请点击大勾:)这个问题可能会帮助你:有趣的黑客行为,但是:我真的不确定我们是否应该建议人们如何禁用框架破坏代码。即使撇开道德问题不谈,如果破坏框架的代码被更新,他们的网站也会突然崩溃。