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

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;

}

原文地址:https://www.cnblogs.com/zhoudawei/p/7514077.html