1、用下面这一行代码替代alert方法:window.alert = function() {};
2、在function(){} 里创建一个div作为alert出来的内容。如下:window.alert = function(txt) { var div = document.createElement("DIV");}
3、给这个alert出来的DIV设置样式,颜色、宽、高、对齐、位置等等:window.alert = function(txt) { var div = document.createElement("DIV"); shield.style.position = "absolute"; shield.style.background = "#333"; shield.style.textAlign = "center"; shield.style.zIndex = "9999999";}
4、设置完成之后,在页面中调用alert,效果如下: