if (top.location!= self.location) {
top.location = self.location.href
}
如果某人在iFrame中拥有我的网站,则会突然爆发。
但是,我只想对某些域进行此操作。我怎么检查呢?
答案 0 :(得分:1)
您可以使用其他条件......
var allowedDomains = ["stackoverflow.com"];
if (allowedDomains.indexOf(top.location.hostname) == -1
&& top.location!= self.location) {
top.location = self.location.href
}