javascript 重写alert后如何找回来

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

//调用找回alert
function getAlert(){
  var f = document.createElement("iframe");
  f.style.cssText = "border:0;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();
}
刚入坑,强势崛起ing!
原文地址:https://www.cnblogs.com/victfx/p/5580176.html