Ajax的Msxml现在因该用哪些呢?

mkz4 2008-11-27 09:29:34
<script type="text/javascript">
var xmlHttp = false;
try {
xmlHttp = new ActiveXObject("Msxml2.XMLHTTP");
} catch (e) {
try {
xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
} catch (e2) {
xmlHttp = false;
}
}
if (!xmlHttp && typeof XMLHttpRequest!='undefined') {
xmlHttp = new XMLHttpRequest();
}


我的这个在firebug调试出问题了,那现在改用那些版本呢,最好兼容更多的浏览器~
...全文
89 5 打赏 收藏 转发到动态 举报
写回复
用AI写文章
5 条回复
切换为时间正序
请发表友善的回复…
发表回复
peacock 2008-11-30
  • 打赏
  • 举报
回复
楼主的代码没问题呀,firebug也没提示任何错误,我用得好好的
mkz4 2008-11-28
  • 打赏
  • 举报
回复
能发个大家觉得的不错的创建xmlhttp请求的代码不,感谢先
xuStanly 2008-11-28
  • 打赏
  • 举报
回复
根据我的一些小研究
http://blog.csdn.net/xuStanly/archive/2008/02/23/2114573.aspx
IE:Microsoft.XMLHTTP
ELSE:XMLHttpRequest
jiduomi123 2008-11-28
  • 打赏
  • 举报
回复

var Sys = {};
var ua = navigator.userAgent.toLowerCase();
window.ActiveXObject ? Sys.ie = ua.match(/msie ([\d.]+)/)[1] :
document.getBoxObjectFor ? Sys.firefox = ua.match(/firefox\/([\d.]+)/)[1] :
window.MessageEvent && !document.getBoxObjectFor ? Sys.chrome = ua.match(/chrome\/([\d.]+)/)[1] :
window.opera ? Sys.opera = ua.match(/opera.([\d.]+)/)[1] :
window.openDatabase ? Sys.safari = ua.match(/version\/([\d.]+)/)[1] : 0;

//以下进行测试
if(Sys.ie) document.write('IE: '+Sys.ie);
if(Sys.firefox) document.write('Firefox: '+Sys.firefox);
if(Sys.chrome) document.write('Chrome: '+Sys.chrome);
if(Sys.opera) document.write('Opera: '+Sys.opera);
if(Sys.safari) document.write('Safari: '+Sys.safari);
jiduomi123 2008-11-28
  • 打赏
  • 举报
回复

function getOs(){
if(navigator.userAgent.indexOf("MSIE")>0) {
return "MSIE";
}
if(navigator.userAgent.indexOf("Firefox")>0){
return "Firefox";
}
if(navigator.userAgent.indexOf("Safari")>0) {
return "Safari";
}
if(navigator.userAgent.indexOf("Camino")>0){
return "Camino";
}
if(navigator.userAgent.indexOf("Gecko")>0){
return "Gecko";
}
}

各种浏览器的判断

52,781

社区成员

发帖
与我相关
我的任务
社区描述
Web 开发 Ajax
社区管理员
  • Ajax
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧