我只是想知道这是否有效,我尝试使用以下脚本,如果它们不在域上,它确实可以重定向iframe,但是它不允许其他域,weeder和stumbleupon访问内容。
window.onload = function(){
try
{
if (window.parent
&& !(window.parent.location.hostname === "sitename.com"
|| window.parent.location.hostname === "weeder.org"
|| window.parent.location.hostname === "stumbleupon.com"
|| window.parent.location.hostname === "localhost")){
throw new Error();
}
}
catch (e){
window.location.href = "http://redirecttothis.com";
}
}
如果我们试图阻止iframe滥用者,那将会很有效。
答案 0 :(得分:0)