将浏览器扩展从 FF 移植到 chrome。我有这个 XMLHttpRequest,它工作正常:
var xhrdata = new XMLHttpRequest(),
xhrdata.onreadystatechange = function () {
if (xhrdata.readyState === 4) {
if (xhrdata.status === 200) {
getJXONTree(xhrdata.responseXML);
}
}
};
xhrdata.open("GET", "mydomain.com/my.xml", true);
xhrdata.responseType = "document";
xhrdata.send();
这会将 .responseXML 发送到此函数(缩短)
function getJXONTree(oXMLParent) {
var vResult = true, nLength = 0, sCollectedTxt = '';
if (oXMLParent.hasAttributes()) {
vResult = {};
[...]
这在 Firefox 中工作得非常好,但在 chrome 中,使用完全相同的代码轮询完全相同的 XML,我得到这个错误:
TypeError: Object #<Document> has no method 'hasAttributes'
我在这里想念什么?