解决IOSwebview加载H5页面频繁点击会上移

在IOSwebview 我们嵌入H5页面的开发的时候, 在H5的空白页面双击2次页面会上移动

(function()
 
{
 
var agent = navigator.userAgent.toLowerCase();
 
var iLastTouch = null; //缓存上一次tap的时间
 
if (agent.indexOf('iphone') >= 0 || agent.indexOf('ipad') >= 0) //检测是否是ios
 
{
 
document.body.addEventListener('touchend', function(event)
 
{
 
var iNow = new Date().getTime();
 
iLastTouch = iLastTouch || iNow + 1 /** 第一次时将iLastTouch设为当前时间+1 */ ;
 
var delta = iNow - iLastTouch;
 
if (delta < 500 && delta > 0)
 
{
 
event.preventDefault();
 
return false;
 
}
 
iLastTouch = iNow;
 
}, false);
 
}
 
})();

转载:https://blog.csdn.net/cy_baicai/article/details/79172483

猜你喜欢

转载自blog.csdn.net/u010881899/article/details/82259847