防止网页被嵌套

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/zhpblog/p/7103090.html