1. 程式人生 > >仿冒網站風險解決方案:防止自己的網頁被別人iframe嵌入

仿冒網站風險解決方案:防止自己的網頁被別人iframe嵌入

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;
}

在頁面中加入以上JS程式碼.

參考地址:http://www.ruanyifeng.com/blog/2010/08/anti-frameset_javascript_codes_continued.html