防止網頁被嵌入框架的代碼

try{

  top.location.hostname; //Chrome不報錯

  if (top.location.hostname != window.location.hostname) {

    top.location.href =window.location.href; //其他瀏覽器有異常

  }}

catch(e){

  top.location.href = window.location.href;

}

ref:http://www.ruanyifeng.com/blog/2010/08/anti-frameset_javascript_codes_continued.html

 

if (self!=top){ window.top.location.replace(self.location); //打開自己網站的頁面 }

ref:https://blog.csdn.net/shaerdong/article/details/53208511

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章