[英]Disable the javascript and meta tag from other HTML page by using Javascript
我在一台服務器上有一個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>
c.html-服務器2
<html><head></head><body>Please visit later.</body></html>
當我打開http://server1/a.html
,我將重定向到http://website2/c.html
因為如果主機不同,它將使用JavaScript和meta標簽進行重定向。
我想要做的是:我根本不希望b.html
完全運行其JavaScript進行重定向,並且meta標簽刷新為c.html
。
如何編碼a.html
以b.html
在我的iframe中呈現b.html
? 因此,應禁用b.html
的javascript和meta標記。
聽起來服務器2是第三方擁有的,您無法控制它。 不幸的是,您可以看到Javascript中有一個“框架中斷”腳本,該腳本專門用於防止頁面在您嘗試執行時嵌入到iframe中。
一種解決方法是直接從Web服務器發出HTTP請求以加載頁面b
,然后剝離javascript並將其包含在頁面中。
編輯:您應該真正征求另一個站點的許可,因為如果這樣做,您基本上是在重新分配他們的內容。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.