0

I am currently working on javascript project which uses backbone.js as the framework. its a pretty old project where Activex components are used in it, now i need to replace this controls completely so that even when i have my active x disabled my functionality should work as expected. How can i achieve this ? Here is my below chunk of a code which can be refereed . Thank you

function getXMLRequest() {
  var xmlHttp = null;
  if (location.protocol.substr(0, 4) == "http") {
    try { // Firefox, Opera 8.0+, Safari  
      xmlHttp = new XMLHttpRequest();
    } catch (e) { // Internet Explorer  
      try {
        // i need to replace these activex controls
        xmlHttp = new ActiveXObject("Msxml2.XMLHTTP");
      } catch (e) {
        xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
      }
    }
  } else {
    xmlHttp = new XMLCclRequest();
  }

  return xmlHttp;
}
4

1 回答 1

1

该代码仅在浏览器不支持 XMLHttpRequest 时才使用 ActiveX。

ie 如果浏览器是 Internet Explorer 7 或更早版本。

今天没有人应该使用那个浏览器。它没有获得安全更新。它不能在获得安全更新的操作系统上运行。

所以:

function getXMLRequest() {
    return new XMLHttpRequest();
}

如果您需要支持这种过时的浏览器,那么您需要更改服务器 客户端上的代码以使用 JSONP。

于 2019-08-12T09:38:18.390 回答