firefox中获取event方法
在IE中通过wndow.event即可获取当前操作对象,但是firefox没有event对象,不过我们有两种方法在ff中获取操作对象。
1、参数方式。
比如:onclick='getevnet(event)' ,这种方法比较直观,没什么好说的。
2、递归当前操作方法。通过方法调用者层层寻找,直到所需要的对象
js代码
function getEvent() {
if (document.all) {
return window.event; //如果ie
}
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;
if (document.all) {
return window.event; //如果ie
}
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;
}
Insert mode
————————————————————————————————————————
一个人的时候,总是在想
我的生活到底在期待什么……

浙公网安备 33010602011771号