点透/触屏事件/js兼容性代码

1.触屏事件

2.cookie 本地存储

3.jsonp

1.hammer.js

2.swiper.js

js兼容性代码

事件对象 e || window.event

事件目标 e.target || e.srcElement

给元素添加滚轮事件

element.mousewheel = fn;

element.addEventListener && element.addEventListener("DOMMouseScroll", fn, false)

页面的滚动条

document.body.scrollTop || document.documentElement.scrollTop

获取非行间样式

window.getComputedStyle(element)

element.currentStyle

绑定事件

ele.addEventListener

ele.attachEvent

...

1.触屏事件

touchstart/touchmove/touchend/touchcanclee.touch 

触屏点的数组touchstart/touchmove 

事件可使用 e.touchtouchend 事件不能使用e.touches,而使用e.changedTouches

2.点透现象(移动端开发的一些坑)

移动端 touchstart click 移动端有延迟300ms,原因:浏览器要判断用户是否有进一步的操作[双击]

touchstartDOMContentLoaded 结构节点渲染完毕触发load 等待所有的资源[img/js/audio/vedio]加载完成才触发

解决点透现象的方案:

使用fastclickdocument.addEventListener && document.addEventListener("DOMContentLoaded",function(){FastClick.attach(document.body);},false)

3.弹窗里面包含表单弹窗中的虚拟键盘使用fixed 定位,相对浏览器窗口,有输入框的时候,虚拟键盘有可能遮挡表单输入

4.上传文件file.onchange = fn;file.files 上传的图片信息f.type/f.size/f.name缩略图URL.createObjectURL()/FileReaderjson 利用script脚本

你可能感兴趣的:(点透/触屏事件/js兼容性代码)