PageSourceSearch

https://java1234.com/include/dedeajax2.js

js java1234.com collected 2026-09-25 19:45:40 UTC 8,228 bytes, 281 lines download raw bytes

1<!--
2//xmlhttp和xmldom对象
3var DedeXHTTP = null;
4var DedeXDOM = null;
5var DedeContainer = null;
6var DedeShowError = false;
7var DedeShowWait = false;
8var DedeErrCon = "";
9var DedeErrDisplay = "下载数据失败";
10var DedeWaitDisplay = "正在下载数据...";
11
12//获取指定ID的元素
13
14function $DE(id) {
15    return document.getElementById(id);
16}
17
18//gcontainer 是保存下载完成的内容的容器
19//mShowError 是否提示错误信息
20//DedeShowWait 是否提示等待信息
21//mErrCon 服务器返回什么字符串视为错误
22//mErrDisplay 发生错误时显示的信息
23//mWaitDisplay 等待时提示信息
24//默认调用 DedeAjax('divid',false,false,'','','')
25
26function DedeAjax(gcontainer,mShowError,mShowWait,mErrCon,mErrDisplay,mWaitDisplay)
27{
28
29    DedeContainer = gcontainer;
30    DedeShowError = mShowError;
31    DedeShowWait = mShowWait;
32    if(mErrCon!="") DedeErrCon = mErrCon;
33    if(mErrDisplay!="") DedeErrDisplay = mErrDisplay;
34    if(mErrDisplay=="x") DedeErrDisplay = "";
35    if(mWaitDisplay!="") DedeWaitDisplay = mWaitDisplay;
36
37
38    //post或get发送数据的键值对
39    this.keys = Array();
40    this.values = Array();
41    this.keyCount = -1;
42    this.sendlang = 'gb2312';
43
44    //请求头类型
45    this.rtype = 'text';
46
47    //初始化xmlhttp
48    //IE6、IE5
49    if(window.ActiveXObject) {
50        try { DedeXHTTP = new ActiveXObject("Msxml2.XMLHTTP");} catch (e) { }
51        if (DedeXHTTP == null) try { DedeXHTTP = new ActiveXObject("Microsoft.XMLHTTP");} catch (e) { }
52    }
53    else {
54        DedeXHTTP = new XMLHttpRequest();
55    }
56
57    //增加一个POST或GET键值对
58    this.AddKeyN = function(skey,svalue) {
59        if(this.sendlang=='utf-8') this.AddKeyUtf8(skey, svalue);
60        else this.AddKey(skey, svalue);
61    };
62    
63    this.AddKey = function(skey,svalue) {
64        this.keyCount++;
65        this.keys[this.keyCount] = skey;
66        svalue = svalue+'';
67        if(svalue != '') svalue = svalue.replace(/\+/g,'$#$');
68        this.values[this.keyCount] = escape(svalue);
69    };
70
71    //增加一个POST或GET键值对
72    this.AddKeyUtf8 = function(skey,svalue) {
73        this.keyCount++;
74        this.keys[this.keyCount] = skey;
75        svalue = svalue+'';
76        if(svalue != '') svalue = svalue.replace(/\+/g,'$#$');
77        this.values[this.keyCount] = encodeURI(svalue);
78    };
79
80    //增加一个Http请求头键值对
81    this.AddHead = function(skey,svalue) {
82        this.rkeyCount++;
83        this.rkeys[this.rkeyCount] = skey;
84        this.rvalues[this.rkeyCount] = svalue;
85    };
86
87    //清除当前对象的哈希表参数
88    this.ClearSet = function() {
89        this.keyCount = -1;
90        this.keys = Array();
91        this.values = Array();
92        this.rkeyCount = -1;
93        this.rkeys = Array();
94        this.rvalues = Array();
95    };
96
97
98    DedeXHTTP.onreadystatechange = function() {
99        //在IE6中不管阻断或异步模式都会执行这个事件的
100        if(DedeXHTTP.readyState == 4){
101            if(DedeXHTTP.status == 200)
102            {
103                if(DedeXHTTP.responseText!=DedeErrCon) {
104                    DedeContainer.innerHTML = DedeXHTTP.responseText;
105                }
106                else {
107                    if(DedeShowError) DedeContainer.innerHTML = DedeErrDisplay;
108                }
109                DedeXHTTP = null;
110            }
111            else { if(DedeShowError) DedeContainer.innerHTML = DedeErrDisplay; }
112        }
113        else { if(DedeShowWait) DedeContainer.innerHTML = DedeWaitDisplay; }
114    };
115
116    //检测阻断模式的状态
117    this.BarrageStat = function() {
118        if(DedeXHTTP==null) return;
119        if(typeof(DedeXHTTP.status)!=undefined && DedeXHTTP.status == 200)
120        {
121            if(DedeXHTTP.responseText!=DedeErrCon) {
122                DedeContainer.innerHTML = DedeXHTTP.responseText;
123            }
124            else {
125                if(DedeShowError) DedeContainer.innerHTML = DedeErrDisplay;
126            }
127        }
128    };
129
130    //发送http请求头
131    this.SendHead = function()
132    {
133        //发送用户自行设定的请求头
134        if(this.rkeyCount!=-1)
135        { 
136            for(var i = 0;i<=this.rkeyCount;i++)
137            {
138                DedeXHTTP.setRequestHeader(this.rkeys[i],this.rvalues[i]);
139            }
140        }
141         if(this.rtype=='binary'){
142         DedeXHTTP.setRequestHeader("Content-Type","multipart/form-data");
143    }else{
144        DedeXHTTP.setRequestHeader("Content-Type","application/x-www-form-urlencoded");
145    }
146};
147
148//用Post方式发送数据
149this.SendPost = function(purl) {
150    var pdata = "";
151    var i=0;
152    this.state = 0;
153    DedeXHTTP.open("POST", purl, true);
154    this.SendHead();
155    //post数据
156    if(this.keyCount!=-1)
157    {
158        for(;i<=this.keyCount;i++)
159        {
160            if(pdata=="") pdata = this.keys[i]+'='+this.values[i];
161            else pdata += "&"+this.keys[i]+'='+this.values[i];
162        }
163    }
164    DedeXHTTP.send(pdata);
165};
166
167//用GET方式发送数据
168this.SendGet = function(purl) {
169    var gkey = "";
170    var i=0;
171    this.state = 0;
172    //get参数
173    if(this.keyCount!=-1)
174    { 
175        for(;i<=this.keyCount;i++)
176        {
177            if(gkey=="") gkey = this.keys[i]+'='+this.values[i];
178            else gkey += "&"+this.keys[i]+'='+this.values[i];
179        }
180        if(purl.indexOf('?')==-1) purl = purl + '?' + gkey;
181        else  purl = purl + '&' + gkey;
182    }
183    DedeXHTTP.open("GET", purl, true);
184    this.SendHead();
185    DedeXHTTP.send(null);
186};
187
188//用GET方式发送数据,阻塞模式
189this.SendGet2 = function(purl) {
190    var gkey = "";
191    var i=0;
192    this.state = 0;
193    //get参数
194    if(this.keyCount!=-1)
195    { 
196        for(;i<=this.keyCount;i++)
197        {
198            if(gkey=="") gkey = this.keys[i]+'='+this.values[i];
199            else gkey += "&"+this.keys[i]+'='+this.values[i];
200        }
201        if(purl.indexOf('?')==-1) purl = purl + '?' + gkey;
202        else  purl = purl + '&' + gkey;
203    }
204    DedeXHTTP.open("GET", purl, false);
205    this.SendHead();
206    DedeXHTTP.send(null);
207    //firefox中直接检测XHTTP状态
208    this.BarrageStat();
209};
210
211//用Post方式发送数据
212this.SendPost2 = function(purl) {
213    var pdata = "";
214    var i=0;
215    this.state = 0;
216    DedeXHTTP.open("POST", purl, false);
217    this.SendHead();
218    //post数据
219    if(this.keyCount!=-1)
220    {
221        for(;i<=this.keyCount;i++)
222        {
223            if(pdata=="") pdata = this.keys[i]+'='+this.values[i];
224            else pdata += "&"+this.keys[i]+'='+this.values[i];
225        }
226    }
227    DedeXHTTP.send(pdata);
228    //firefox中直接检测XHTTP状态
229    this.BarrageStat();
230};
231
232
233} // End Class DedeAjax
234
235//初始化xmldom
236function InitXDom() {
237    if(DedeXDOM!=null) return;
238    var obj = null;
239    // Gecko、Mozilla、Firefox
240    if (typeof(DOMParser) != "undefined") { 
241        var parser = new DOMParser();
242        obj = parser.parseFromString(xmlText, "text/xml");
243    }
244    // IE
245    else { 
246        try { obj = new ActiveXObject("MSXML2.DOMDocument");} catch (e) { }
247        if (obj == null) try { obj = new ActiveXObject("Microsoft.XMLDOM"); } catch (e) { }
248    }
249    DedeXDOM = obj;
250};
251
252
253
254//读写cookie函数
255function GetCookie(c_name)
256{
257    if (document.cookie.length > 0)
258    {
259        c_start = document.cookie.indexOf(c_name + "=")
260        if (c_start != -1)
261        {
262            c_start = c_start + c_name.length + 1;
263            c_end   = document.cookie.indexOf(";",c_start);
264            if (c_end == -1)
265            {
266                c_end = document.cookie.length;
267            }
268            return unescape(document.cookie.substring(c_start,c_end));
269        }
270    }
271    return null
272}
273
274function SetCookie(c_name,value,expiredays)
275{
276    var exdate = new Date();
277    exdate.setDate(exdate.getDate() + expiredays);
278    document.cookie = c_name + "=" +escape(value) + ((expiredays == null) ? "" : ";expires=" + exdate.toGMTString()); //使设置的有效时间正确。增加toGMTString()
279}
280
281-->

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.