首页 > 编程知识 正文

js浏览器兼容性面试题,怎么处理浏览器兼容性问题

时间:2023-05-05 22:04:22 阅读:109198 作者:4757

/1,xsdys内部样式的兼容包functiongetstyle(ele,attr ) if ) ele.currentstyle ) returnele.currentstyle ) attr ); } else { returngetcomputedstyle (ele ([ attr ] ) }//2,事件对象) /获取常规浏览器:在事件处理程序的第一个参数//IE浏览器事件处理程序中获取的常规浏览器: e.keyCode//IE浏览器: e.whichvarcode=e.keycode|| e.which//4,事件目标function target { vare=Evie //5、阻止事件冒泡的程序包functionstopbubble(e ) if ) { e.stopPropagation ) { e.stop propagation } else ) e.cancel bubbuble (e ) 拦截式绑定事件的functionaddevent(ele,type,cb ) if ) ele.attachevent ) ele.attachevent ) ) on'type, cb ) ) eele.attachevent ) )兼容(cb )//7,拦截式删除事件的functionremoveevent(ele,type,cb ),if ) ele.detachevent CB}//8、默认事件functionstopdefault(e ) if ) { e.prevent default } { e.prevent default }; }else{ e.returnValue=false; }

版权声明:该文观点仅代表作者本人。处理文章:请发送邮件至 三1五14八八95#扣扣.com 举报,一经查实,本站将立刻删除。