当前位置:编程学习 > JS >>

xmlhttp创建方法

下面这种xmlhttp创建方法是一种完全的创建方法哦,下面来看看吧xmlhttp的功能多么的强大哦。

function CreateHTTPObject(){
    var xmlhttp;
   
    try {
        xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
    }
    catch (e) {
        try {
            xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
        }
        catch (e) {
            xmlhttp = false;
        }
    }
   
    if (!xmlhttp && typeof XMLHttpRequest!='undefined') {
        try {
            xmlhttp = new XMLHttpRequest();
        }
        catch (e) {
            xmlhttp=false;
        }
    }
   
    if (!xmlhttp && window.createRequest) {
        try {
            xmlhttp = window.createRequest();
        }
        catch (e) {
            xmlhttp=false;
        }
    }
   
    return xmlhttp;
}

补充:网页制作,js教程 
CopyRight © 2012 站长网 编程知识问答 www.zzzyk.com All Rights Reserved
部份技术文章来自网络,