twitter中处理网页被iframe方式

记录一下,感觉蛮有意思的

 

function bust () {
  document.write 
= "";
  window.top.location 
= window.self.location;
  setTimeout(
function() {
    document.body.innerHTML 
= '';
    }, 
0);
  window.self.onload 
= function(evt) {
    document.body.innerHTML 
= '';
  };
}
if (window.top !== window.self) { // are you trying to put self in an iframe?
  try {
    
if (window.top.location.host) { // this is illegal to access unless you share a non-spoofable document domain
      // fun times
    } else {
      bust(); 
// chrome executes this
    }
  } 
catch (ex) {
    bust(); 
// everyone executes this
  }

} 

posted @ 2011-05-21 23:43  chaoren1641  阅读(747)  评论(0编辑  收藏  举报