Tag: firefox
兼容XMLHttpRequest实例化函数.
function getXmlHttp(){
try
{
xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
}
catch(e)
{
try
{
xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
}
catch(e)
{
xmlhttp = null;
}
}
if (xmlhttp==null && typeof XMLHttpRequest!="undefined"){
try
{
xmlhttp=new XMLHttpRequest();
xmlhttp.overrideMimeType('text/xml');
}catch(e){
xmlhttp=false;
}
}
return xmlhttp;
}
以上函数是我最近一次实例XMLHttpRequest的方法.
早先进行实例的时候,是先处理支持XMLHttpRequest类的标准浏览器,再处理IE这种使用ActiveX实现XMLHttpRequest.
但是前几天发现,似乎IE7已经开始支持XMLHttpRequest,但是使用工程中有发现有点问题,就有改了一下,使用上面这个函数来获取XMLHttpRequest支持.
Recent Comments
- sub040 on 原来我还年轻
- sub040 on 小孩…
- FT on 解决javascript无法使用submit方法提交表单问题
- sub040 on 考试
- sub040 on 无题