无意中测试AJAXRequest浏览器兼容性的时候,发现AJAXRequest.update方法在某些情况下在IE里有问题,经过测试找到是setTimeout和setInterval的问题。 问题出现在当调用AJAXRequest.update方法时,如果带了更新间隔及更新次数,那么在IE下面就会出现问题,具体表现为带了更新间隔时是函数工作,带上更新次数时函数无法在更新指定次数后停止执行。 测试几个例子之后找到了问题所在,在IE里,setTimeout和setInterval是不支持参数传递的。 演示地址:http://www.xujiwei.cn/demo/usetimer/ 在Netscape的JavaScript参考中找到setTimeout的语法如下: 代码如下: setTimeout Evaluates an expression or calls a function once after a specified number of milliseconds elapses. 语法 setTimeout(expression, msec) setTimeout(function, msec, arg1, ..., argN) 参数 expression A string containing a JavaScript expression. msec A numeric value or numeric string, in millisecond units. function Any function. arg1, ..., argN (Optional) The arguments, if any, passed to function.