javascript 重写alert后如何找回来

//重写alert
window.alert = function(){};

//调用找回alert
function getAlert(){
  var f = document.createElement("iframe");
  f.style.cssText = "border:0;width:0;height:0;display:none";
  document.body.appendChild(f);
  var d = f.contentWindow.document;
  d.write("<script type=\"text/javascript\">window.parent.alert = alert;<\/script>");
  d.close();
}
posted @ 2016-06-13 11:56  kamifun  阅读(409)  评论(0编辑  收藏  举报