⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 http.js

📁 Punjab is a jabber XMLRPC/SOAP/REST client. It is a xmlrpc, soap, or REST server that allows for p
💻 JS
字号:
var ua = navigator.userAgent.toLowerCase();//// Browser Detection//is_mac = (ua.indexOf("mac")!=-1) ? true : false;ns_4 = (document.layers) ? true : false;ie_mac = ((document.all)&&(is_mac)) ? true : false;ie_4_plus = (document.all) ? true : false;ie_4 = ((document.all)&&(ua.indexOf("msie 4.")!=-1)) ? true : false;ie_5 = ((document.all)&&(ua.indexOf("msie 5.")!=-1)) ? true : false;ie_6 = ((document.all)&&(ua.indexOf("msie 6.")!=-1)) ? true : false;ver4 = (ns_4 || ie_4_plus) ? true : false;ns_6 = (!document.layers) && (ua.indexOf('netscape')!=-1)?true:false;ie_5_plus = ie_5 || ie_6;ie_major = 0;if (ie_4_plus){	var start = ua.indexOf("msie");	var end = ua.indexOf(".",start);	ie_major = parseInt(ua.substring(start+5,end));	ie_5_plus = (ie_major>=5) ? true : false;}var is_gecko = (ua.indexOf("gecko") != -1);var is_safari = (ua.indexOf("safari") != -1);function set_cookie(name, value, expires, path, domain, secure) {  var cur_cookie = name + "=" + escape(value) +      ((expires) ? "; expires=" + expires.toGMTString() : "") +      ((path) ? "; path=" + path : "") +      ((domain) ? "; domain=" + domain : "") +      ((secure) ? "; secure" : "");  document.cookie = cur_cookie;}function get_cookie(name) {  var dc = document.cookie;  var prefix = name + "=";  var begin = dc.indexOf("; " + prefix);  if (begin == -1) {    begin = dc.indexOf(prefix);    if (begin != 0) return null;  } else    begin += 2;  var end = document.cookie.indexOf(";", begin);  if (end == -1)    end = dc.length;  return unescape(dc.substring(begin + prefix.length, end));}function HTTP() { var xmlhttp /*@cc_on @*/ /*@if (@_jscript_version >= 5)   try {   xmlhttp=new ActiveXObject("Msxml2.XMLHTTP")  } catch (e) {   try {     xmlhttp=new ActiveXObject("Microsoft.XMLHTTP")   } catch (E) {    xmlhttp=false   }  } @else  xmlhttp=false @end @*/ if (!xmlhttp) {  try {   xmlhttp = new XMLHttpRequest();  } catch (e) {   xmlhttp=false  } } return xmlhttp}if (typeof getURL=='undefined') {  getURL=function(url,fn,s) {   var xmlhttp=new HTTP();  var offset = 0;  if (xmlhttp) {   if (typeof s!='undefined') {      xmlhttp.multipart = true;   }	   url += ( ( url.indexOf('?') + 1 ) ? '&' : '?' ) + ( new Date() ).getTime(); //prevent cache      xmlhttp.open("GET",url,true);   xmlhttp.onreadystatechange=function() {      switch (xmlhttp.readyState) {            // Request not yet made            case 1:                 try {                    fn.on_init();                } catch (e) { /* Handler method not defined */ }            break;            // Contact established with server but nothing downloaded yet            case 2:                try {                    // Check for HTTP status 200                    if ( xmlhttp.status != 200 ) {                        fn.on_error(                            xmlhttp.status,                            xmlhttp.statusText                            );                        // Abort the request                        xmlhttp.abort();                    }                } catch (e) {                    /* Handler method not defined */                }            break;            // Called multiple while downloading in progress            case 3:                // Notify user handler of download progress	        		                try {                    // Get the total content length                    // -useful to work out how much has been downloaded                    try {                        var content_length =                             xmlhttp.getResponseHeader("Content-Length");                    } catch (e) {                        var content_length = NaN;                    } 	            try {                      var tmp_length = xmlhttp.responseText.length;	              if (xmlhttp.responseText.lastIndexOf("\n") < xmlhttp.responseText.length) {	                 tmp_length = xmlhttp.responseText.lastIndexOf("\n");	              }	              var content = xmlhttp.responseText.substring(offset, tmp_length);	            } catch (e) {	                                    var content = null;                    }                    // Call the progress handler with what we've got                    fn.in_progress(                                                  xmlhttp.responseText,                        content,                        content_length,                        offset                    );                    offset += content.length;                } catch (e) {  /* Handler method not defined */ }            break;            // Download complete            case 4:                try {                    fn.on_load(xmlhttp.responseText);                } catch (e) {                    /* Handler method not defined */                } finally {                    // Call no longer in progress                }            break;        }   }   xmlhttp.send(null);   } else {     alert('error in getURL');   } }}if (typeof postURL=='undefined') { postURL=function(url,txt,fn,type,enc) {  var xmlhttp=new HTTP();  var offset = 0;  if (xmlhttp) {   xmlhttp.open("POST",url,true);   if (enc) xmlhttp.setRequestHeader("Content-Encoding",enc)   if (type) xmlhttp.setRequestHeader("Content-Type",type)   xmlhttp.onreadystatechange=function() {	  switch (xmlhttp.readyState) {            // Request not yet made            case 1:                 try {                    fn.on_init();                } catch (e) { /* Handler method not defined */ }            break;            // Contact established with server but nothing downloaded yet            case 2:                try {                    // Check for HTTP status 200                    if ( xmlhttp.status != 200 ) {                        fn.on_error(                            xmlhttp.status,                            xmlhttp.statusText                            );                        // Abort the request                        xmlhttp.abort();                    }                } catch (e) {                    /* Handler method not defined */                }            break;            // Called multiple while downloading in progress            case 3:                // Notify user handler of download progress	                        try {                    // Get the total content length                    // -useful to work out how much has been downloaded                    try {                        var content_length =                             xmlhttp.getResponseHeader("Content-Length");                    } catch (e) {                        var content_length = NaN;                    } 	            try {  	               var content = xmlhttp.responseText.substring(offset, xmlhttp.responseText.length);                                          offset += content.length;                    } catch(e) {                        var content = null;                    } 	                                // Call the progress handler with what we've got                    fn.in_progress(                                                  xmlhttp.responseText,                        content,                        content_length,                        offset                    );                } catch (e) { /* Handler method not defined */ }            break;            // Download complete            case 4:                try {                    fn.on_load(xmlhttp.responseText);                } catch (e) {                    /* Handler method not defined */                } finally {                }            break;        }   }   xmlhttp.send(txt)  } else {   //Some Appropriate Fallback...  } }}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -