现在的位置: 首页 > 综合 > 正文

以支持多种浏览器的方式创建 XMLHttpRequest 对象

2014年01月25日 ⁄ 综合 ⁄ 共 345字 ⁄ 字号 评论关闭
/* Create a new XMLHttpRequest object to talk to the Web server */
var xmlHttp = false;
/*@cc_on @*/
/*@if (@_jscript_version >= 5)
try {
  xmlHttp = new ActiveXObject("Msxml2.XMLHTTP");
} catch (e) {
  try {
    xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
  } catch (e2) {
    xmlHttp = false;
  }
}
@end @*/
if (!xmlHttp && typeof XMLHttpRequest != 'undefined') {
  xmlHttp = new XMLHttpRequest();
}

抱歉!评论已关闭.