kiinlam
11/25/2014 - 4:01 AM

防止网页被嵌入框架的代码

防止网页被嵌入框架的代码

/*
 * 作者: 阮一峰 http://www.ruanyifeng.com/
 * http://www.ruanyifeng.com/blog/2010/08/anti-frameset_javascript_codes_continued.html
 */
try{
  top.location.hostname;
  if (top.location.hostname != window.location.hostname) {
    top.location.href =window.location.href;
  }
}
catch(e){
  top.location.href = window.location.href;
}