重定向iframes没有不同的url

重定向iframes没有不同的url,iframe,external,Iframe,External,一些random公司购买了一个.com域名,我拥有.net。他在网站上发布了一个iframe链接到我的网站,如果他发布了“这个网站正在出售”,我需要阻止这种情况发生。是否可以使用PHP或javascript阻止特定站点访问我的站点,或将其iframe重定向到其他地方。这很简单: 说他这样用你的档案 a、 html <html> <body> <iframe src="sample.html"/> </html> windo

一些random公司购买了一个.com域名,我拥有.net。他在网站上发布了一个iframe链接到我的网站,如果他发布了“这个网站正在出售”,我需要阻止这种情况发生。是否可以使用PHP或javascript阻止特定站点访问我的站点,或将其iframe重定向到其他地方。

这很简单: 说他这样用你的档案

a、 html

<html>
    <body>
        <iframe src="sample.html"/>
</html>
window.onload = function(e) {
    if ( window.self !== window.top ) {
    //Your site is in i frame
    //just redirect to his own site if you feel like there will be an endless recursion so nothing will load probably.
    //You can put your custom action if this is not what you want
        window.self.location = "a.html"
    //would be pretty good enough :D
    }
};