您好,欢迎来到三六零分类信息网!老站,搜索引擎当天收录,欢迎发信息

如何创建ajax对象并兼容多个浏览器

2025/12/25 5:26:54发布16次查看
这篇文章主要介绍了创建ajax对象并兼容多个浏览器方法简单记录,在某些情况下还是比较实用的,需要的朋友可以参考下
这篇文章主要介绍了如何创建ajax对象并兼容多个浏览器,需要的朋友可以参考下
<script> function createajax(){ var request=false; //window对象中有xmlhttprequest存在就是非ie,包括(ie7以上版本) 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>
上面是我整理给大家的,希望今后会对大家有帮助。
相关文章:
使用yii整合的pjax(pushstate+ajax)实现无刷新加载页面
基于h5 ajax实现手机定位
浅析asp.net mvc 中ajax的使用
以上就是如何创建ajax对象并兼容多个浏览器的详细内容。
该用户其它信息

VIP推荐

免费发布信息,免费发布B2B信息网站平台 - 三六零分类信息网 沪ICP备09012988号-2
企业名录 Product