2015-05-20 31 views
2

的Javascript框架殺手我使用的代碼中使用我的網頁殺框架:有例外

if(self == top) { 
     document.documentElement.style.display = 'block'; 
    } else { 
      top.location = self.location; 
    }; 

但我想補充一些例外的一個域名並添加另一個條件:

​​

但它不會工作。腳本殺死每個幀,甚至從www.linuxportal.pl。如何使腳本殺死每一幀,但只留在www.linuxportal.pl框架?

+0

問題應該不是你的'if'條件是'window.top.location.host!== '...''? – techfoobar

+0

不,它不會工作。在Chrome控制檯中,我收到了「Uncaught SecurityError」。 – QkiZ

+1

Ahh跨域,當然它不會工作。 – techfoobar

回答

0

我解決我的document.referrer

if(self == top) { 
     document.documentElement.style.display = 'block'; 
    } 
else { 
    if (document.referrer.indexOf("www.linuxportal.pl") >= 0) { 
     document.documentElement.style.display = 'block'; 
    } 
    else { 
     top.location = self.location; 
    } 
};