FF几个常用方法,兼容
来源:互联网 发布:图像增强算法综述 编辑:程序博客网 时间:2024/04/29 09:58
<input id="wc" onclick="alert(window.event.srcElement.id)" type="button" value="查看" />
<script type="text/javascript">
(function (bool) {
//兼容FF一些方法
var html;
if (bool) {
html = window.HTMLElement.prototype;
window.__defineGetter__("event", function () {
//兼容Event对象
var o = arguments.callee;
do {
if (o.arguments[0] instanceof Event) return o.arguments[0];
} while (o = o.caller);
return null;
});
Event.prototype.__defineGetter__("srcElement", function () {
//兼容Event.srcElement对象
var n = this.target;
while (n.nodeType != 1) n = n.parentNode;
return n;
});
html.__defineSetter__("className", function (t_val) {
//兼容className属性(高版本FF已经兼容了)
return this.setAttribute("class") = t_val;
});
html.__defineGetter__("className", function () {
//兼容className属性(高版本FF已经兼容了)
return this.getAttribute("class");
});
}
})(/Firefox/.test(window.navigator.userAgent));
Object.extend = function (a, b) {
//追加方法
for (var i in b) a[i] = b[i];
return a;
};
Object.extend(Object, {
addEvent : function (a, b, c, d) {
//添加函数
var $ni, $nf;
if (b.constructor != Array) { $ni = $nf = b; }
else { $ni = b[0], $nf = b[1]; }
if (a.attachEvent) a.attachEvent($ni, c);
else a.addEventListener($nf.replace(/^on/, ""), c, d || false);
return c;
},
delEvent : function (a, b, c, d) {
//删除函数
var $ni, $nf;
if (b.constructor != Array) { $ni = $nf = b; }
else { $ni = b[0], $nf = b[1]; }
if (a.detachEvent) a.detachEvent($ni, c);
else a.removeEventListener($nf.replace(/^on/, ""), c, d || false);
return c;
}
});
</script>
- FF几个常用方法,兼容
- 常用的兼容IE和火狐FF等浏览器的js方法
- 常用的兼容IE和火狐FF等浏览器的js方法
- 兼容FF/IE的insertAdjacentHTML方法
- 兼容FF/IE的insertAdjacentHTML方法
- getElementsByName 兼容IE FF的方法
- 兼容IE FF的ByName方法
- 兼容IE FF的CSS方法总结
- bootstrapdatetimepicker ff 浏览器 不兼容处理方法
- CSS完美兼容IE6/IE7/FF的通用方法
- EXT2中一段兼容FF的insertAdjacentHTML方法
- CSS完美兼容IE6/IE7/FF的通用方法
- CSS完美兼容IE6/IE7/FF的通用方法
- 兼容IE和FF的字体阴影的方法
- CSS完美兼容IE6/IE7/FF的通用方法
- CSS完美兼容IE6/IE7/FF的通用方法
- 完美兼容IE6/IE7/FF的通用方法
- IE和FF JS中兼容的一些方法
- Vs2005 asp.net development server未能开始侦听端口
- Const与static readonly有什么不同?
- osCommerce服务器移植
- 关于GPRS设备无法读取SIM卡的分析!
- [SQL] 生成无级树 http://blog.csdn.net/xluzhong/articles/299618.aspx
- FF几个常用方法,兼容
- 你知道x86是什么字节序吗?还有怎么转换字节序吗?
- 看图识技术 - Crossbow
- Windows服务器端编程-第二章 设备IO和线程间通信-4-警告式I/O的优缺点
- IDS入侵检测
- 学习.Net的经典网站
- UDT协议-基于UDP的可靠数据传输协议
- 关于类的序列化[Serializable]
- ORACLE Job