2013-10-02 51 views
0

我怎樣才能讓我的網站框在:http://myDomain.com;和我的網站有不同的網址;所以按域名過濾Iframe;

<meta http-equiv="X-Frame-Options" content="sameorigin"> 

不工作,

<meta http-equiv="X-Frame-Options" content="ALLOW-FROM http://myDomain.com"> 

並不被所有的瀏覽器都支持; 感謝您的幫助;

+0

您需要將它作爲標題添加到腳本語言或Web服務器級別。你使用哪種技術堆棧? – SilverlightFox

回答

0

你可以做到這一點,但你將不得不寫一些腳本。

標準framebreaker腳本是這樣的:

if(top != self) { 
    top.location.href = self.location.href; 
} 

您可以定製這個味,就像這樣:

if (top != self) { 
    if (top.location.toLower().indexOf("http://mydomain.com/") != 0) { 
     top.location.href = "http://mydomain.com/error.html"; 
    } 
}