This is partially a request for a workaround, and partially an attempt to get the word out that Internet Explorer's prototype implementation is still faulty.
这部分是对变通方法的要求,部分是试图说明Internet Explorer的原型实现仍然有问题。
The following code does not work on Internet Explorer.
以下代码在Internet Explorer上不起作用。
XMLHttpRequest.prototype.old = XMLHttpRequest.prototype.open;
var x = new XMLHttpRequest();
x.old("POST", "test", false);
For IE 8 beta, and all previous versions, the XMLHttpRequest.prototype property never existed in the first place. In IE8, it does exist, but you'll get a "Invalid procedure call or argument" error. Internet Explorer doesn't like decoration.
对于IE 8 beta以及所有以前的版本,XMLHttpRequest.prototype属性从未存在过。在IE8中,它确实存在,但您将收到“无效的过程调用或参数”错误。 Internet Explorer不喜欢装饰。
Does anyone know of a workaround for this?
有谁知道这个的解决方法?
Update:
It has been pointed that I could override the entirety of XMLHttpRequest with a new function and constructor, and then create a wrapper script ala XMLHttpRequest.js. The prototype method is much shorter, so I would still prefer to use it for non-IE browsers.
有人指出,我可以使用新的函数和构造函数覆盖整个XMLHttpRequest,然后创建一个包装器脚本ala XMLHttpRequest.js。原型方法要短得多,所以我仍然希望将它用于非IE浏览器。
1 个解决方案
#1
2
The problem seems to be that IE 8 recognizes XMLHttpRequest, but not as a function. Active X objects still seem to work. Instead of testing for the existance of window.XMLHtppRequest, I test for the typeof window.XMLHtppRequest. seems to work OK.
问题似乎是IE 8识别XMLHttpRequest,但不是作为一个函数。 Active X对象似乎仍然有效。我没有测试window.XMLHtppRequest的存在,而是测试window.XMLHtppRequest的类型。似乎工作正常。
I recoded my get request as follows:
我按如下方式记录了我的获取请求:
FG.ajax.getxhr = function(){
var xhr;
if (typeof window.XMLHttpRequest === 'function') {
xhr = XMLHttpRequest();
}
else {
xhr = new ActiveXObject("Microsoft.XMLHTTP");
}
return xhr;
#1
2
The problem seems to be that IE 8 recognizes XMLHttpRequest, but not as a function. Active X objects still seem to work. Instead of testing for the existance of window.XMLHtppRequest, I test for the typeof window.XMLHtppRequest. seems to work OK.
问题似乎是IE 8识别XMLHttpRequest,但不是作为一个函数。 Active X对象似乎仍然有效。我没有测试window.XMLHtppRequest的存在,而是测试window.XMLHtppRequest的类型。似乎工作正常。
I recoded my get request as follows:
我按如下方式记录了我的获取请求:
FG.ajax.getxhr = function(){
var xhr;
if (typeof window.XMLHttpRequest === 'function') {
xhr = XMLHttpRequest();
}
else {
xhr = new ActiveXObject("Microsoft.XMLHTTP");
}
return xhr;