window.alert()在webkit内核浏览器中出现带有ip等信息解决办法
暂时没有发现更好的办法,so,我重写了alert方法(要引入jquery.js)
/* * 由于系统自带alert在webkit内核浏览器中会带有ip等信息,影响体验度,所以在此重写了一个alert方法 * * */ window.alert = function(txt){ var shield = document.createElement("DIV"); shield.id = "shield"; shield.style.display = "none"; shield.style.position = "absolute"; shield.style.left = "0px"; shield.style.top = "0px"; shield.style.bottom = "0px"; shield.style.right = "0px"; shield.style.backgroundColor = "rgba(0,0,0,0.3)"; shield.style.textAlign = "center"; shield.style.zIndex = "800"; var alertFram = document.createElement("DIV"); alertFram.id="alertFram"; alertFram.style.margin = "0 auto"; alertFram.style.marginTop = "140px"; alertFram.style.width = "280px"; alertFram.style.height = "120px"; alertFram.style.backgroundCorlor = "white"; alertFram.style.textAlign = "center"; alertFram.style.lineHeight = "150px"; alertFram.style.borderRadius = "5px"; alertFram.style.boxShadow = "1px 1px 3px #909090"; strHtml = "<ul style=\"list-style:none;margin:0px;padding:0px;width:100%;color:black;border-radius:5px;overflow: hidden;\">\n"; strHtml += " <li style=\"background:#fff;text-align:center;font-size:14px;font-weight:bold;height:80px;line-height:80px;border-bottom:1px solid #ccc;\">"+txt+"</li>\n"; strHtml += " <li style=\"background:#fff;text-align:center;font-weight:bold;height:40px;line-height:40px; border-radius: 0px 0px 5px 5px;\" id='ok'>ok</li>\n"; strHtml += "</ul>\n"; alertFram.innerHTML = strHtml; shield.appendChild(alertFram); document.body.appendChild(shield); $("#shield").fadeIn(); var ok = function(){ $("#shield").fadeOut(); } var oOk = $("#ok"); if(LI_isPC()){ oOk.mousedown(function(){ dragging = false; oOk.css("backgroundColor","blue"); }); oOk.mousemove(function(){ oOk.css("backgroundColor","white"); }); oOk.mouseup(function(){ if(dragging) return; else{ oOk.css("backgroundColor","white"); ok(); event.stopPropagation(); } }); }else{ oOk.on("touchstart",function(){ dragging = false; oOk.css("backgroundColor","blue"); }); oOk.on("touchmove",function(){ dragging = true; }); oOk.on("touchend",function(){ if(dragging) return; else{ oOk.css("backgroundColor","white"); ok(); event.stopPropagation(); } }); } document.body.onselectstart = function(){return false;} }