虽然jQuery 对各种浏览器的兼容已经做的很好 但还是会碰到要检测浏览器才能搞定的情况
比如用 $.ajax 来调取 xml 并解析的例子中
$.ajax({
type:"GET",
url:"questions.xml",
dataType:'xml',
timeut:1500,
error:function(){alert("Error loading xml!")},
success:function(xml){//function goes here
})
type:"GET",
url:"questions.xml",
dataType:'xml',
timeut:1500,
error:function(){alert("Error loading xml!")},
success:function(xml){//function goes here

})
在本地用静态环境测试 IE 总会警告错误,FF 和其他浏览器却正常调取解析,如果用绝对地址
$.ajax({
type:"GET",
url:"http://www.xxx.com/focus/kikx/questions.xml",
dataType:'xml'
..
则IE 调取解析正常,而Firefox却不能调取到XML 好吧 我还是来判断下浏览器吧 :
type:"GET",
url:"http://www.xxx.com/focus/kikx/questions.xml",
dataType:'xml'

下面是检测浏览器的一段脚本 写的很精简 很好用:
