兼容性

IOS移动端click事件300ms的延迟相应

  • fastclick可以解决在手机上点击事件的300ms延迟
  • zepto的touch模块,tap事件也是为了解决在click的延迟问题
  • 触摸屏的相应顺序为touchstart-->touchmove-->touchend-->click,也可以通过绑定ontouchstart事件,加快事件的响应,解决300ms的延迟问题

ios的一些情况下对非可点击元素(label,span)监听click事件,iso下不会触发,css增加cursor:pointer就搞定了。

h5底部输入框被键盘遮挡问题

var oHeight = $(document).height(); //浏览器当前的高度
$(window).resize(function(){ if($(document).height() < oHeight){ $("#footer").css("position","static"); }else{ $("#footer").css("position","absolute"); } });

fixed定位缺陷

  • ios下fixed元素容易定位出错,软键盘弹出时,影响fixed元素定位
  • android下fixed表现要比iOS更好,软键盘弹出时,不会影响fixed元素定位
  • ios4下不支持position:fixed
  • 解决方案: 可用iScroll插件解决这个问题

往返缓存问题

点击浏览器的回退,有时候不会自动执行js,特别是在mobilesafari中。这与往返缓存(bfcache)有关系。

window.onunload = function(){};

日期

new Date('2022-03-22') // ios出错
new Date('2022/03/22') // ok
贡献者: mankueng