在工作中遇到,ios系统,在输入完成后,弹出提示信息时,键盘没有弹下去,造成不好的用户体验。我的解决方案是,重写alert方法
JS 代码:
window.alert=function(){
var shield = document.createElement("DIV");
shield.setAttribute("class","alert_dialog");
var strHtml="";
strHtml+='<div class="alert_dialog_con">';
strHtml+='<p>'+str+'</p>';
strHtml+='<button class="alert_dialog_btn" onclick="doOk();">确认</button>';
strHtml+='</div>';
shield.innerHTML = strHtml;
document.body.appendChild(shield);
this.doOk = function(){
shield.parentNode.removeChild(shield);
}
}
css 代码:
.alert_dialog {
19rem;
position: fixed;
top: 0;
left: 0;
bottom: 0;
right: 0;
background: rgba(0, 0, 0, 0.6);
z-index: 1999;
display: block;
transition: .6s all ease;
overflow-y: auto;
}
.alert_dialog_con {
72%;
margin: 10rem auto 0;
background: #ffffff;
padding: 1rem;
text-align: center;
border-radius: 5px;
}
.alert_dialog_con p{
margin-top: 1rem;
line-height: 24px;
font-size: 0.8rem;
}
.alert_dialog_btn {
5rem;
height: 2rem;
margin-top: 2rem;
font-family: "微软雅黑";
border-radius: 5px;
margin-bottom: 1rem;
}