最近些前端,发现alert在安卓中正常显示,ios中会弹出ip。如下图。
然后重写了alert方法后。终于烦人的ip消失了!
下面是重写方法。非常简单。直接用即可!
//重写alert
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);
}