源码网商城,靠谱的源码在线交易网站 我的订单 购物车 帮助

源码网商城

ie和firefox不兼容的解决方法集合

  • 时间:2020-02-09 10:25 编辑: 来源: 阅读:
  • 扫一扫,手机访问
摘要:ie和firefox不兼容的解决方法集合
[b]1、firefox和ie事件event处理[/b] 在ie中,事件对象是作为一个全局变量来保存和维护的。 所有的浏览器事件,不管是用户触发 的,还是其他事件, 都会更新window.event 对象。 所以在代码中,只要轻松调用 window.event 就可以轻松获取 事件对象, 再 event.srcElement 就可以取得触发事件的元素进行进一步处理 在ff中, 事件对象却不是全局对象,一般情况下,是现场发生,现场使用,ff把事件对象自动传 递给对应的事件处理函数。 在代码中,函数的第一个参数就是ff下的事件对象了。 <button id="btn4" onclick="foo4()">按钮4</button> <script> function foo4(){ var evt=getEvent(); var element=evt.srcElement || evt.target ; alert(element.id) } function getEvent() { //同时兼容ie和ff的写法 if(document.all) return window.event; func=getEvent.caller; while(func!=null){ var arg0=func.arguments[0]; if(arg0){ if((arg0.constructor==Event || arg0.constructor ==MouseEvent) || (typeof(arg0)=="object" && arg0.preventDefault && arg0.stopPropagation)){ return arg0; } } func=func.caller; } return null; } </script> [b]2、firefox和ie对手型指针cursor不兼容[/b] 手型指针有cursor:hand和cursor:pointer两种写法,其中cursor:hand在ff中不支持,返回错误! 只要使用cursor:pointer即可,ff和ie都支持!
  • 全部评论(0)
联系客服
客服电话:
400-000-3129
微信版

扫一扫进微信版
返回顶部