欢迎使用CSDN-markdown编辑器
2015-09-24 11:52
141 查看
/**
* @description 事件绑定,兼容各浏览器
* @param target 事件触发对象
* @param type 事件
* @param func 事件处理函数
*/
function addEvents(target, type, func) {
if (target.addEventListener) //非ie 和ie9
target.addEventListener(type, func, false);
else if (target.attachEvent) //ie6到ie8
target.attachEvent(“on” + type, func);
else target[“on” + type] = func; //ie5
};
/**
* @description 事件移除,兼容各浏览器
* @param target 事件触发对象
* @param type 事件
* @param func 事件处理函数
*/
function removeEvents(target, type, func){
if (target.removeEventListener)
target.removeEventListener(type, func, false);
else if (target.detachEvent)
target.detachEvent(“on” + type, func);
else target[“on” + type] = null;
};
* @description 事件绑定,兼容各浏览器
* @param target 事件触发对象
* @param type 事件
* @param func 事件处理函数
*/
function addEvents(target, type, func) {
if (target.addEventListener) //非ie 和ie9
target.addEventListener(type, func, false);
else if (target.attachEvent) //ie6到ie8
target.attachEvent(“on” + type, func);
else target[“on” + type] = func; //ie5
};
/**
* @description 事件移除,兼容各浏览器
* @param target 事件触发对象
* @param type 事件
* @param func 事件处理函数
*/
function removeEvents(target, type, func){
if (target.removeEventListener)
target.removeEventListener(type, func, false);
else if (target.detachEvent)
target.detachEvent(“on” + type, func);
else target[“on” + type] = null;
};
相关文章推荐
- 线性搜索算法
- 程序员面试必备规程
- 技术选型(一)——安卓开发
- Linux Red Hat 5.6下安装Oracle 11gR2(最新版原创)
- 配置nginx worker 进程数
- 技术选型(一)——安卓开发
- hosname相关函数
- Chrome扩展开发指南(转载)
- %1$s %1$d (java & Android 格式化字符串)
- [LeetCode]Compare Version Numbers
- navigationBar translucent
- 上午所学(jvm内存分配和shell排序算法的深入理解)
- easyui tabs中打开新的tabs关闭当前tabs
- easyUI之Form(表单)组件
- 使用 OAuth2-Server-php 在 Yii 框架上搭建 OAuth2 Server
- Keep-Alive简介及在Tomcat中配置
- html Table标签的初步使用
- SAP接口编程-RFC系列01 : RFC Hello World
- 设计模式六大原则(2):里氏替换原则
- 交叉编译glibc