一些随机购买了一个.com域名和我自己的.net。他已经在网站上发布了一个链接到我的网站的iframe,如果他已经发布了“这个网站正在出售”的顶部,我需要阻止这种情况发生。是否可以使用PHP或javascript来阻止该特定站点访问我的站点,或者将其iframe重定向到其他地方。
发布于 2015-12-01 15:15:10
这很简单:假设他这样使用你的文件
a.html
<html>
<body>
<iframe src="sample.html"/>
</html>只需将以下行添加到已有的on Document load函数中:
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
}
};https://stackoverflow.com/questions/34014085
复制相似问题