源码网商城,靠谱的源码在线交易网站 我的订单 购物车 帮助

源码网商城

三种方式获取XMLHttpRequest对象

  • 时间:2020-05-15 19:23 编辑: 来源: 阅读:
  • 扫一扫,手机访问
摘要:三种方式获取XMLHttpRequest对象
获取XmlHttpRequest对象
[u]复制代码[/u] 代码如下:
//1 function getXMLHttpRequest() { var xmlHttpReq; try { // Firefox, Opera 8.0+, Safari xmlHttpReq = new XMLHttpRequest(); } catch (e) { try {// Internet Explorer xmlHttpReq = new ActiveXObject("Msxml2.XMLHTTP"); } catch (e) { try { xmlHttpReq = new ActiveXObject("Microsoft.XMLHTTP"); } catch (e) { } } } return xmlHttpReq; } //2 function getXMLHttpRequest() { var xmlHttpReq = null; if (window.ActiveXObject) {// Internet Explorer xmlHttpReq = new ActiveXObject("MSXML2.XMLHTTP.3.0"); } else if (window.XMLHttpRequest) { xmlHttpReq = new XMLHttpRequest(); } return xmlHttpReq; } //3 function getXMLHttpRequest() { var xmlHttpReq = null; if (window.XMLHttpRequest) {// Mozilla Firefox, Opera 8.0+, Safari xmlHttpReq = new XMLHttpRequest(); } else { if (window.ActiveXObject) {// Internet Explorer try { xmlHttpReq = new ActiveXObject("Microsoft.XMLHTTP"); } catch (e) { try {// Internet Explorer xmlHttpReq = new ActiveXObject("Msxml2.XMLHTTP"); } catch (e) { } } } } return xmlHttpReq; }
  • 全部评论(0)
联系客服
客服电话:
400-000-3129
微信版

扫一扫进微信版
返回顶部