重写alert()方法显示如图效果很简单。添加掩码以防止用户操作。值得一提的是window.alert=function(name){variframe=document.createElement("IFRAME");iframe.id="iframe";iframe.style.display="无";框架。setAttribute("src",'data:text/html,');document.documentElement.appendChild(iframe);window.frames[0].window.alert(名字);iframe.parentNode.removeChild(iframe);这个应该是在iframe中再次弹出alert,使得内置浏览器使用Safari时弹出的网页提示(www.baidu.com的提示)不过,虽然这个方法取消了Android中URL的提示文字,无法在主页面显示。下图考的妹子觉得太丑了。...参考ios移动端的提示,做一个仿alert代码:window.alert=function(name){//创建一个大盒子varbox=document.createElement("div");varback=document.createElement("div");//创建一个关闭按钮back.id="backg";document.body.appendChild(返回);varbutton=document.createElement("div");//定义一个对象保存样式box.id="alertbox";//将创建的元素添加到bodydocument.body.appendChild(box);//将alert传入的内容添加到box中if(arguments[0]){box.innerHTML=arguments[0];}button.innerHTML="确定";//定义按钮样式button.id="alertbutton";//将按钮添加到盒子中box.appendChild(button);//给按钮添加点击事件button.addEventListener("click",function(){document.body.removeChild(box);document.body.removeChild(back);//每次点击需要移除子元素,否则嘿嘿嘿})};下面是我用淘宝的h5flexible布局的css代码,如果rem不对可以看一下http://www.w3cplus.com/mobile...css:#alertbox{width:60%;高度:2.2rem;背景色:rgb(248,248,248);位置:绝对;顶部:42%;左:20%;word-wrap:break-word;字体大小:16px;字体粗细:粗体;z-指数:999;文本对齐:居中;边界半径:0.3rem;line-height:1.2rem;}#alertbutton{border:1pxsolidrgb(204,204,204);背景色:rgb(255,255,255);宽度:100%;颜色:#61a7ea;高度:1rem;字体粗细:正常;中心;行高:1rem;大纲:无;位置:绝对;底部:0;右:0;border-bottom-right-radius:0.3rem;border-bottom-left-radius:0.3rem;}#backg{top:0;位置:绝对;宽度:100%;高度:100%;背景:#000000;不透明度:0.3;溢出:隐藏;}成功!当提示信息较少时,不建议直接alert某些后台返回的长JSON
