MPBrowser简易图片浏览器 v1.0

2019-09-14 07:34:21王冬梅
MPBrowser.js

var thisImgNo = 290;
function ajaxConn(){
    var xmlhttp = false;
    try{xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");}
    catch(e){try{xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");}
    catch(e){try{xmlhttp = new XMLHttpRequest();}
    catch(e){alert(e);xmlhttp = false;}}}
    if(!xmlhttp)return null;
    this.connect = function(Url,Method,postContent){
        if(!xmlhttp)return false;
        Method = Method.toUpperCase();
        try{
            if (Method == "GET"){
                xmlhttp.open(Method,Url + '?' + postContent,true);
                xmlhttp.setRequestHeader("Content-Type","text/html;charset=GB2312");
                sVars = null;
            }else{
                xmlhttp.open(Method,Url,true);
                xmlhttp.setRequestHeader("Method","POST "+Url+" HTTP/1.1");
                xmlhttp.setRequestHeader("Content-Type","application/x-www-form-urlencoded");
            }
            xmlhttp.onreadystatechange = function(){
                if(xmlhttp.readyState == 4){
                    if(xmlhttp.status == 200){
                        imgInfo = xmlhttp.ResponseText;
                        var imgInfoArr = imgInfo.split("|");
                        var tmpimg = new Image();