objBlurFun("input");
//如果不是当前触摸点不在input上,那么都失去焦点
function objBlurFun(sDom,time){
var time = time||300;
//判断是否为苹果
var isIPHONE = navigator.userAgent.toUpperCase().indexOf("IPHONE")!= -1;
if(isIPHONE){
var obj = document.querySelectorAll(sDom);
for(var i=0;i<obj.length;i++){
objBlur(obj[i],time);
}
}
}
// 元素失去焦点隐藏iphone的软键盘
function objBlur(sdom,time){
if(sdom){
sdom.addEventListener("focus", function(){
document.addEventListener("touchend", docTouchend,false);
},false); }else{
throw new Error("objBlur()没有找到元素");
}
var docTouchend = function(event){
if(event.target!= sdom){
setTimeout(function(){
sdom.blur();
document.removeEventListener('touchend', docTouchend,false);
},time);
}
}; }
05-01 00:54