<script>
function createAjax(){
var request=false;

//window对象中有XMLHttpRequest存在就是非IE,包括(IE7,IE8)
if(window.XMLHttpRequest){
  request=new XMLHttpRequest();

if(request.overrideMimeType){
  request.overrideMimeType("text/xml");
}

//window对象中有ActiveXObject属性存在就是IE
}else if(window.ActiveXObject){

var versions=['Microsoft.XMLHTTP', 'MSXML.XMLHTTP', 'Msxml2.XMLHTTP.7.0','Msxml2.XMLHTTP.6.0','Msxml2.XMLHTTP.5.0', 'Msxml2.XMLHTTP.4.0', 'MSXML2.XMLHTTP.3.0', 'MSXML2.XMLHTTP'];

for(var i=0; i<versions.length; i++){
try{
request=new ActiveXObject(versions[i]);

if(request){
return request;
}
}catch(e){
request=false;
}
}
}
return request;
}

var ajax=createAjax();

alert(ajax);
</script>

ajax 对象创建 兼容各个浏览器的更多相关文章

  1. 创建ajax对象并兼容多个浏览器方法简单记录

    这篇文章主要介绍了如何创建ajax对象并兼容多个浏览器,需要的朋友可以参考下<script> function createAjax(){ var request=false; //win ...

  2. ajax中基本兼容各浏览器的XMLHttpRequest的创建

    function createXHR(){ var xhr = null; if(window.XMLHttpRequest){//判断当前浏览器是否支持XMLHttpRequest xhr = ne ...

  3. Ajax的完整兼容各种浏览器版本代码

    <script type="text/javascript"> function createAjax(){ var request=false; //window对象 ...

  4. Ajax--Ajax基于原生javascript:创建Ajax对象、链接服务器、发送请求、接受响应结果

    Ajax概述 异步:指某段程序执行时不会阻塞其它程序执行,其表现形式为程序的执行顺序不依赖程序本身的书写顺序,相反则为同步. 同步请求: 请求是由浏览器发送 页面会刷新 异步请求: 请求是由浏览器的一 ...

  5. Jquery 对象转json ,Json转对象。兼容浏览器。

    引入jquery 转json库 [ 文件大小为2.2K] <script type="text/javascript" src="https://jquery-js ...

  6. 创建Ajax对象

    针对不同版本浏览器插件Ajax对象. <script> function createAjax(){ var request=false; //window对象中有XMLHttpReque ...

  7. XMLHttpRequest对象创建

    本文摘抄自:Ajax知识体系大梳理地址:http://louiszhai.github.io/2016/11/02/ajax/本文内容并不完整,请到原文阅读. if (window.XMLHttpRe ...

  8. 【转】让Bootstrap 3兼容IE8浏览器

    FROM : http://www.ijophy.com/2014/05/bootstrap3-compatible-with-ie8.html 最近在研究Bootstrap(官方,Github)这个 ...

  9. 让Bootstrap 3兼容IE8浏览器

    最近在研究Bootstrap(官方,Github)这个优秀的前端框架,Bootstrap最开始是Twitter团队内部的一个前端框架,所谓前端框架就是一个CSS/HTML框架,框架里面有下拉菜单.按钮 ...

随机推荐

  1. mysql强更改root密码

    在丢失root密码的时候,可以这样 要先停掉 mysql服务 mysqld_safe --skip-grant-tables& mysql -u root mysql mysql> UP ...

  2. ubuntu下sublime中文无法输入的问题

    感谢- http://www.cnblogs.com/ningvsban/p/4346766.html

  3. android模拟器没法通过localhost访问本地服务器的解决

    当android项目访问在一台服务器上的WEB服务时,没法通过localhost或者127.0.0.1来访问.模拟器把它自己作为了localhost,代码中使用localhost或者127.0.0.1 ...

  4. 在Ubuntu14.04系统POWER8服务器上搭建Docker Registry服务

    本文描述了如何在POWER8服务器上搭建一个本地化的Docker镜像仓库,主要涉及镜像制作,Docker Registry服务启动等.希望能够对在非X86服务器上搭建Docker仓库的同学提供参考. ...

  5. 创建javascript对象的几种方式

    ECMAScript提供的对象有:String.Date.Array.Boolean.Math.Number.RegExp.Global 程序中需要用到很多自定义的js对象 1.直接创建 var ob ...

  6. CRM Diagnostics CRM 2016 诊断

    http://xxx.xxxxxx.xxx/Organization/tools/diagnostics/diag.aspx

  7. sublime text 3 license 2016.05

    补充:2016.05 最近经过测试,3个注册码在新版3103的sublime上已经不可用了. 现补充两枚新版的license key: -– BEGIN LICENSE -– Michael Barn ...

  8. [Linux编程]__read_mostly变量含义

    1.定义 __read_mostly原语将定义的变量为存放在.data.read_mostly段中,原型在include/asm/cache.h 中定义: #define __read_mostly ...

  9. Tables without a clustered index are not supported in this version of SQL Server. Please create a clustered index and try again.

    问题: Azure Sql 在插入数据是出现“Msg 40054, Level 16, State 1, Line 2  Tables without a clustered index are no ...

  10. Mvc public virtual DbQuery<TResult> Include("")

    参数 path 类型:System.String要在查询结果中返回的相关对象列表(以点号分隔). 返回值 类型:System.Data.Entity.Infrastructure.DbQuery< ...