日期:2014-05-16  浏览次数:20359 次

onreadystatechange在ff不支持怎么办啊
我想在内容一改变就触发
这个正合我意
问题是ff不支持

用keyup之类的都试过但都用一些问题(例如enter   输入法等等)
怎么办啊

------解决方案--------------------
晕倒,那个只是一个键盘变化的捕获,给你写了个你要的效果。。测试无问题。FF和OP下拖拽进入时候不会触发focus和blur。。不过当触发了会检索到变化
<script type= "text/javascript ">
var Class = {
//创建类
create: function () {
return function () {
this.initialize.apply(this, arguments);
};
}
};

var $A = function (a) {
//转换数组
return a ? Array.apply(null, a) : new Array;
};

var $ = function (id) {
//获取对象
return document.getElementById(id);
};

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) {
//添加函数
if (a.attachEvent) a.attachEvent(b[0], c);
else a.addEventListener(b[1] || b[0].replace(/^on/, " "), c, d || false);
return c;
},

delEvent : function (a, b, c, d) {
if (a.detachEvent) a.detachEvent(b[0], c);
else a.removeEventListener(b[1] || b[0].replace(/^on/, " "), c, d || false);
return c;
},

reEvent : function () {
//获取Event
return window.event ? window.event : (function (o) {
do {
o = o.caller;
} while (o && !/^\[object[ A-Za-z]*Event\]$/.test(o.arguments[0]));
return o.arguments[0];
})(this.reEvent);
}

});

Function.prototype.bind = function () {
//绑定事件
var wc = this, a = $A(arguments), o = a.shift();
return function () {
wc.apply(o, a.concat($A(arguments)));
};
};

var change = Class.create();

change.prototype = {

time : 10, timer : 0, //记时器和时间值static类型^o^

initialize : function (input) {
var wc = this;
wc.input = input; //对象
wc.value = input.value; //原始值记录
wc.sFunc = Object.addEvent(input, [ "onfocus "], wc.top.bind(wc));
wc.eFunc = Object.addEvent(input, [ "onblur "], wc.end.bind(wc));
},

check : function () {
//检索变化
var wc = this, input = wc.input, temp;
if (wc.value != input.value) { //如果和原始值不等
temp = [wc.value, input.value].sort(function (a, b) { //排序原始值和新值,得到最长的串
a = a.length, b = b.length;
return a > = b ? -1 : 1;
});
wc.value = input.value; //覆盖原始值
document.title = input.id + ": " + temp[0].replace(temp[1], " "); //利用长串替换短串得到变化值
}
},

top : function () {
//开始检索
var wc = this;
wc.timer = window.setInterval(function () {
wc.check();
}, wc.time);
},

end : function () {
var wc = this;
window.clearInterval(wc.timer);
wc.timer = 0;
wc.check(); //当离开的时候要检索最后一变
}

};

window.onload = function () {
new change($( "wc1 "));
new change($( "wc2 "));
};
</script>
<input id= "wc1 " />
<input id= "wc2 " />