重写浏览器alert解决ios端原生alert出现当前网址的URL

window.alert = function(name){
   var iframe = document.createElement("IFRAME");
  iframe.style.display="none";
  iframe.setAttribute("src", 'data:text/plain,');
  document.documentElement.appendChild(iframe);
  window.frames[0].window.alert(name);
  iframe.parentNode.removeChild(iframe);
}

posted @ 2017-05-25 17:03  崔凯通  阅读(1180)  评论(0编辑  收藏  举报