﻿<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:trackback="http://madskills.com/public/xml/rss/module/trackback/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/"><channel><title>IT博客-asfman-文章分类-ajax</title><link>http://www.cnitblog.com/asfman/category/3087.html</link><description>有些事，我们明知道是错的，也要去坚持，因为不甘心；有些人，我们明知道是爱的，也要去放弃，因为没结局；有时候，我们明知道没路了，却还在前行，因为习惯了。</description><language>zh-cn</language><lastBuildDate>Mon, 26 Sep 2011 13:39:40 GMT</lastBuildDate><pubDate>Mon, 26 Sep 2011 13:39:40 GMT</pubDate><ttl>60</ttl><item><title>ASP小偷程序如何利用XMLHTTP实现表单的提交</title><link>http://www.cnitblog.com/asfman/articles/18545.html</link><dc:creator>汪杰</dc:creator><author>汪杰</author><pubDate>Sat, 28 Oct 2006 07:19:00 GMT</pubDate><guid>http://www.cnitblog.com/asfman/articles/18545.html</guid><wfw:comment>http://www.cnitblog.com/asfman/comments/18545.html</wfw:comment><comments>http://www.cnitblog.com/asfman/articles/18545.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cnitblog.com/asfman/comments/commentRss/18545.html</wfw:commentRss><trackback:ping>http://www.cnitblog.com/asfman/services/trackbacks/18545.html</trackback:ping><description><![CDATA[
		<h1 id="dxytitle">
				<strong>ASP小偷程序如何利用XMLHTTP实现表单的提交</strong>
		</h1>
		<div id="dxyinfo">转载</div>
		<div id="dxycontent">[原创]ASP小偷程序如何利用XMLHTTP实现表单的提交以及cookies或session的发送 <br />利用XMLHTTP来制作小偷的具体细节落伍很多人都发过和讨论过了，但是在制作ASP小偷的过程中，很多人就发现ASP小偷不如PHP小偷的那么强 <br />大了。确实，如果在原网站如果存在表单提交或cookies的验证，对于ASP来说，不使用基于SOCKET的组件就难以完成，其实，XMLHTTP的另外两 <br />个方法被我们忽略了，而这正是问题的关键。 <br />下面首先来说说这个方法 <br />1。.send() <br />由于流行的小偷是使用的GET而不是POST来传送数据，所以很多人忽略了这个方法，而使用SEND发送数据也很简单，就是SEND("内容")，可是， <br />发送表单就不是这么简单，因为你发送的表单如果是中文的话，就要牵扯到编码的问题了。 <br />首先，你在OPEN 时要确定是用POST 即 .open("POST",地址,是否异步) <br />然后，在SEND里面加上你表单的内容，比如说，你要提交的表单有3个表单域，分别是A，B，C，对应的值分别是1，2，3，那么，你在SEND里这 <br />样写就可以提交表单了，.send("A=1&amp;B=2&amp;C=3"),怎么样，很简单吧，是不是没想到呢？但是别高兴的太早了，我前面说到了，如果表单的值是 <br />中文的话，数据传输的就会出错了。这里我们借助一个函数escape(),熟悉JAVASCRIPT的朋友都应该知道这个函数的作用了，现在VBSCRIPT同样支持这个函数。.send("A=escape('值1')&amp;B=escape('值2')&amp;C=escape('值3')") <br />2。.setRequestHeader() <br />接着上面的所说，你的数据send出去了，对方却不会接收到，为什么了，其实，那是因为你的HTTP头少了一个东西，然后用这个函数把加上去就可以了，具体就是.setRequestHeader("CONTENT-TYPE","application/x-www-form-urlencoded"), 告诉对方你是提交了一个urlencode编码的表单。 <br />好的，说完了表单的提交来说怎么传送cookies和session <br />[ Last edited by 墨鼠 on 2005-4-13 at 13:20 ]  <br />其实传送cookies也很简单了，同样利用这个函数在HTTP头里添加东西，比如，我当前在落伍的cookies是 <br />cdb_sid=ybBiK0; cdb_cookietime=315360000; cdb_oldtopics=D869008D; cdb_visitedfid=1D45; cdb_auth=AQYHXVFDGERdsggVQA1VYUgxQDwFVV1dUAlwFAFRXVwU%2FbAIJB1lUCg; cdb_fid45=1113370145 <br />现在我要发送这个cookies就直接是.setRequestHeader("Cookie","cdb_sid=ybBiK0; cdb_cookietime=315360000; cdb_oldtopics=D869008D; cdb_visitedfid=1D45; cdb_auth=AQYHXVFDGERdsggVQA1VYUgxQDwFVV1dUAlwFAFRXVwU%2FbAIJB1lUCg; cdb_fid45=1113370145") <br />当然，有些网站页面有页面判断功能，这个也不难，就是.setRequestHeader("Referer","来路的绝对地址") <br />这里还有个重要问题，就是这个方法由于是写HTTP头的，所以不能更改现有的HTTP头，对于怎么用asp获取对方页面的cookies或session并且发出去，就下次在发文说明，请先给个精华吧。 <br />为了偶的墨猫MM，写的累死了:cool: <br />use xmlhttp's getResponseHeader and setRequestHeader method<br />Dim logxml, idpw, postxml, info, cookie<br />idpw="id=abc&amp;pw=pass"<br />Set logxml = Server.CreateObject("Microsoft.XMLHTTP")<br />logxml.Open "POST", "http://myserver/login", False<br />logxml.Send idpw<br />cookie = logxml.getResponseHeader("Set-Cookie")<br />info="title=hello&amp;content=world"<br />Set postxml = Server.CreateObject("Microsoft.XMLHTTP")<br />postxml.Open "POST", "http://myserver/post", False<br />postxml.setRequestHeader("Cookie",cookie)<br />postxml.Send</div>
<img src ="http://www.cnitblog.com/asfman/aggbug/18545.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cnitblog.com/asfman/" target="_blank">汪杰</a> 2006-10-28 15:19 <a href="http://www.cnitblog.com/asfman/articles/18545.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>提诉</title><link>http://www.cnitblog.com/asfman/articles/18346.html</link><dc:creator>汪杰</dc:creator><author>汪杰</author><pubDate>Tue, 24 Oct 2006 08:16:00 GMT</pubDate><guid>http://www.cnitblog.com/asfman/articles/18346.html</guid><wfw:comment>http://www.cnitblog.com/asfman/comments/18346.html</wfw:comment><comments>http://www.cnitblog.com/asfman/articles/18346.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cnitblog.com/asfman/comments/commentRss/18346.html</wfw:commentRss><trackback:ping>http://www.cnitblog.com/asfman/services/trackbacks/18346.html</trackback:ping><description><![CDATA[
		<p>&lt;html&gt;<br />&lt;head&gt;&lt;title&gt;bytes2text&lt;/title&gt;&lt;/head&gt;<br />&lt;body&gt;<br />&lt;div id="text1"&gt;解码用时:&lt;/div&gt;<br />&lt;script language="vbscript"&gt;<br />Function jsMidB(str, p)<br /> jsMidB = MidB(str, p)<br />End Function</p>
		<p>Function jsChr(ascii)<br /> jsChr = Chr(ascii)<br />End Function<br />&lt;/script&gt;<br />&lt;script language="javascript"&gt;<br />function xmlHttp(sendMethod, url, postData)<br />{<br /> var http = new ActiveXObject("Microsoft.XMLHTTP");<br /> http.open(sendMethod, url, false, null, null);<br /> if(sendMethod == "post"){<br />  http.setRequestHeader("Content-Type","application/x-www-form-urlencoded");<br />  http.send(postData);<br /> }<br /> else{<br />  http.send(null)<br /> }<br /> return http;<br />}</p>
		<p>function bs2str(str)<br />{<br /> if(!bs2str.ss) bs2str.ss = [];<br /> return unescape(escape(jsMidb(str,1)).replace(/.{2}(.{2})(.{2})/g, "%$2%$1").replace(/%([^0-7].).(.{2})/g, function(a,a1,a2){var s=a1+a2;if(!bs2str.ss[s]) bs2str.ss[s]=jsChr(eval("0x"+s));return bs2str.ss[s];}));<br />}</p>
		<p>//测试<br />var http = xmlHttp("get", "<a href="http://bbs.blueidea.com">http://bbs.blueidea.com</a>", "");<br />var data = http.responseBody;<br />t = (new Date()).getTime();<br />var html = bs2str(data);<br />document.getElementById("text1").innerText += (new Date()).getTime() - t;<br />document.getElementById("text1").innerText += "\r\n" + html;<br />&lt;/script&gt;<br />&lt;/body&gt;<br />&lt;/html&gt;</p>
<img src ="http://www.cnitblog.com/asfman/aggbug/18346.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cnitblog.com/asfman/" target="_blank">汪杰</a> 2006-10-24 16:16 <a href="http://www.cnitblog.com/asfman/articles/18346.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>用XMLHTTP Post/Get HTML页面时的中文乱码问题之完全Script解决方案</title><link>http://www.cnitblog.com/asfman/articles/18286.html</link><dc:creator>汪杰</dc:creator><author>汪杰</author><pubDate>Mon, 23 Oct 2006 08:23:00 GMT</pubDate><guid>http://www.cnitblog.com/asfman/articles/18286.html</guid><wfw:comment>http://www.cnitblog.com/asfman/comments/18286.html</wfw:comment><comments>http://www.cnitblog.com/asfman/articles/18286.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cnitblog.com/asfman/comments/commentRss/18286.html</wfw:commentRss><trackback:ping>http://www.cnitblog.com/asfman/services/trackbacks/18286.html</trackback:ping><description><![CDATA[
		<p> 用XMLHTTP Post/Get HTML页面时的中文乱码问题之完全Script解决方案</p>
		<p>关键词：VBScript, ASP, JavaScript, Java, XML</p>
		<p>以前我曾经贴过一篇用XMLHTTP Post Form 的帖子，那里的代码中我Post E文的Value毫无问题，但是后来发现Post含有中文的表单时会出现乱码，原因当然是UTF-8 和GB2312 之间的转换问题了！TNND，打倒GB2312！大家都用UTF8多好。</p>
		<p>用XMLHTTP Post Form时的表单乱码有两方面的原因——Post表单数据时中文乱码；服务器Response被XMLHTTP不正确编码引起的乱码。换句话说，本文主要解决两个问题——怎样正确Post中文内容&amp;怎样正确显示得到的中文内容。</p>
		<p>Part I Post中文内容</p>
		<p>先看看E文的表单是怎么提交的：</p>
		<p>&lt;SCRIPT language="JavaScript"&gt;<br />strA = "submit1=Submit&amp;text1=scsdfsd";<br />var oReq = new ActiveXObject("MSXML2.XMLHTTP");<br />oReq.open("POST","<a href="http://ServerName/VDir/TstResult.asp&quot;,false">http://ServerName/VDir/TstResult.asp",false</a>);<br />oReq.setRequestHeader("Content-Length",strA.length);  <br />oReq.setRequestHeader("CONTENT-TYPE","application/x-www-form-urlencoded");<br />oReq.send(strA);<br />&lt;/ScRIPT&gt;</p>
		<p>如果把strA = "submit1=Submit&amp;text1=scsdfsd";换成：<br />strA = "submit1=Submit&amp;text1=中文";</p>
		<p>你会发现提交上去的东东根本不对，ASP中Request.Form("Text1"）根本取不到值。俺用Request.BinaryRead把一个HTML Form中的Post内容写出来看了看，才发现问题——Form提交时也要编码的，编码后的中文是类似于%??%??的转义字符，比如“中文”就被编码为：%D6%D0%CE%C4。呵呵，也怪俺笨，人家CONTENT-TYPE里明明写的清清楚楚——application/x-www-form-urlencoded，urlencoded嘛当然就是这个样子了。既然这样,那我们也知道该怎么办了——自己做转换，代码见下：</p>
		<p>&lt;SCRIPT language="VBScript"&gt;<br />Function URLEncoding(vstrIn)<br />    strReturn = ""<br />    For i = 1 To Len(vstrIn)<br />        ThisChr = Mid(vStrIn,i,1)<br />        If Abs(Asc(ThisChr)) &lt; &amp;HFF Then<br />            strReturn = strReturn &amp; ThisChr<br />        Else<br />            innerCode = Asc(ThisChr)<br />            If innerCode &lt; 0 Then<br />                innerCode = innerCode + &amp;H10000<br />            End If<br />            Hight8 = (innerCode  And &amp;HFF00)\ &amp;HFF<br />            Low8 = innerCode And &amp;HFF<br />            strReturn = strReturn &amp; "%" &amp; Hex(Hight8) &amp;  "%" &amp; Hex(Low8)<br />        End If<br />    Next<br />    URLEncoding = strReturn<br />End Function</p>
		<p>strA = URLEncoding("submit1=Submit&amp;text1=中文")<br />oReq = CreateObject("MSXML2.XMLHTTP")<br />oReq.open "POST","<a href="http://ServerName/VDir/TstResult.asp&quot;,false">http://ServerName/VDir/TstResult.asp",false</a><br />oReq.setRequestHeader "Content-Length",Len(strA)<br />oReq.setRequestHeader "CONTENT-TYPE","application/x-www-form-urlencoded"<br />oReq.send strA<br />&lt;/ScRIPT&gt;</p>
		<p>（在这里俺把前面的JavaScript的代码改成了VBScript，不是吃饱了撑的没事干，原因见后）</p>
		<p>Part II.正确显示得到的中文内容</p>
		<p>OK，如果你在Server端把Form的内容写到数据库/文件的话，你在那里看到的中文毫无问题，但是，假如你想看看Server的Response——问题来了：如果Response的结果不是XML，XMLHTTP.responseXML里当然是不会有东东的，那就用responseText好了，在代码的最后加一句：</p>
		<p>alert(oReq.responseText)<br />看看俺们辛勤劳动的结果  :P</p>
		<p>但是但是.....怎么所有的中文全变成了方格? （我打不出来，有兴趣自己去试，也不用Post，Get一个含有中文的网页就可以发现了。）</p>
		<p>原因很简单：XMLHTTP得到Response时假定Response是UTF8编码的，如果Response是XML，那还可以通过encoding来指定编码，但HTML就不行了。（见鬼的GB2312，再次打倒！）所以它把含GB2312编码的HTML当成UTF8格式，不出错才有鬼！</p>
		<p>不过好在还有补救的办法：XMLHTTP的responseBody 属性里包含的可是未解码的Resonse——"a raw undecoded bytes as received directly from the server" ：），唯一的问题是，responseBody返回的是一个unsigned bytes数组，我们怎么去访问它，怎么把它转换成BSTR？</p>
		<p>这就是为什么我在上面把代码改成VBScript的原因——VBScript Can do it,but JavaScript Cannot!</p>
		<p>代码见下：<br />&lt;SCRIPT language="VBScript"&gt;<br />Function URLEncoding(vstrIn)<br />    strReturn = ""<br />    For i = 1 To Len(vstrIn)<br />        ThisChr = Mid(vStrIn,i,1)<br />        If Abs(Asc(ThisChr)) &lt; &amp;HFF Then<br />            strReturn = strReturn &amp; ThisChr<br />        Else<br />            innerCode = Asc(ThisChr)<br />            If innerCode &lt; 0 Then<br />                innerCode = innerCode + &amp;H10000<br />            End If<br />            Hight8 = (innerCode  And &amp;HFF00)\ &amp;HFF<br />            Low8 = innerCode And &amp;HFF<br />            strReturn = strReturn &amp; "%" &amp; Hex(Hight8) &amp;  "%" &amp; Hex(Low8)<br />        End If<br />    Next<br />    URLEncoding = strReturn<br />End Function</p>
		<p>Function bytes2BSTR(vIn)<br />    strReturn = ""<br />    For i = 1 To LenB(vIn)<br />        ThisCharCode = AscB(MidB(vIn,i,1))<br />        If ThisCharCode &lt; &amp;H80 Then<br />            strReturn = strReturn &amp; Chr(ThisCharCode)<br />        Else<br />            NextCharCode = AscB(MidB(vIn,i+1,1))<br />            strReturn = strReturn &amp; Chr(CLng(ThisCharCode) * &amp;H100 + CInt(NextCharCode))<br />            i = i + 1<br />        End If<br />    Next<br />    bytes2BSTR = strReturn<br />End Function</p>
		<p>strA = URLEncoding("submit1=Submit&amp;text1=中文")<br />oReq = CreateObject("MSXML2.XMLHTTP")<br />oReq.open "POST","<a href="http://ServerName/VDir/TstResult.asp&quot;,false">http://ServerName/VDir/TstResult.asp",false</a><br />oReq.setRequestHeader "Content-Length",Len(strA)<br />oReq.setRequestHeader "CONTENT-TYPE","application/x-www-form-urlencoded"<br />oReq.send strA<br />alert bytes2BSTR(oReq.responseBody)<br />&lt;/ScRIPT&gt;</p>
		<p>嘿嘿，是不是很简单啊，用这个再试试看？一切OK！</p>
		<p>（顺便说说byte()，这个东东在VBScript里的表现只能用妖来形容——对它调用VarType 返回8209——vbArray + vbByte,用LBound、UBound能拿到数组的上界下界，但是就是不能用name(i)的形式访问，搞得我以为在Script里根本没法处理这种类型，在bytes2BSTR函数里可以看到我是把它当成String来处理的——LenB/MidB什么的，发现这点纯属意外——我开始往这个函数里传的是XMLHTTP.responseText，想一个Byte一个Byte地看看里面到底有点什么，后来一时性起把responseText改成responseBody，结果就中奖了，哈哈）</p>
		<p>最后的废话：<br />1、以上代码在MSXML Parser 3 Release＋VBScript 5.5环境下通过。那位兄弟有早一点版本的Script可以帮我试试看能不能成。<br />2、一直以为JavaScript vs VBScript应该是JavaScript略好，所以有时候想彻底抛弃VBScript，ASP Server/Client统统用JavaScript，看来未必是个好主意。</p>
		<p> <br /></p>
<img src ="http://www.cnitblog.com/asfman/aggbug/18286.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cnitblog.com/asfman/" target="_blank">汪杰</a> 2006-10-23 16:23 <a href="http://www.cnitblog.com/asfman/articles/18286.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>Ansi,UTF8,Unicode,ASCII编码</title><link>http://www.cnitblog.com/asfman/articles/18284.html</link><dc:creator>汪杰</dc:creator><author>汪杰</author><pubDate>Mon, 23 Oct 2006 08:01:00 GMT</pubDate><guid>http://www.cnitblog.com/asfman/articles/18284.html</guid><wfw:comment>http://www.cnitblog.com/asfman/comments/18284.html</wfw:comment><comments>http://www.cnitblog.com/asfman/articles/18284.html#Feedback</comments><slash:comments>1</slash:comments><wfw:commentRss>http://www.cnitblog.com/asfman/comments/commentRss/18284.html</wfw:commentRss><trackback:ping>http://www.cnitblog.com/asfman/services/trackbacks/18284.html</trackback:ping><description><![CDATA[
		<script><![CDATA[unction StorePage(){d=document;t=d.selection?(d.selection.type!='None'?d.selection.createRange().text:''):(d.getSelection?d.getSelection():'');void(keyit=window.open('http://www.365key.com/storeit.aspx?t='+escape(d.title)+'&u='+escape(d.location.href)+'&c='+escape(t),'keyit','scrollbars=no,width=475,height=575,left=75,top=20,status=no,resizable=yes'));keyit.focus();}]]&gt;</script>
 
<div class="post"><div class="postTitle"><img height="13" src="http://blog.csdn.net/images/zhuan.gif" width="15" border="0" /> </div><div class="postText"><p>转自<a href="http://calmzeal.cnblogs.com/archive/2006/03/02/341332.aspx">http://calmzeal.cnblogs.com/archive/2006/03/02/341332.aspx</a>  原作者:calmzeal</p><p>最近在看c# String Handling and Regular Expressions handBook,打算把正则表达式好好学一下,顺便复习一下字符串.<br /><br />关于上述编码,一直迷迷糊糊,查了些资料,总算大致了解了<br />1.  ASCII和Ansi编码<br /><strong>    字符内码</strong>(charcter code)指的是用来代表字符的内码.读者在输入和存储文档时都要使用内码,内码分为 <br /><strong>    单字节内码</strong> -- Single-Byte character sets (SBCS),可以支持256个字符编码. <br />    <strong>双字节内码</strong> -- Double-Byte character sets)(DBCS),可以支持65000个字符编码.<br />前者即为ASCII编码，后者对应ANSI.<br />至于简体中文编码GB2312，实际上它是ＡＮＳＩ的一个代码页936<br /><br />2. Unicode<br />　如上，ANSI有很多代码页，使用不同代码页的内码无法在其他代码也正常显示，这就是为什么日文版／繁体中文版游戏无法在简体中文平台直接显示的原因．<br />    Unicode也是一种字符编码方法，不过它是由国际组织设计，可以容纳全世界所有语言文字的编码方案．它是一种２字节编码，能够提供６５５３６个字符，这个数字是不够表示所有的字符的（汉语就有５５０００多字符），所以，通过一个代理对的机制来实现附加的９１７，４７６个字符表示，以达到所有字符都具有唯一编码．<br /><br />３．Unicode和BigEndianUnicode<br />    这两者只是存储顺序不同，如＂A＂的unicode编码为65 00<br />    其BigEndianUnicode编码为00 65<br /><br />4.  UTF-8</p><p>    这是为传输而设计的编码，其系列还有UTF-7和UTF-16<br />    其中UTF-16和Unicode编码大致一样, UTF-8就是以8位为单元对Unicode进行编码。从Unicode到UTF-8的编码方式如下：<br />　　　　　Unicode编码(16进制)　　　　　　UTF-8 字节流(二进制) <br />　　　　　0000 - 007F　　　　　　　　　0xxxxxxx <br />　　　　　0080 - 07FF　　　　　　　　　110xxxxx 10xxxxxx <br />　　　　　0800 - FFFF　　　　　　　　　1110xxxx 10xxxxxx 10xxxxxx <br /><br />　　例如“汉”字的Unicode编码是6C49。6C49在0800-FFFF之间，所以肯定要用3字节模板了：1110xxxx 10xxxxxx 10xxxxxx。将6C49写成二进制是：0110 110001 001001， 用这个比特流依次代替模板中的x，得到：11100110 10110001 10001001，即E6 B1 89。<br /></p><p> </p></div></div><img src ="http://www.cnitblog.com/asfman/aggbug/18284.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cnitblog.com/asfman/" target="_blank">汪杰</a> 2006-10-23 16:01 <a href="http://www.cnitblog.com/asfman/articles/18284.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>GB 2312 汉字编码字符集</title><link>http://www.cnitblog.com/asfman/articles/18282.html</link><dc:creator>汪杰</dc:creator><author>汪杰</author><pubDate>Mon, 23 Oct 2006 07:27:00 GMT</pubDate><guid>http://www.cnitblog.com/asfman/articles/18282.html</guid><wfw:comment>http://www.cnitblog.com/asfman/comments/18282.html</wfw:comment><comments>http://www.cnitblog.com/asfman/articles/18282.html#Feedback</comments><slash:comments>1</slash:comments><wfw:commentRss>http://www.cnitblog.com/asfman/comments/commentRss/18282.html</wfw:commentRss><trackback:ping>http://www.cnitblog.com/asfman/services/trackbacks/18282.html</trackback:ping><description><![CDATA[
		<p align="center">
				<font color="#ff0000">
						<b>GB 2312 汉字编码字符集</b>
				</font>
		</p>
		<br />　　GB 2312 码是中华人民共和国国家标准汉字信息交换用编码，全称《信息交换用汉字编码字符集　基本集》，标准号为 GB 2312－80（GB 是“国标”二字的汉语拼音缩写），由中华人民共和国国家标准总局发布，1981年5月1日实施。习惯上称国标码、GB 码，或区位码。它是一个简化字汉字的编码，通行于中国大陆地区。新加坡等地也使用这一编码。<br />　　GB 2312-80 收录简化汉字及一般符号、序号、数字、拉丁字母、日文假名、希腊字母、俄文字母、汉语拼音符号、汉语注音字母，共 7445 个图形字符。其中汉字以外的图形字符 682 个，汉字 6763 个。<br />　　GB 2312-80 规定，“对任意一个图形字符都采用两个字节（Byte）表示。每个字节均采用 GB 1988－80 及 GB 2311－80 中的七位编码表示。两个字节中前面的字节为第一字节，后面的字节为第二字节。”习惯上称第一字节为“高字节”，第二字节为“低字节”。<br />　　GB 2312-80 将代码表分为 94 个区（Section），对应第一字节；每个区 94 个位（Position），对应第二字节。两个字节的值，分别为区号值和位号值各加 32（20H）。<br />　　GB 2312-80 规定，01～09 区（原规定为 1～9 区，为表示区位码方便起见，今改称 01～09 区）为符号、数字区，16～87 区为汉字区。而 10～15 区、88～94 区是有待于“进一步标准化”的“空白位置”区域。但第 10 区推荐与第 3 区的 94 个图形字符（即 GB 1988－80 中的 94 个图形字符）相同，字形宽度为其宽度的一半。<br />　　GB 2312-80 把收录的汉字分成两级。第一级汉字是常用汉字，计 3755 个，置于 16～55 区，按汉语拼音字母／笔形顺序排列；第二级汉字是次常用汉字，计 3008 个，置于 56～87 区，按部首／笔画顺序排列。字音以普通话审音委员会发表的《普通话异读词三次审音总表初稿》（1963年出版）为准，字形以中华人民共和国文化部、中国文字改革委员会公布的《印刷通用汉字字形表》（1964年出版）为准。 
<p></p>　　例：汉字“啊”，第一字节为 0110000，第二字节为 0100001，即 16 区、01 位，用 16－01 表示。 
<p></p><center><font color="#ff0000">GB 2312－80 图形字符代码表</font><p></p><table cellspacing="0" cellpadding="2" border="1" white="70%"><tbody><tr><td><a href="http://www.haiyan.com/steelk/navigator/ref/gb2312/gb01.htm">01-07区</a></td><td><a href="http://www.haiyan.com/steelk/navigator/ref/gb2312/gb08.htm">08-15区</a></td><td><a href="http://www.haiyan.com/steelk/navigator/ref/gb2312/gb16.htm">16-23区</a></td><td><a href="http://www.haiyan.com/steelk/navigator/ref/gb2312/gb24.htm">24-31区</a></td><td><a href="http://www.haiyan.com/steelk/navigator/ref/gb2312/gb32.htm">32-39区</a></td><td><a href="http://www.haiyan.com/steelk/navigator/ref/gb2312/gb40.htm">40-47区</a></td></tr><tr><td><a href="http://www.haiyan.com/steelk/navigator/ref/gb2312/gb48.htm">48-55区</a></td><td><a href="http://www.haiyan.com/steelk/navigator/ref/gb2312/gb56.htm">56-63区</a></td><td><a href="http://www.haiyan.com/steelk/navigator/ref/gb2312/gb64.htm">64-71区</a></td><td><a href="http://www.haiyan.com/steelk/navigator/ref/gb2312/gb72.htm">72-79区</a></td><td><a href="http://www.haiyan.com/steelk/navigator/ref/gb2312/gb80.htm">80-87区</a></td><td><font color="#f48931">88区以下略</font></td></tr></tbody></table></center><p>　　注：<br />　　1. 如果你使用外挂式中文平台，需要将当前环境设置为 GB 码来阅读上表。例如，使用南极星全球通，需要将当前环境设置成为“Chinese GB Simplified”（中文GB简体），而不要设置成为“Chinese Auto Simplified”（中文自动简体）。有些外挂式的中文平台，不能正确显示 01～15 区的空白位置。<br />　　2. 02 区的 0201～0210、06 区的 0664～0685 和 08 区的 0827～0832 位置，在 GB 2312－80 中原本规定为有待于进一步标准化的空白位置。但如果你使用的操作系统为 Windows 95 简体中文版（及更高的版本），或者使用了其他支持 GBK 码、CJK 码的汉字系统，在某些情况下会看到以上位置分别为 10 个小写罗马数字、19 个中文竖排用符号和 6 个汉语拼音符号。这些符号系 GB 5007.1、<a href="http://www.haiyan.com/steelk/navigator/ref/gb12345/gbindex.htm">GB/T 12345-90</a> 及 <a href="http://www.haiyan.com/steelk/navigator/ref/gbk/gbindex.htm">GBK</a> 增补的符号，由于 Windows 95 简体中文版使用了 GBK 字体，所以显示出这些符号。此外第 10、11、12 区显示的汉字，也属类似的情况。<br />　　3. GB 码的编码范围为 2121H～777EH，与 ASCII 码有重叠，通行将 GB 码两个字节的最高位均置 1（MSB=1），以示区别。因此，实际应用的 GB 码是 GB 码高位置 1 后的变形码，编码范围为 0A1A1H～0F7FEH。如汉字“啊”，第一字节为 10110000，第二字节为 10100001。</p><center><table cellspacing="0" cellpadding="2" border="1"><tbody><tr><td colspan="3"><a href="http://www.haiyan.com/steelk/navigator/ref/gb2312/GB2312.zip">下载</a> GB 2312-80 代码表纯文本文件（ZIP压缩）<br />　　 该文件为 GB 2312 代码编制。</td></tr><tr><td>　</td><td>ZIP 文件：</td><td>解压缩后文件：</td></tr><tr><td>文件名：</td><td>GB2312.zip</td><td>GB2312.txt</td></tr><tr><td>长　度：</td><td>17,314 Bytes</td><td>31,517 Bytes</td></tr></tbody></table></center><img src ="http://www.cnitblog.com/asfman/aggbug/18282.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cnitblog.com/asfman/" target="_blank">汪杰</a> 2006-10-23 15:27 <a href="http://www.cnitblog.com/asfman/articles/18282.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>ASCII编码表</title><link>http://www.cnitblog.com/asfman/articles/18281.html</link><dc:creator>汪杰</dc:creator><author>汪杰</author><pubDate>Mon, 23 Oct 2006 07:22:00 GMT</pubDate><guid>http://www.cnitblog.com/asfman/articles/18281.html</guid><wfw:comment>http://www.cnitblog.com/asfman/comments/18281.html</wfw:comment><comments>http://www.cnitblog.com/asfman/articles/18281.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cnitblog.com/asfman/comments/commentRss/18281.html</wfw:commentRss><trackback:ping>http://www.cnitblog.com/asfman/services/trackbacks/18281.html</trackback:ping><description><![CDATA[
		<div class="carticletitle">
				<h1>ASCII编码表</h1>
		</div>
		<div class="carticle">
				<!--articlepart start-->
				<p>ASCII是英文American Standard Code for Information Interchange的缩写。ASCII码是目前计算机最通用的编码标准。</p>
				<p>因为计算机只能接受数字信息，ASCII码将字符作为数字来表示，以便计算机能够接受和处理。比如大写字母M的ASCII码是77。</p>
				<p>ASCII码中，第0～32号及第127号是控制字符，常用的有LF(换行)、CR(回车)；第33～126号是字符，其中第48～57号为0～9十个阿拉伯数字；65～90号为26个大写英文字母，97～122号为26个小写英文字母，其余的是一些标点符号、运算符号等。</p>
				<p>以下是常用的ASCII码对照表：</p>
				<p>
				</p>
				<table>
						<tbody>
								<tr>
										<td style="BACKGROUND-COLOR: #ffffff">
												<table>
														<tbody>
																<tr class="header">
																		<td>十进制</td>
																		<td>十六进制</td>
																		<td>字符</td>
																</tr>
																<tr>
																		<td>9</td>
																		<td>9</td>
																		<td>TAB(制表符)</td>
																</tr>
																<tr>
																		<td>10</td>
																		<td>A</td>
																		<td>换行</td>
																</tr>
																<tr>
																		<td>13</td>
																		<td>D</td>
																		<td>回车</td>
																</tr>
																<tr>
																		<td>32</td>
																		<td>20</td>
																		<td>空格</td>
																</tr>
																<tr>
																		<td>33</td>
																		<td>21</td>
																		<td>!</td>
																</tr>
																<tr>
																		<td>34</td>
																		<td>22</td>
																		<td>"</td>
																</tr>
																<tr>
																		<td>35</td>
																		<td>23</td>
																		<td>#</td>
																</tr>
																<tr>
																		<td>36</td>
																		<td>24</td>
																		<td>$</td>
																</tr>
																<tr>
																		<td>37</td>
																		<td>25</td>
																		<td>%</td>
																</tr>
																<tr>
																		<td>38</td>
																		<td>26</td>
																		<td>&amp;</td>
																</tr>
																<tr>
																		<td>39</td>
																		<td>27</td>
																		<td>'</td>
																</tr>
																<tr>
																		<td>40</td>
																		<td>28</td>
																		<td>(</td>
																</tr>
																<tr>
																		<td>41</td>
																		<td>29</td>
																		<td>)</td>
																</tr>
																<tr>
																		<td>42</td>
																		<td>2A</td>
																		<td>*</td>
																</tr>
																<tr>
																		<td>43</td>
																		<td>2B</td>
																		<td>+</td>
																</tr>
																<tr>
																		<td>44</td>
																		<td>2C</td>
																		<td>,</td>
																</tr>
																<tr>
																		<td>45</td>
																		<td>2D</td>
																		<td>-</td>
																</tr>
																<tr>
																		<td>46</td>
																		<td>2E</td>
																		<td>.</td>
																</tr>
																<tr>
																		<td>47</td>
																		<td>2F</td>
																		<td>/</td>
																</tr>
																<tr>
																		<td>48</td>
																		<td>30</td>
																		<td>0</td>
																</tr>
																<tr>
																		<td>49</td>
																		<td>31</td>
																		<td>1</td>
																</tr>
																<tr>
																		<td>50</td>
																		<td>32</td>
																		<td>2</td>
																</tr>
																<tr>
																		<td>51</td>
																		<td>33</td>
																		<td>3</td>
																</tr>
																<tr>
																		<td>52</td>
																		<td>34</td>
																		<td>4</td>
																</tr>
																<tr>
																		<td>53</td>
																		<td>35</td>
																		<td>5</td>
																</tr>
																<tr>
																		<td>54</td>
																		<td>36</td>
																		<td>6</td>
																</tr>
																<tr>
																		<td>55</td>
																		<td>37</td>
																		<td>7</td>
																</tr>
																<tr>
																		<td>56</td>
																		<td>38</td>
																		<td>8</td>
																</tr>
																<tr>
																		<td>57</td>
																		<td>39</td>
																		<td>9</td>
																</tr>
																<tr>
																		<td>58</td>
																		<td>3A</td>
																		<td>:</td>
																</tr>
																<tr>
																		<td>59</td>
																		<td>3B</td>
																		<td>;</td>
																</tr>
																<tr>
																		<td>60</td>
																		<td>3C</td>
																		<td>&lt;</td>
																</tr>
																<tr>
																		<td>61</td>
																		<td>3D</td>
																		<td>=</td>
																</tr>
														</tbody>
												</table>
										</td>
										<td style="BACKGROUND-COLOR: #ffffff">
												<table>
														<tbody>
																<tr class="header">
																		<td>十进制</td>
																		<td>十六进制</td>
																		<td>字符</td>
																</tr>
																<tr>
																		<td>62</td>
																		<td>3E</td>
																		<td>&gt;</td>
																</tr>
																<tr>
																		<td>63</td>
																		<td>3F</td>
																		<td>?</td>
																</tr>
																<tr>
																		<td>64</td>
																		<td>40</td>
																		<td>@</td>
																</tr>
																<tr>
																		<td>65</td>
																		<td>41</td>
																		<td>A</td>
																</tr>
																<tr>
																		<td>66</td>
																		<td>42</td>
																		<td>B</td>
																</tr>
																<tr>
																		<td>67</td>
																		<td>43</td>
																		<td>C</td>
																</tr>
																<tr>
																		<td>68</td>
																		<td>44</td>
																		<td>D</td>
																</tr>
																<tr>
																		<td>69</td>
																		<td>45</td>
																		<td>E</td>
																</tr>
																<tr>
																		<td>70</td>
																		<td>46</td>
																		<td>F</td>
																</tr>
																<tr>
																		<td>71</td>
																		<td>47</td>
																		<td>G</td>
																</tr>
																<tr>
																		<td>72</td>
																		<td>48</td>
																		<td>H</td>
																</tr>
																<tr>
																		<td>73</td>
																		<td>49</td>
																		<td>I</td>
																</tr>
																<tr>
																		<td>74</td>
																		<td>4A</td>
																		<td>J</td>
																</tr>
																<tr>
																		<td>75</td>
																		<td>4B</td>
																		<td>K</td>
																</tr>
																<tr>
																		<td>76</td>
																		<td>4C</td>
																		<td>L</td>
																</tr>
																<tr>
																		<td>77</td>
																		<td>4D</td>
																		<td>M</td>
																</tr>
																<tr>
																		<td>78</td>
																		<td>4E</td>
																		<td>N</td>
																</tr>
																<tr>
																		<td>79</td>
																		<td>4F</td>
																		<td>O</td>
																</tr>
																<tr>
																		<td>80</td>
																		<td>50</td>
																		<td>P</td>
																</tr>
																<tr>
																		<td>81</td>
																		<td>51</td>
																		<td>Q</td>
																</tr>
																<tr>
																		<td>82</td>
																		<td>52</td>
																		<td>R</td>
																</tr>
																<tr>
																		<td>83</td>
																		<td>53</td>
																		<td>S</td>
																</tr>
																<tr>
																		<td>84</td>
																		<td>54</td>
																		<td>T</td>
																</tr>
																<tr>
																		<td>85</td>
																		<td>55</td>
																		<td>U</td>
																</tr>
																<tr>
																		<td>86</td>
																		<td>56</td>
																		<td>V</td>
																</tr>
																<tr>
																		<td>87</td>
																		<td>57</td>
																		<td>W</td>
																</tr>
																<tr>
																		<td>88</td>
																		<td>58</td>
																		<td>X</td>
																</tr>
																<tr>
																		<td>89</td>
																		<td>59</td>
																		<td>Y</td>
																</tr>
																<tr>
																		<td>90</td>
																		<td>5A</td>
																		<td>Z</td>
																</tr>
																<tr>
																		<td>91</td>
																		<td>5B</td>
																		<td>[</td>
																</tr>
																<tr>
																		<td>92</td>
																		<td>5C</td>
																		<td>\</td>
																</tr>
																<tr>
																		<td>93</td>
																		<td>5D</td>
																		<td>]</td>
																</tr>
																<tr>
																		<td>94</td>
																		<td>5E</td>
																		<td>^</td>
																</tr>
														</tbody>
												</table>
										</td>
										<td style="VERTICAL-ALIGN: top; BACKGROUND-COLOR: #ffffff">
												<table>
														<tbody>
																<tr class="header">
																		<td>十进制</td>
																		<td>十六进制</td>
																		<td>字符</td>
																</tr>
																<tr>
																		<td>95</td>
																		<td>5F</td>
																		<td>_</td>
																</tr>
																<tr>
																		<td>96</td>
																		<td>60</td>
																		<td>`</td>
																</tr>
																<tr>
																		<td>97</td>
																		<td>61</td>
																		<td>a</td>
																</tr>
																<tr>
																		<td>98</td>
																		<td>62</td>
																		<td>b</td>
																</tr>
																<tr>
																		<td>99</td>
																		<td>63</td>
																		<td>c</td>
																</tr>
																<tr>
																		<td>100</td>
																		<td>64</td>
																		<td>d</td>
																</tr>
																<tr>
																		<td>101</td>
																		<td>65</td>
																		<td>e</td>
																</tr>
																<tr>
																		<td>102</td>
																		<td>66</td>
																		<td>f</td>
																</tr>
																<tr>
																		<td>103</td>
																		<td>67</td>
																		<td>g</td>
																</tr>
																<tr>
																		<td>104</td>
																		<td>68</td>
																		<td>h</td>
																</tr>
																<tr>
																		<td>105</td>
																		<td>69</td>
																		<td>i</td>
																</tr>
																<tr>
																		<td>106</td>
																		<td>6A</td>
																		<td>j</td>
																</tr>
																<tr>
																		<td>107</td>
																		<td>6B</td>
																		<td>k</td>
																</tr>
																<tr>
																		<td>108</td>
																		<td>6C</td>
																		<td>l</td>
																</tr>
																<tr>
																		<td>109</td>
																		<td>6D</td>
																		<td>m</td>
																</tr>
																<tr>
																		<td>110</td>
																		<td>6E</td>
																		<td>n</td>
																</tr>
																<tr>
																		<td>111</td>
																		<td>6F</td>
																		<td>o</td>
																</tr>
																<tr>
																		<td>112</td>
																		<td>70</td>
																		<td>p</td>
																</tr>
																<tr>
																		<td>113</td>
																		<td>71</td>
																		<td>q</td>
																</tr>
																<tr>
																		<td>114</td>
																		<td>72</td>
																		<td>r</td>
																</tr>
																<tr>
																		<td>115</td>
																		<td>73</td>
																		<td>s</td>
																</tr>
																<tr>
																		<td>116</td>
																		<td>74</td>
																		<td>t</td>
																</tr>
																<tr>
																		<td>117</td>
																		<td>75</td>
																		<td>u</td>
																</tr>
																<tr>
																		<td>118</td>
																		<td>76</td>
																		<td>v</td>
																</tr>
																<tr>
																		<td>119</td>
																		<td>77</td>
																		<td>w</td>
																</tr>
																<tr>
																		<td>120</td>
																		<td>78</td>
																		<td>x</td>
																</tr>
																<tr>
																		<td>121</td>
																		<td>79</td>
																		<td>y</td>
																</tr>
																<tr>
																		<td>122</td>
																		<td>7A</td>
																		<td>z</td>
																</tr>
																<tr>
																		<td>123</td>
																		<td>7B</td>
																		<td>{</td>
																</tr>
																<tr>
																		<td>124</td>
																		<td>7C</td>
																		<td>|</td>
																</tr>
																<tr>
																		<td>125</td>
																		<td>7D</td>
																		<td>}</td>
																</tr>
																<tr>
																		<td>126</td>
																		<td>7E</td>
																		<td>~</td>
																</tr>
														</tbody>
												</table>
										</td>
								</tr>
						</tbody>
				</table>
				<p>完整的ASCII编码表如下(来源：微软MSDN站点)：</p>
				<p>
						<img alt="ASCII编码表" src="http://www.blabla.cn/asdocs/ref/ascii.gif" />
				</p>
		</div>
<img src ="http://www.cnitblog.com/asfman/aggbug/18281.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cnitblog.com/asfman/" target="_blank">汪杰</a> 2006-10-23 15:22 <a href="http://www.cnitblog.com/asfman/articles/18281.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>innerHTML方法加载一些含有javascript脚本的字符串</title><link>http://www.cnitblog.com/asfman/articles/18101.html</link><dc:creator>汪杰</dc:creator><author>汪杰</author><pubDate>Wed, 18 Oct 2006 15:32:00 GMT</pubDate><guid>http://www.cnitblog.com/asfman/articles/18101.html</guid><wfw:comment>http://www.cnitblog.com/asfman/comments/18101.html</wfw:comment><comments>http://www.cnitblog.com/asfman/articles/18101.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cnitblog.com/asfman/comments/commentRss/18101.html</wfw:commentRss><trackback:ping>http://www.cnitblog.com/asfman/services/trackbacks/18101.html</trackback:ping><description><![CDATA[
		<div class="msgborder" id="code0">我们也许有写时候会遇到要使用innerHTML方法加载一些含有javascript脚本的字符串，但是当我们直接用innerHTML加载这段字符串的时候，发现了javascript的脚本根本没有运行，而这段脚本就解决了这段问题．<br />&lt;html&gt;<br />&lt;head&gt;<br />&lt;title&gt;&lt;/title&gt;<br />&lt;/head&gt;<br />&lt;script language="javascript" type="text/javascript"&gt;<br />&lt;!--<br />var global_html_pool = [];<br />var global_script_pool = [];<br />var global_script_src_pool = [];<br />var global_lock_pool = [];<br />var innerhtml_lock = null;<br />var document_buffer = "";<br /><br />function set_innerHTML(obj_id, html, time) {<br />    if (innerhtml_lock == null) {<br />        innerhtml_lock = obj_id;<br />    }<br />    else if (typeof(time) == "undefined") {<br />        global_lock_pool[obj_id + "_html"] = html;<br />        window.setTimeout("set_innerHTML('" + obj_id + "', global_lock_pool['" + obj_id + "_html']);", 10);<br />        return;<br />    }<br />    else if (innerhtml_lock != obj_id) {<br />        global_lock_pool[obj_id + "_html"] = html;<br />        window.setTimeout("set_innerHTML('" + obj_id + "', global_lock_pool['" + obj_id + "_html'], " + time + ");", 10);<br />        return;<br />    }<br /><br />    function get_script_id() {<br />        return "script_" + (new Date()).getTime().toString(36)<br />          + Math.floor(Math.random() * 100000000).toString(36);<br />    }<br /><br />    document_buffer = "";<br /><br />    document.write = function (str) {<br />        document_buffer += str;<br />    }<br />    document.writeln = function (str) {<br />        document_buffer += str + "\n";<br />    }<br /><br />    global_html_pool = [];<br /><br />    var scripts = [];<br />    html = html.split(/&lt;\/script&gt;/i);<br />    for (var i = 0; i &lt; html.length; i++) {<br />        global_html_pool[i] = html[i].replace(/&lt;script[\s\S]*$/ig, "");<br />        scripts[i] = {text: '', src: '' };<br />        scripts[i].text = html[i].substr(global_html_pool[i].length);<br />        scripts[i].src = scripts[i].text.substr(0, scripts[i].text.indexOf('&gt;') + 1);<br />        scripts[i].src = scripts[i].src.match(/src\s*=\s*(\"([^\"]*)\"|\'([^\']*)\'|([^\s]*)[\s&gt;])/i);<br />        if (scripts[i].src) {<br />            if (scripts[i].src[2]) {<br />                scripts[i].src = scripts[i].src[2];<br />            }<br />            else if (scripts[i].src[3]) {<br />                scripts[i].src = scripts[i].src[3];<br />            }<br />            else if (scripts[i].src[4]) {<br />                scripts[i].src = scripts[i].src[4];<br />            }<br />            else {<br />                scripts[i].src = "";<br />            }<br />            scripts[i].text = "";<br />        }<br />        else {<br />            scripts[i].src = "";<br />            scripts[i].text = scripts[i].text.substr(scripts[i].text.indexOf('&gt;') + 1);<br />            scripts[i].text = scripts[i].text.replace(/^\s*&lt;\!--\s*/g, "");<br />        }<br />    }<br /><br />    var s;<br />    if (typeof(time) == "undefined") {<br />        s = 0;<br />    }<br />    else {<br />        s = time;<br />    }<br /><br />    var script, add_script, remove_script;<br /><br />    for (var i = 0; i &lt; scripts.length; i++) {<br />        var add_html = "document_buffer += global_html_pool[" + i + "];\n";<br />        add_html += "document.getElementById('" + obj_id + "').innerHTML = document_buffer;\n";<br />        script = document.createElement("script");<br />        if (scripts[i].src) {<br />            script.src = scripts[i].src;<br />            if (typeof(global_script_src_pool[script.src]) == "undefined") {<br />                global_script_src_pool[script.src] = true;<br />                s += 2000;<br />            }<br />            else {<br />                s += 10;<br />            }<br />        }<br />        else {<br />            script.text = scripts[i].text;<br />            s += 10;<br />        }<br />        script.defer = true;<br />        script.type =  "text/javascript";<br />        script.id = get_script_id();<br />        global_script_pool[script.id] = script;<br />        add_script = add_html;<br />        add_script += "document.getElementsByTagName('head').item(0)";<br />        add_script += ".appendChild(global_script_pool['" + script.id + "']);\n";<br />        window.setTimeout(add_script, s);<br />        remove_script = "document.getElementsByTagName('head').item(0)";<br />        remove_script += ".removeChild(document.getElementById('" + script.id + "'));\n";<br />        remove_script += "delete global_script_pool['" + script.id + "'];\n";<br />        window.setTimeout(remove_script, s + 10000);<br />    }<br /><br />    var end_script = "if (document_buffer.match(/&lt;\\/script&gt;/i)) {\n";<br />    end_script += "set_innerHTML('" + obj_id + "', document_buffer, " + s + ");\n";<br />    end_script += "}\n";<br />    end_script += "else {\n";<br />    end_script += "document.getElementById('" + obj_id + "').innerHTML = document_buffer;\n";<br />    end_script += "innerhtml_lock = null;\n";<br />    end_script += "}";<br />    window.setTimeout(end_script, s);<br />}<br />--&gt;<br />&lt;/script&gt;<br />&lt;body&gt;<br />&lt;div align="center"&gt;<br />&lt;form name="frmScript"&gt;<br />&lt;textarea id="script" name="script" cols="40" rows="8"&gt;<br />&lt;script type="text/javascript"&gt;<br />    document.write("这里的内容是使用document.write方法写入的");<br />&lt;/script&gt;<br />&lt;/textarea&gt;<br />&lt;/form&gt;<br />&lt;div&gt;<br />&lt;div align="center"&gt;<br />    &lt;a href="javascript:void(0)" onclick="set_innerHTML('innerHTML',document.frmScript.script.value)"&gt;写如内容&lt;/a&gt;<br />&lt;/div&gt;<br />&lt;hr width="300" size="1"&gt;<br />&lt;table border="0" width="300" style="border:1px solid #E2E2E2" cellpadding="0" cellspacing="0" align="center"&gt;<br />       &lt;tr&gt;<br />             &lt;td id="innerHTML" height="200"&gt;<br />             &lt;/td&gt;<br />       &lt;/tr&gt;<br />&lt;/table&gt;      <br />&lt;/body&gt;<br />&lt;/html&gt;</div>
<img src ="http://www.cnitblog.com/asfman/aggbug/18101.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cnitblog.com/asfman/" target="_blank">汪杰</a> 2006-10-18 23:32 <a href="http://www.cnitblog.com/asfman/articles/18101.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>客户端的urlencode和dencode</title><link>http://www.cnitblog.com/asfman/articles/18009.html</link><dc:creator>汪杰</dc:creator><author>汪杰</author><pubDate>Sun, 15 Oct 2006 16:49:00 GMT</pubDate><guid>http://www.cnitblog.com/asfman/articles/18009.html</guid><wfw:comment>http://www.cnitblog.com/asfman/comments/18009.html</wfw:comment><comments>http://www.cnitblog.com/asfman/articles/18009.html#Feedback</comments><slash:comments>1</slash:comments><wfw:commentRss>http://www.cnitblog.com/asfman/comments/commentRss/18009.html</wfw:commentRss><trackback:ping>http://www.cnitblog.com/asfman/services/trackbacks/18009.html</trackback:ping><description><![CDATA[
		<p>urlencode解码：<br />&lt;script language=vbscript&gt;<br />Function vbChar(str)<br /> vbChar=chr(str)<br />End Function<br />Function uc(str)<br />  uc=hex(ascW(str))<br />End Function<br />&lt;/script&gt;<br />&lt;script language=javascript&gt;<br />var glbEncode=new Array();<br />function reCode(str) {<br />  var str=str.replace(/%([A-Z].)%(.{2})/g,"@$1$2").replace(/\+/g,"%20");<br />  var t=str.split("@"),k,l=t.length;<br /> for(var i=1;i&lt;l;i++) {<br />   k=t[i].substring(0,4);<br />  if(!glbEncode[k])<br />   glbEncode[k]=uc(vbChar(eval("0x"+k)));<br />   t[i]=glbEncode[k]+t[i].substring(4);<br />}<br />str=unescape(t.join("%u"));<br />return str;<br />}<br />document.write(reCode("%D0%A1+%C7%E0%2C%CE%D2%B0%AE%C4%E3"))<br />&lt;/script&gt;<br />urlencode加码：<br />&lt;script language=vbscript&gt;<br />Function vbChar(str)<br /> vbChar=chrW(str)<br />End Function<br />Function reHex(str)<br /> reHex=hex(asc(str))<br />End Function<br />&lt;/script&gt;<br />&lt;script language=javascript&gt;<br />var glbEncode=new Object();<br />function urlEncode(str) {<br />  str=escape(str).replace(/%u(.{4})/g,"@$1").replace(/%20/g,"+");<br />  var t=str.split("@"),l=t.length,k;<br />  for(var i=1;i&lt;l;i++) {<br />    k=t[i].substring(0,4);<br />    if(!glbEncode[k])<br />     glbEncode[k]=reHex(vbChar(eval("0x"+k))).replace(/(.{2})(.{2})/g,"%$1%$2");<br />     t[i]=glbEncode[k]+t[i].substring(4);<br />  }<br />  return t.join("");<br />}<br />var str="小 青,我爱你";<br />document.write(urlEncode(str))<br />&lt;/script&gt;<br />原理：<br />urlencode跟escape除了空格和字符值大于 255 的编码不一样其他都一样</p>
<img src ="http://www.cnitblog.com/asfman/aggbug/18009.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cnitblog.com/asfman/" target="_blank">汪杰</a> 2006-10-16 00:49 <a href="http://www.cnitblog.com/asfman/articles/18009.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>ImageLoader 1.1 Release</title><link>http://www.cnitblog.com/asfman/articles/17975.html</link><dc:creator>汪杰</dc:creator><author>汪杰</author><pubDate>Sat, 14 Oct 2006 08:16:00 GMT</pubDate><guid>http://www.cnitblog.com/asfman/articles/17975.html</guid><wfw:comment>http://www.cnitblog.com/asfman/comments/17975.html</wfw:comment><comments>http://www.cnitblog.com/asfman/articles/17975.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cnitblog.com/asfman/comments/commentRss/17975.html</wfw:commentRss><trackback:ping>http://www.cnitblog.com/asfman/services/trackbacks/17975.html</trackback:ping><description><![CDATA[
		<font color="#ff0000">By dknt From bbs.blueidea.com</font>
		<br />
		<br />特点：<br />1.图片预载入，载入后再显示。意图一次呈现，不会让一块一块下载破坏你的页面，绝佳的用户体验，颠覆传统的浏览器呈现图片的处理方式（需要后续函数支持）。<br />2.不会因载入图片造成脚本暂停假死，完全另一线程进行。不影响主程序流程。<br />3.提供及时的反馈，包括两方面的内容：1.正在载入什么图片 2.当前的百分数进度。大大提高留住用户眼球的概率，不会让用户因为苦等而离开。<br />4.容错支持，即使某个图片没有成功下载，也可以设置超时时间以便处理下一个图片。<br />5.多变的参数类型，尽最大可能方便使用。<br /><br /><div class="msgheader"><div class="right"><a class="smalltxt" onclick="copycode($('code0'));" href="http://bbs.blueidea.com/thread-2676673-1-2.html###">[Copy to clipboard]</a></div>CODE:</div><div class="msgborder" id="code0">// save this as "image_loader.js"<br /><br />//-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-//<br />/*<br />  ImageLoader, Version 1.1, JavaScript <br />  (c) 2006 Christian An &lt;anchangsi@gmail.com&gt;<br /><br />  With copyright not modified, you can use this program freely. <br />*/<br />//-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-//<br /><br />function ImageLoader(className,Options){<br />    this._ImageLoadStack = null;<br />    this._currrentLoading = "";<br />    this._FinalRun = false;<br />    this.numLoaded = 0;<br />    this.ClassName = className;<br />    <br />    if(typeof(Options)=="undefined") Options = {};<br />    <br />    if(isNaN(Options.Timeout) || Options.Timeout &lt; 0 ||  Options.Timeout &gt;100000){<br />        this.EnableTimeout = false;<br />    }else {<br />        this.EnableTimeout = true;<br />        this.Timeout = Options.Timeout;<br />    }<br />    <br />    if(typeof(Options.func)=="undefined"){<br />        this.AfterFunction = null;<br />    }else{<br />        this.AfterFunction = Options.func;<br />    }<br />    <br />    if(typeof(Options.display)=="undefined"){<br />        this.disDiv = null;<br />    }else if(typeof(Options.display)=="string"){<br />        this.disDiv = document.getElementById(Options.display);<br />    }else if(typeof(Options.display)=="object"){<br />        this.disDiv = Options.display;<br />    }else{<br />        this.disDiv = null;<br />    }<br /><br />    if(typeof(Options.process)=="undefined"){<br />        this.procDiv = null;<br />    }else if(typeof(Options.process)=="string"){<br />        this.procDiv = document.getElementById(Options.process);<br />    }else if(typeof(Options.process)=="object"){<br />        this.procDiv = Options.process;<br />    }else{<br />        this.procDiv = null;<br />    }<br /><br />    <br />    if(typeof(document.imageArray)=="undefined") document.imageArray = new Array();<br />    <br />    this.Load = function(){<br />        var args = this.Load.arguments;<br />        if(args.length!=0){<br />            this._ImageLoadStack = new Array();<br />            for(i=0; i&lt;args.length; i++){<br />                if(args[i].indexOf("#")!=0){<br />                    this._ImageLoadStack.push(args[i]);<br />                }<br />            }<br /><br />        }else if(this._ImageLoadStack == null){<br />            this._runFinal();<br />        }<br />        this.numTotal = this._ImageLoadStack.length;<br />        this._LoadAImage();<br />    }<br />    <br />    this._LoadAImage = function(){<br />        if(this._ImageLoadStack.length!=0){<br />            var sURL = this._ImageLoadStack.shift();<br />            if(this.disDiv!=null) this.disDiv.innerHTML = sURL;<br />            _currrentLoading = sURL;<br />        <br />            <br />            var j = document.imageArray.length;<br />            document.imageArray[j] = document.createElement("IMG");<br />            document.imageArray[j].Owner = this;<br />            <br />            document.imageArray[j].onload = function(){<br />                this.Owner._LoadAImage();<br />                this.onload = null;<br />            }<br />            document.imageArray[j].onerror = function(){<br />                this.Owner._LoadAImage();<br />                this.onload = null;<br />            }<br />            <br />            if(this.EnableTimeout){<br />                window.setTimeout("if(_currrentLoading==\""+sURL+"\"){"+this.ClassName+"._LoadAImage()}",this.Timeout);<br />            }<br />    <br />            document.imageArray[j++].src = sURL;<br />                if(this.procDiv!=null){<br />                this.numLoaded++;<br />                var percentage = Math.floor(this.numLoaded * 100 / this.numTotal);<br />                this.procDiv.innerHTML = percentage;<br />            }<br /><br />        }else{<br />            this._runFinal();<br />        }<br /><br />    }<br />    this._runFinal = function(){<br />            if(this._FinalRun == false){<br />                this._FinalRun = true;<br />                <br />                if(typeof(this.AfterFunction)=="function"){<br />                    this.AfterFunction();<br />                }else if(typeof(this.AfterFunction)=="string"){<br />                    if (window.execScript){<br />                        window.execScript(this.AfterFunction);<br />                    }else{<br />                        window.eval(this.AfterFunction); <br />                    }<br />                }<br />            }<br />    }<br />    this.setLoadImages = function(imageArray){<br />        if(typeof(imageArray)!="object") return;<br />        this._ImageLoadStack = imageArray;<br />    }<br /><br />}</div><br /><b>[Document]</b><br /><br />使用<br /><br /><div class="msgheader"><div class="right"><a class="smalltxt" onclick="copycode($('code1'));" href="http://bbs.blueidea.com/thread-2676673-1-2.html###">[Copy to clipboard]</a></div>CODE:</div><div class="msgborder" id="code1">var loader = new ImageLoader(ClassName,Options);</div><br />的形式创建该对象。<br /><br />其中：<br /><br />loader ： 为 JavaScript 变量名；<br /><br />ClassName ： String 型： 为 loader 在 JavaScript 中的表达。 如果是在任何函数之外创建该对象，请直接赋以该变量的字符串形式，如对应loader 为"loader" ; 如果是某个函数体内，仍然赋以该变量的字符串形式，但是创建的变量名请使用 window.loader 的形式。<br /><br />Options   ： Object 型，下列属性是支持的：<br />                Timeout ： Integer，可选。取值为1-100000,单位毫秒。非正整数表示不采用。此为一个图片的最大载入时间，如果提供这个参数，则某个图片不能正常下载时，可以跳过继续下载另一个图片。否则将一直等到该图片下载完成为止。<br />                func      ： Function / String，必须。当所有图片载入之后调用的函数，通常是一个显示这些图片功能的函数。如果不提供这个函数，则整个机制将变得毫无作用。 Function型的参数会直接调用，String型的参数会当作JavaScript 语句来运行。<br />                display   ：String / Object，可选。此为显示当前载入图片的DOM对象，该对象应该支持innerHTML属性。 当提供此参数为String 时，会被当作DOM对象的 id 来处理，若 Object 型，则直接当作一个DOM对象。提供其他类型没有效果。<br />                process  ：String / Object，可选。此为以百分数显示当前载入进度的DOM对象，该对象应该支持innerHTML属性。 当提供此参数为String 时，会被当作DOM对象的 id 来处理，若 Object 型，则直接当作一个DOM对象。提供其他类型没有效果。<br />见下列示范:<br /><br /><div class="msgheader"><div class="right"><a class="smalltxt" onclick="copycode($('code2'));" href="http://bbs.blueidea.com/thread-2676673-1-2.html###">[Copy to clipboard]</a></div>CODE:</div><div class="msgborder" id="code2">//在所有函数之外时<br />//function final(){...};<br />function $(par){<br />    return document.getElementById(par)<br />}<br /><br />var MyLoader = new ImageLoader("MyLoader ",{Timeout:1000,func: final,display:"display",process:$("process")});<br /><br /><br />//在某个函数体内时<br />function somefunc(){<br />   //...<br />   window.MyLoader = new ImageLoader("MyLoader ",{Timeout:1000,func: "alert('fine')",display:"display",process:$("process")});<br />  //...<br />}</div><br /><b>=*-*=*-*=*-*=*-*=*-*=*-*=*-*=*-*=*-*=*-*=*-*=*-*=*-*=*-*=*-*=*-*=*-*=*-*=*-*=*-*=*-*=*-*</b><br /><br />方法定义：<br />Load(paralist)  ：载入一系列图片。完毕后自动调用 func属性的内容。 paralist，可以是一些字符串的集合（但不要提供一个数组），各项由 , 隔开。这些字符串应该是图片的url。也可以不提供任何参数。Load方法将载入预先设定好的系列图片。如果没有预先设定过，则直接调用 func 属性的内容。若func没有提供，则没有任何效果。<br /><br /><div class="msgheader"><div class="right"><a class="smalltxt" onclick="copycode($('code3'));" href="http://bbs.blueidea.com/thread-2676673-1-2.html###">[Copy to clipboard]</a></div>CODE:</div><div class="msgborder" id="code3">//sample：<br />MyLoader.Load("http://bbs.blueidea.com/images/blue/logo.gif",<br />            "http://gg.blueidea.com/2006/chinaok/208x32.gif",<br />            "http://gg.blueidea.com/2006/now/208x32.gif",<br />            "http://gg.blueidea.com/2006/gongyi/banner.jpg",<br />            "http://gg.blueidea.com/2006/flash8/pepsi.gif",<br />            "http://www.google.com/intl/zh-CN_ALL/images/logo.gif");<br /><br />//or if pic series is provided.<br /><br />MyLoader.Load();</div><br />setLoadImages(ArrayImages)： 设定要载入的图片系列。ArrayImages 应以数组的形式提供，数组的每一个元素都应当是一个图片的URL。不接受其他类型的参数。此方法调用后并不开始载入图片。<br /><br /><div class="msgheader"><div class="right"><a class="smalltxt" onclick="copycode($('code4'));" href="http://bbs.blueidea.com/thread-2676673-1-2.html###">[Copy to clipboard]</a></div>CODE:</div><div class="msgborder" id="code4">//sample：<br />MyLoader.setLoadImages(["http://bbs.blueidea.com/images/blue/logo.gif",<br />            "http://gg.blueidea.com/2006/chinaok/208x32.gif",<br />            "http://gg.blueidea.com/2006/now/208x32.gif",<br />            "http://gg.blueidea.com/2006/gongyi/banner.jpg",<br />            "http://gg.blueidea.com/2006/flash8/pepsi.gif",<br />            "http://www.google.com/intl/zh-CN_ALL/images/logo.gif"])<br /><strong>[测试用例]<br /><div style="BORDER-RIGHT: #cccccc 1px solid; PADDING-RIGHT: 5px; BORDER-TOP: #cccccc 1px solid; PADDING-LEFT: 4px; FONT-SIZE: 13px; PADDING-BOTTOM: 4px; BORDER-LEFT: #cccccc 1px solid; WIDTH: 98%; WORD-BREAK: break-all; PADDING-TOP: 4px; BORDER-BOTTOM: #cccccc 1px solid; BACKGROUND-COLOR: #eeeeee"><span style="COLOR: #008080">  1</span> <span style="COLOR: #000000">&lt;</span><span style="COLOR: #000000">body</span><span style="COLOR: #000000">&gt;</span><span style="COLOR: #000000"><br /></span><span style="COLOR: #008080">  2</span> <span style="COLOR: #000000"></span><span style="COLOR: #000000">&lt;</span><span style="COLOR: #000000">script </span><span style="COLOR: #000000">&gt;</span><span style="COLOR: #000000"><br /></span><span style="COLOR: #008080">  3</span> <span style="COLOR: #000000"></span><span style="COLOR: #008000">//</span><span style="COLOR: #008000">-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-//</span><span style="COLOR: #008000"><br /></span><span style="COLOR: #008080">  4</span> <span style="COLOR: #008000">/*</span><span style="COLOR: #008000"><br /></span><span style="COLOR: #008080">  5</span> <span style="COLOR: #008000">  ImageLoader, Version 1.0, JavaScript <br /></span><span style="COLOR: #008080">  6</span> <span style="COLOR: #008000">  (c) 2006 Christian An &lt;anchangsi@gmail.com&gt;<br /></span><span style="COLOR: #008080">  7</span> <span style="COLOR: #008000"><br /></span><span style="COLOR: #008080">  8</span> <span style="COLOR: #008000">  With copyright not modified, you can use this program freely. <br /></span><span style="COLOR: #008080">  9</span> <span style="COLOR: #008000"></span><span style="COLOR: #008000">*/</span><span style="COLOR: #000000"><br /></span><span style="COLOR: #008080"> 10</span> <span style="COLOR: #000000"></span><span style="COLOR: #008000">//</span><span style="COLOR: #008000">-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-//</span><span style="COLOR: #008000"><br /></span><span style="COLOR: #008080"> 11</span> <span style="COLOR: #008000"></span><span style="COLOR: #000000"><br /></span><span style="COLOR: #008080"> 12</span> <span style="COLOR: #000000"><br /></span><span style="COLOR: #008080"> 13</span> <span style="COLOR: #000000"><br /></span><span style="COLOR: #008080"> 14</span> <span style="COLOR: #000000"></span><span style="COLOR: #0000ff">function</span><span style="COLOR: #000000"> ImageLoader(className,Options){<br /></span><span style="COLOR: #008080"> 15</span> <span style="COLOR: #000000">    </span><span style="COLOR: #0000ff">this</span><span style="COLOR: #000000">._ImageLoadStack </span><span style="COLOR: #000000">=</span><span style="COLOR: #000000"> </span><span style="COLOR: #0000ff">null</span><span style="COLOR: #000000">;<br /></span><span style="COLOR: #008080"> 16</span> <span style="COLOR: #000000">    </span><span style="COLOR: #0000ff">this</span><span style="COLOR: #000000">._currrentLoading </span><span style="COLOR: #000000">=</span><span style="COLOR: #000000"> </span><span style="COLOR: #000000">""</span><span style="COLOR: #000000">;<br /></span><span style="COLOR: #008080"> 17</span> <span style="COLOR: #000000">    </span><span style="COLOR: #0000ff">this</span><span style="COLOR: #000000">._FinalRun </span><span style="COLOR: #000000">=</span><span style="COLOR: #000000"> </span><span style="COLOR: #0000ff">false</span><span style="COLOR: #000000">;<br /></span><span style="COLOR: #008080"> 18</span> <span style="COLOR: #000000">    </span><span style="COLOR: #0000ff">this</span><span style="COLOR: #000000">.numLoaded </span><span style="COLOR: #000000">=</span><span style="COLOR: #000000"> </span><span style="COLOR: #000000">0</span><span style="COLOR: #000000">;<br /></span><span style="COLOR: #008080"> 19</span> <span style="COLOR: #000000">    </span><span style="COLOR: #0000ff">this</span><span style="COLOR: #000000">.ClassName </span><span style="COLOR: #000000">=</span><span style="COLOR: #000000"> className;<br /></span><span style="COLOR: #008080"> 20</span> <span style="COLOR: #000000">    <br /></span><span style="COLOR: #008080"> 21</span> <span style="COLOR: #000000">    </span><span style="COLOR: #0000ff">if</span><span style="COLOR: #000000">(</span><span style="COLOR: #0000ff">typeof</span><span style="COLOR: #000000">(Options)</span><span style="COLOR: #000000">==</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">undefined</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">) Options </span><span style="COLOR: #000000">=</span><span style="COLOR: #000000"> {};<br /></span><span style="COLOR: #008080"> 22</span> <span style="COLOR: #000000">    <br /></span><span style="COLOR: #008080"> 23</span> <span style="COLOR: #000000">    </span><span style="COLOR: #0000ff">if</span><span style="COLOR: #000000">(isNaN(Options.Timeout) </span><span style="COLOR: #000000">||</span><span style="COLOR: #000000"> Options.Timeout </span><span style="COLOR: #000000">&lt;</span><span style="COLOR: #000000"> </span><span style="COLOR: #000000">0</span><span style="COLOR: #000000"> </span><span style="COLOR: #000000">||</span><span style="COLOR: #000000">  Options.Timeout </span><span style="COLOR: #000000">&gt;</span><span style="COLOR: #000000">100000</span><span style="COLOR: #000000">){<br /></span><span style="COLOR: #008080"> 24</span> <span style="COLOR: #000000">        </span><span style="COLOR: #0000ff">this</span><span style="COLOR: #000000">.EnableTimeout </span><span style="COLOR: #000000">=</span><span style="COLOR: #000000"> </span><span style="COLOR: #0000ff">false</span><span style="COLOR: #000000">;<br /></span><span style="COLOR: #008080"> 25</span> <span style="COLOR: #000000">    }</span><span style="COLOR: #0000ff">else</span><span style="COLOR: #000000"> {<br /></span><span style="COLOR: #008080"> 26</span> <span style="COLOR: #000000">        </span><span style="COLOR: #0000ff">this</span><span style="COLOR: #000000">.EnableTimeout </span><span style="COLOR: #000000">=</span><span style="COLOR: #000000"> </span><span style="COLOR: #0000ff">true</span><span style="COLOR: #000000">;<br /></span><span style="COLOR: #008080"> 27</span> <span style="COLOR: #000000">        </span><span style="COLOR: #0000ff">this</span><span style="COLOR: #000000">.Timeout </span><span style="COLOR: #000000">=</span><span style="COLOR: #000000"> Options.Timeout;<br /></span><span style="COLOR: #008080"> 28</span> <span style="COLOR: #000000">    }<br /></span><span style="COLOR: #008080"> 29</span> <span style="COLOR: #000000">    <br /></span><span style="COLOR: #008080"> 30</span> <span style="COLOR: #000000">    </span><span style="COLOR: #0000ff">if</span><span style="COLOR: #000000">(</span><span style="COLOR: #0000ff">typeof</span><span style="COLOR: #000000">(Options.func)</span><span style="COLOR: #000000">==</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">undefined</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">){<br /></span><span style="COLOR: #008080"> 31</span> <span style="COLOR: #000000">        </span><span style="COLOR: #0000ff">this</span><span style="COLOR: #000000">.AfterFunction </span><span style="COLOR: #000000">=</span><span style="COLOR: #000000"> </span><span style="COLOR: #0000ff">null</span><span style="COLOR: #000000">;<br /></span><span style="COLOR: #008080"> 32</span> <span style="COLOR: #000000">    }</span><span style="COLOR: #0000ff">else</span><span style="COLOR: #000000">{<br /></span><span style="COLOR: #008080"> 33</span> <span style="COLOR: #000000">        </span><span style="COLOR: #0000ff">this</span><span style="COLOR: #000000">.AfterFunction </span><span style="COLOR: #000000">=</span><span style="COLOR: #000000"> Options.func;<br /></span><span style="COLOR: #008080"> 34</span> <span style="COLOR: #000000">    }<br /></span><span style="COLOR: #008080"> 35</span> <span style="COLOR: #000000">    <br /></span><span style="COLOR: #008080"> 36</span> <span style="COLOR: #000000">    </span><span style="COLOR: #0000ff">if</span><span style="COLOR: #000000">(</span><span style="COLOR: #0000ff">typeof</span><span style="COLOR: #000000">(Options.display)</span><span style="COLOR: #000000">==</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">undefined</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">){<br /></span><span style="COLOR: #008080"> 37</span> <span style="COLOR: #000000">        </span><span style="COLOR: #0000ff">this</span><span style="COLOR: #000000">.disDiv </span><span style="COLOR: #000000">=</span><span style="COLOR: #000000"> </span><span style="COLOR: #0000ff">null</span><span style="COLOR: #000000">;<br /></span><span style="COLOR: #008080"> 38</span> <span style="COLOR: #000000">    }</span><span style="COLOR: #0000ff">else</span><span style="COLOR: #000000"> </span><span style="COLOR: #0000ff">if</span><span style="COLOR: #000000">(</span><span style="COLOR: #0000ff">typeof</span><span style="COLOR: #000000">(Options.display)</span><span style="COLOR: #000000">==</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">string</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">){<br /></span><span style="COLOR: #008080"> 39</span> <span style="COLOR: #000000">        </span><span style="COLOR: #0000ff">this</span><span style="COLOR: #000000">.disDiv </span><span style="COLOR: #000000">=</span><span style="COLOR: #000000"> document.getElementById(Options.display);<br /></span><span style="COLOR: #008080"> 40</span> <span style="COLOR: #000000">    }</span><span style="COLOR: #0000ff">else</span><span style="COLOR: #000000"> </span><span style="COLOR: #0000ff">if</span><span style="COLOR: #000000">(</span><span style="COLOR: #0000ff">typeof</span><span style="COLOR: #000000">(Options.display)</span><span style="COLOR: #000000">==</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">object</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">){<br /></span><span style="COLOR: #008080"> 41</span> <span style="COLOR: #000000">        </span><span style="COLOR: #0000ff">this</span><span style="COLOR: #000000">.disDiv </span><span style="COLOR: #000000">=</span><span style="COLOR: #000000"> Options.display;<br /></span><span style="COLOR: #008080"> 42</span> <span style="COLOR: #000000">    }</span><span style="COLOR: #0000ff">else</span><span style="COLOR: #000000">{<br /></span><span style="COLOR: #008080"> 43</span> <span style="COLOR: #000000">        </span><span style="COLOR: #0000ff">this</span><span style="COLOR: #000000">.disDiv </span><span style="COLOR: #000000">=</span><span style="COLOR: #000000"> </span><span style="COLOR: #0000ff">null</span><span style="COLOR: #000000">;<br /></span><span style="COLOR: #008080"> 44</span> <span style="COLOR: #000000">    }<br /></span><span style="COLOR: #008080"> 45</span> <span style="COLOR: #000000"><br /></span><span style="COLOR: #008080"> 46</span> <span style="COLOR: #000000">    </span><span style="COLOR: #0000ff">if</span><span style="COLOR: #000000">(</span><span style="COLOR: #0000ff">typeof</span><span style="COLOR: #000000">(Options.process)</span><span style="COLOR: #000000">==</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">undefined</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">){<br /></span><span style="COLOR: #008080"> 47</span> <span style="COLOR: #000000">        </span><span style="COLOR: #0000ff">this</span><span style="COLOR: #000000">.procDiv </span><span style="COLOR: #000000">=</span><span style="COLOR: #000000"> </span><span style="COLOR: #0000ff">null</span><span style="COLOR: #000000">;<br /></span><span style="COLOR: #008080"> 48</span> <span style="COLOR: #000000">    }</span><span style="COLOR: #0000ff">else</span><span style="COLOR: #000000"> </span><span style="COLOR: #0000ff">if</span><span style="COLOR: #000000">(</span><span style="COLOR: #0000ff">typeof</span><span style="COLOR: #000000">(Options.process)</span><span style="COLOR: #000000">==</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">string</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">){<br /></span><span style="COLOR: #008080"> 49</span> <span style="COLOR: #000000">        </span><span style="COLOR: #0000ff">this</span><span style="COLOR: #000000">.procDiv </span><span style="COLOR: #000000">=</span><span style="COLOR: #000000"> document.getElementById(Options.process);<br /></span><span style="COLOR: #008080"> 50</span> <span style="COLOR: #000000">    }</span><span style="COLOR: #0000ff">else</span><span style="COLOR: #000000"> </span><span style="COLOR: #0000ff">if</span><span style="COLOR: #000000">(</span><span style="COLOR: #0000ff">typeof</span><span style="COLOR: #000000">(Options.process)</span><span style="COLOR: #000000">==</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">object</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">){<br /></span><span style="COLOR: #008080"> 51</span> <span style="COLOR: #000000">        </span><span style="COLOR: #0000ff">this</span><span style="COLOR: #000000">.procDiv </span><span style="COLOR: #000000">=</span><span style="COLOR: #000000"> Options.process;<br /></span><span style="COLOR: #008080"> 52</span> <span style="COLOR: #000000">    }</span><span style="COLOR: #0000ff">else</span><span style="COLOR: #000000">{<br /></span><span style="COLOR: #008080"> 53</span> <span style="COLOR: #000000">        </span><span style="COLOR: #0000ff">this</span><span style="COLOR: #000000">.procDiv </span><span style="COLOR: #000000">=</span><span style="COLOR: #000000"> </span><span style="COLOR: #0000ff">null</span><span style="COLOR: #000000">;<br /></span><span style="COLOR: #008080"> 54</span> <span style="COLOR: #000000">    }<br /></span><span style="COLOR: #008080"> 55</span> <span style="COLOR: #000000"><br /></span><span style="COLOR: #008080"> 56</span> <span style="COLOR: #000000">    <br /></span><span style="COLOR: #008080"> 57</span> <span style="COLOR: #000000">    </span><span style="COLOR: #0000ff">if</span><span style="COLOR: #000000">(</span><span style="COLOR: #0000ff">typeof</span><span style="COLOR: #000000">(document.imageArray)</span><span style="COLOR: #000000">==</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">undefined</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">) document.imageArray </span><span style="COLOR: #000000">=</span><span style="COLOR: #000000"> </span><span style="COLOR: #0000ff">new</span><span style="COLOR: #000000"> Array();<br /></span><span style="COLOR: #008080"> 58</span> <span style="COLOR: #000000">    <br /></span><span style="COLOR: #008080"> 59</span> <span style="COLOR: #000000">    </span><span style="COLOR: #0000ff">this</span><span style="COLOR: #000000">.Load </span><span style="COLOR: #000000">=</span><span style="COLOR: #000000"> </span><span style="COLOR: #0000ff">function</span><span style="COLOR: #000000">(){<br /></span><span style="COLOR: #008080"> 60</span> <span style="COLOR: #000000">        </span><span style="COLOR: #0000ff">var</span><span style="COLOR: #000000"> args </span><span style="COLOR: #000000">=</span><span style="COLOR: #000000"> </span><span style="COLOR: #0000ff">this</span><span style="COLOR: #000000">.Load.arguments;<br /></span><span style="COLOR: #008080"> 61</span> <span style="COLOR: #000000">        </span><span style="COLOR: #0000ff">if</span><span style="COLOR: #000000">(args.length</span><span style="COLOR: #000000">!=</span><span style="COLOR: #000000">0</span><span style="COLOR: #000000">){<br /></span><span style="COLOR: #008080"> 62</span> <span style="COLOR: #000000">            </span><span style="COLOR: #0000ff">this</span><span style="COLOR: #000000">._ImageLoadStack </span><span style="COLOR: #000000">=</span><span style="COLOR: #000000"> </span><span style="COLOR: #0000ff">new</span><span style="COLOR: #000000"> Array();<br /></span><span style="COLOR: #008080"> 63</span> <span style="COLOR: #000000">            </span><span style="COLOR: #0000ff">for</span><span style="COLOR: #000000">(i</span><span style="COLOR: #000000">=</span><span style="COLOR: #000000">0</span><span style="COLOR: #000000">; i</span><span style="COLOR: #000000">&lt;</span><span style="COLOR: #000000">args.length; i</span><span style="COLOR: #000000">++</span><span style="COLOR: #000000">){<br /></span><span style="COLOR: #008080"> 64</span> <span style="COLOR: #000000">                </span><span style="COLOR: #0000ff">if</span><span style="COLOR: #000000">(args[i].indexOf(</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">#</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">)</span><span style="COLOR: #000000">!=</span><span style="COLOR: #000000">0</span><span style="COLOR: #000000">){<br /></span><span style="COLOR: #008080"> 65</span> <span style="COLOR: #000000">                    </span><span style="COLOR: #0000ff">this</span><span style="COLOR: #000000">._ImageLoadStack.push(args[i]);<br /></span><span style="COLOR: #008080"> 66</span> <span style="COLOR: #000000">                }<br /></span><span style="COLOR: #008080"> 67</span> <span style="COLOR: #000000">            }<br /></span><span style="COLOR: #008080"> 68</span> <span style="COLOR: #000000"><br /></span><span style="COLOR: #008080"> 69</span> <span style="COLOR: #000000">        }</span><span style="COLOR: #0000ff">else</span><span style="COLOR: #000000"> </span><span style="COLOR: #0000ff">if</span><span style="COLOR: #000000">(</span><span style="COLOR: #0000ff">this</span><span style="COLOR: #000000">._ImageLoadStack </span><span style="COLOR: #000000">==</span><span style="COLOR: #000000"> </span><span style="COLOR: #0000ff">null</span><span style="COLOR: #000000">){<br /></span><span style="COLOR: #008080"> 70</span> <span style="COLOR: #000000">            </span><span style="COLOR: #0000ff">this</span><span style="COLOR: #000000">._runFinal();<br /></span><span style="COLOR: #008080"> 71</span> <span style="COLOR: #000000">        }<br /></span><span style="COLOR: #008080"> 72</span> <span style="COLOR: #000000">        </span><span style="COLOR: #0000ff">this</span><span style="COLOR: #000000">.numTotal </span><span style="COLOR: #000000">=</span><span style="COLOR: #000000"> </span><span style="COLOR: #0000ff">this</span><span style="COLOR: #000000">._ImageLoadStack.length;<br /></span><span style="COLOR: #008080"> 73</span> <span style="COLOR: #000000">        </span><span style="COLOR: #0000ff">this</span><span style="COLOR: #000000">._LoadAImage();<br /></span><span style="COLOR: #008080"> 74</span> <span style="COLOR: #000000">    }<br /></span><span style="COLOR: #008080"> 75</span> <span style="COLOR: #000000">    <br /></span><span style="COLOR: #008080"> 76</span> <span style="COLOR: #000000">    </span><span style="COLOR: #0000ff">this</span><span style="COLOR: #000000">._LoadAImage </span><span style="COLOR: #000000">=</span><span style="COLOR: #000000"> </span><span style="COLOR: #0000ff">function</span><span style="COLOR: #000000">(){<br /></span><span style="COLOR: #008080"> 77</span> <span style="COLOR: #000000">        </span><span style="COLOR: #0000ff">if</span><span style="COLOR: #000000">(</span><span style="COLOR: #0000ff">this</span><span style="COLOR: #000000">._ImageLoadStack.length</span><span style="COLOR: #000000">!=</span><span style="COLOR: #000000">0</span><span style="COLOR: #000000">){<br /></span><span style="COLOR: #008080"> 78</span> <span style="COLOR: #000000">            </span><span style="COLOR: #0000ff">var</span><span style="COLOR: #000000"> sURL </span><span style="COLOR: #000000">=</span><span style="COLOR: #000000"> </span><span style="COLOR: #0000ff">this</span><span style="COLOR: #000000">._ImageLoadStack.shift();<br /></span><span style="COLOR: #008080"> 79</span> <span style="COLOR: #000000">            </span><span style="COLOR: #0000ff">if</span><span style="COLOR: #000000">(</span><span style="COLOR: #0000ff">this</span><span style="COLOR: #000000">.disDiv</span><span style="COLOR: #000000">!=</span><span style="COLOR: #0000ff">null</span><span style="COLOR: #000000">) </span><span style="COLOR: #0000ff">this</span><span style="COLOR: #000000">.disDiv.innerHTML </span><span style="COLOR: #000000">=</span><span style="COLOR: #000000"> sURL;<br /></span><span style="COLOR: #008080"> 80</span> <span style="COLOR: #000000">            _currrentLoading </span><span style="COLOR: #000000">=</span><span style="COLOR: #000000"> sURL;<br /></span><span style="COLOR: #008080"> 81</span> <span style="COLOR: #000000">        <br /></span><span style="COLOR: #008080"> 82</span> <span style="COLOR: #000000">            <br /></span><span style="COLOR: #008080"> 83</span> <span style="COLOR: #000000">            </span><span style="COLOR: #0000ff">var</span><span style="COLOR: #000000"> j </span><span style="COLOR: #000000">=</span><span style="COLOR: #000000"> document.imageArray.length;<br /></span><span style="COLOR: #008080"> 84</span> <span style="COLOR: #000000">            document.imageArray[j] </span><span style="COLOR: #000000">=</span><span style="COLOR: #000000"> document.createElement(</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">IMG</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">);<br /></span><span style="COLOR: #008080"> 85</span> <span style="COLOR: #000000">            document.imageArray[j].Owner </span><span style="COLOR: #000000">=</span><span style="COLOR: #000000"> </span><span style="COLOR: #0000ff">this</span><span style="COLOR: #000000">;<br /></span><span style="COLOR: #008080"> 86</span> <span style="COLOR: #000000">            <br /></span><span style="COLOR: #008080"> 87</span> <span style="COLOR: #000000">            document.imageArray[j].onload </span><span style="COLOR: #000000">=</span><span style="COLOR: #000000"> </span><span style="COLOR: #0000ff">function</span><span style="COLOR: #000000">(){<br /></span><span style="COLOR: #008080"> 88</span> <span style="COLOR: #000000">                </span><span style="COLOR: #0000ff">this</span><span style="COLOR: #000000">.Owner._LoadAImage();<br /></span><span style="COLOR: #008080"> 89</span> <span style="COLOR: #000000">                </span><span style="COLOR: #0000ff">this</span><span style="COLOR: #000000">.onload </span><span style="COLOR: #000000">=</span><span style="COLOR: #000000"> </span><span style="COLOR: #0000ff">null</span><span style="COLOR: #000000">;<br /></span><span style="COLOR: #008080"> 90</span> <span style="COLOR: #000000">            }<br /></span><span style="COLOR: #008080"> 91</span> <span style="COLOR: #000000">            document.imageArray[j].onerror </span><span style="COLOR: #000000">=</span><span style="COLOR: #000000"> </span><span style="COLOR: #0000ff">function</span><span style="COLOR: #000000">(){<br /></span><span style="COLOR: #008080"> 92</span> <span style="COLOR: #000000">                </span><span style="COLOR: #0000ff">this</span><span style="COLOR: #000000">.Owner._LoadAImage();<br /></span><span style="COLOR: #008080"> 93</span> <span style="COLOR: #000000">                </span><span style="COLOR: #0000ff">this</span><span style="COLOR: #000000">.onload </span><span style="COLOR: #000000">=</span><span style="COLOR: #000000"> </span><span style="COLOR: #0000ff">null</span><span style="COLOR: #000000">;<br /></span><span style="COLOR: #008080"> 94</span> <span style="COLOR: #000000">            }<br /></span><span style="COLOR: #008080"> 95</span> <span style="COLOR: #000000">            <br /></span><span style="COLOR: #008080"> 96</span> <span style="COLOR: #000000">            </span><span style="COLOR: #0000ff">if</span><span style="COLOR: #000000">(</span><span style="COLOR: #0000ff">this</span><span style="COLOR: #000000">.EnableTimeout){<br /></span><span style="COLOR: #008080"> 97</span> <span style="COLOR: #000000">                window.setTimeout(</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">if(_currrentLoading==\</span><span style="COLOR: #000000">""</span><span style="COLOR: #000000">+sURL+</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">\</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">){</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">+</span><span style="COLOR: #0000ff">this</span><span style="COLOR: #000000">.ClassName</span><span style="COLOR: #000000">+</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">._LoadAImage()}</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">,</span><span style="COLOR: #0000ff">this</span><span style="COLOR: #000000">.Timeout);<br /></span><span style="COLOR: #008080"> 98</span> <span style="COLOR: #000000">            }<br /></span><span style="COLOR: #008080"> 99</span> <span style="COLOR: #000000">    <br /></span><span style="COLOR: #008080">100</span> <span style="COLOR: #000000">            document.imageArray[j</span><span style="COLOR: #000000">++</span><span style="COLOR: #000000">].src </span><span style="COLOR: #000000">=</span><span style="COLOR: #000000"> sURL;<br /></span><span style="COLOR: #008080">101</span> <span style="COLOR: #000000">                </span><span style="COLOR: #0000ff">if</span><span style="COLOR: #000000">(</span><span style="COLOR: #0000ff">this</span><span style="COLOR: #000000">.procDiv</span><span style="COLOR: #000000">!=</span><span style="COLOR: #0000ff">null</span><span style="COLOR: #000000">){<br /></span><span style="COLOR: #008080">102</span> <span style="COLOR: #000000">                </span><span style="COLOR: #0000ff">this</span><span style="COLOR: #000000">.numLoaded</span><span style="COLOR: #000000">++</span><span style="COLOR: #000000">;<br /></span><span style="COLOR: #008080">103</span> <span style="COLOR: #000000">                </span><span style="COLOR: #0000ff">var</span><span style="COLOR: #000000"> percentage </span><span style="COLOR: #000000">=</span><span style="COLOR: #000000"> Math.floor(</span><span style="COLOR: #0000ff">this</span><span style="COLOR: #000000">.numLoaded </span><span style="COLOR: #000000">*</span><span style="COLOR: #000000"> </span><span style="COLOR: #000000">100</span><span style="COLOR: #000000"> </span><span style="COLOR: #000000">/</span><span style="COLOR: #000000"> </span><span style="COLOR: #0000ff">this</span><span style="COLOR: #000000">.numTotal);<br /></span><span style="COLOR: #008080">104</span> <span style="COLOR: #000000">                </span><span style="COLOR: #0000ff">this</span><span style="COLOR: #000000">.procDiv.innerHTML </span><span style="COLOR: #000000">=</span><span style="COLOR: #000000"> percentage;<br /></span><span style="COLOR: #008080">105</span> <span style="COLOR: #000000">            }<br /></span><span style="COLOR: #008080">106</span> <span style="COLOR: #000000"><br /></span><span style="COLOR: #008080">107</span> <span style="COLOR: #000000">        }</span><span style="COLOR: #0000ff">else</span><span style="COLOR: #000000">{<br /></span><span style="COLOR: #008080">108</span> <span style="COLOR: #000000">            </span><span style="COLOR: #0000ff">this</span><span style="COLOR: #000000">._runFinal();<br /></span><span style="COLOR: #008080">109</span> <span style="COLOR: #000000">        }<br /></span><span style="COLOR: #008080">110</span> <span style="COLOR: #000000"><br /></span><span style="COLOR: #008080">111</span> <span style="COLOR: #000000">    }<br /></span><span style="COLOR: #008080">112</span> <span style="COLOR: #000000">    </span><span style="COLOR: #0000ff">this</span><span style="COLOR: #000000">._runFinal </span><span style="COLOR: #000000">=</span><span style="COLOR: #000000"> </span><span style="COLOR: #0000ff">function</span><span style="COLOR: #000000">(){<br /></span><span style="COLOR: #008080">113</span> <span style="COLOR: #000000">            </span><span style="COLOR: #0000ff">if</span><span style="COLOR: #000000">(</span><span style="COLOR: #0000ff">this</span><span style="COLOR: #000000">._FinalRun </span><span style="COLOR: #000000">==</span><span style="COLOR: #000000"> </span><span style="COLOR: #0000ff">false</span><span style="COLOR: #000000">){<br /></span><span style="COLOR: #008080">114</span> <span style="COLOR: #000000">                </span><span style="COLOR: #0000ff">this</span><span style="COLOR: #000000">._FinalRun </span><span style="COLOR: #000000">=</span><span style="COLOR: #000000"> </span><span style="COLOR: #0000ff">true</span><span style="COLOR: #000000">;<br /></span><span style="COLOR: #008080">115</span> <span style="COLOR: #000000">                <br /></span><span style="COLOR: #008080">116</span> <span style="COLOR: #000000">                </span><span style="COLOR: #0000ff">if</span><span style="COLOR: #000000">(</span><span style="COLOR: #0000ff">typeof</span><span style="COLOR: #000000">(</span><span style="COLOR: #0000ff">this</span><span style="COLOR: #000000">.AfterFunction)</span><span style="COLOR: #000000">==</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">function</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">){<br /></span><span style="COLOR: #008080">117</span> <span style="COLOR: #000000">                    </span><span style="COLOR: #0000ff">this</span><span style="COLOR: #000000">.AfterFunction();<br /></span><span style="COLOR: #008080">118</span> <span style="COLOR: #000000">                }</span><span style="COLOR: #0000ff">else</span><span style="COLOR: #000000"> </span><span style="COLOR: #0000ff">if</span><span style="COLOR: #000000">(</span><span style="COLOR: #0000ff">typeof</span><span style="COLOR: #000000">(</span><span style="COLOR: #0000ff">this</span><span style="COLOR: #000000">.AfterFunction)</span><span style="COLOR: #000000">==</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">string</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">){<br /></span><span style="COLOR: #008080">119</span> <span style="COLOR: #000000">                    </span><span style="COLOR: #0000ff">if</span><span style="COLOR: #000000"> (window.execScript){<br /></span><span style="COLOR: #008080">120</span> <span style="COLOR: #000000">                        window.execScript(</span><span style="COLOR: #0000ff">this</span><span style="COLOR: #000000">.AfterFunction);<br /></span><span style="COLOR: #008080">121</span> <span style="COLOR: #000000">                    }</span><span style="COLOR: #0000ff">else</span><span style="COLOR: #000000">{<br /></span><span style="COLOR: #008080">122</span> <span style="COLOR: #000000">                        window.eval(</span><span style="COLOR: #0000ff">this</span><span style="COLOR: #000000">.AfterFunction); <br /></span><span style="COLOR: #008080">123</span> <span style="COLOR: #000000">                    }<br /></span><span style="COLOR: #008080">124</span> <span style="COLOR: #000000">                }<br /></span><span style="COLOR: #008080">125</span> <span style="COLOR: #000000">            }<br /></span><span style="COLOR: #008080">126</span> <span style="COLOR: #000000">    }<br /></span><span style="COLOR: #008080">127</span> <span style="COLOR: #000000">    </span><span style="COLOR: #0000ff">this</span><span style="COLOR: #000000">.setLoadImages </span><span style="COLOR: #000000">=</span><span style="COLOR: #000000"> </span><span style="COLOR: #0000ff">function</span><span style="COLOR: #000000">(imageArray){<br /></span><span style="COLOR: #008080">128</span> <span style="COLOR: #000000">        </span><span style="COLOR: #0000ff">if</span><span style="COLOR: #000000">(</span><span style="COLOR: #0000ff">typeof</span><span style="COLOR: #000000">(imageArray)</span><span style="COLOR: #000000">!=</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">object</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">) </span><span style="COLOR: #0000ff">return</span><span style="COLOR: #000000">;<br /></span><span style="COLOR: #008080">129</span> <span style="COLOR: #000000">        </span><span style="COLOR: #0000ff">this</span><span style="COLOR: #000000">._ImageLoadStack </span><span style="COLOR: #000000">=</span><span style="COLOR: #000000"> imageArray;<br /></span><span style="COLOR: #008080">130</span> <span style="COLOR: #000000">    }<br /></span><span style="COLOR: #008080">131</span> <span style="COLOR: #000000"><br /></span><span style="COLOR: #008080">132</span> <span style="COLOR: #000000">}</span><span style="COLOR: #000000">&lt;/</span><span style="COLOR: #000000">script</span><span style="COLOR: #000000">&gt;</span><span style="COLOR: #000000"><br /></span><span style="COLOR: #008080">133</span> <span style="COLOR: #000000"></span><span style="COLOR: #000000">&lt;</span><span style="COLOR: #000000">div id</span><span style="COLOR: #000000">=</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">display</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">&gt;&lt;/</span><span style="COLOR: #000000">div</span><span style="COLOR: #000000">&gt;</span><span style="COLOR: #000000"><br /></span><span style="COLOR: #008080">134</span> <span style="COLOR: #000000"></span><span style="COLOR: #000000">&lt;</span><span style="COLOR: #000000">div id</span><span style="COLOR: #000000">=</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">process</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">&gt;&lt;/</span><span style="COLOR: #000000">div</span><span style="COLOR: #000000">&gt;</span><span style="COLOR: #000000"><br /></span><span style="COLOR: #008080">135</span> <span style="COLOR: #000000"></span><span style="COLOR: #000000">&lt;</span><span style="COLOR: #000000">div id</span><span style="COLOR: #000000">=</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">result</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">&gt;&lt;/</span><span style="COLOR: #000000">div</span><span style="COLOR: #000000">&gt;</span><span style="COLOR: #000000"><br /></span><span style="COLOR: #008080">136</span> <span style="COLOR: #000000"></span><span style="COLOR: #000000">&lt;/</span><span style="COLOR: #000000">body</span><span style="COLOR: #000000">&gt;</span><span style="COLOR: #000000"><br /></span><span style="COLOR: #008080">137</span> <span style="COLOR: #000000"><br /></span><span style="COLOR: #008080">138</span> <span style="COLOR: #000000"></span><span style="COLOR: #000000">&lt;</span><span style="COLOR: #000000">script</span><span style="COLOR: #000000">&gt;</span><span style="COLOR: #000000"><br /></span><span style="COLOR: #008080">139</span> <span style="COLOR: #000000"></span><span style="COLOR: #0000ff">function</span><span style="COLOR: #000000"> final(){<br /></span><span style="COLOR: #008080">140</span> <span style="COLOR: #000000">    $(</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">result</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">).innerHTML</span><span style="COLOR: #000000">=</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">OK</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">;<br /></span><span style="COLOR: #008080">141</span> <span style="COLOR: #000000">};<br /></span><span style="COLOR: #008080">142</span> <span style="COLOR: #000000"><br /></span><span style="COLOR: #008080">143</span> <span style="COLOR: #000000"></span><span style="COLOR: #0000ff">function</span><span style="COLOR: #000000"> $(par){<br /></span><span style="COLOR: #008080">144</span> <span style="COLOR: #000000">    </span><span style="COLOR: #0000ff">return</span><span style="COLOR: #000000"> document.getElementById(par)<br /></span><span style="COLOR: #008080">145</span> <span style="COLOR: #000000">}<br /></span><span style="COLOR: #008080">146</span> <span style="COLOR: #000000"><br /></span><span style="COLOR: #008080">147</span> <span style="COLOR: #000000"> </span><span style="COLOR: #0000ff">var</span><span style="COLOR: #000000"> loader </span><span style="COLOR: #000000">=</span><span style="COLOR: #000000"> </span><span style="COLOR: #0000ff">new</span><span style="COLOR: #000000"> ImageLoader(</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">loader</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">,{Timeout:</span><span style="COLOR: #000000">-</span><span style="COLOR: #000000">1</span><span style="COLOR: #000000">,func: final,display:</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">display</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">,process:$(</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">process</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">)});<br /></span><span style="COLOR: #008080">148</span> <span style="COLOR: #000000"> <br /></span><span style="COLOR: #008080">149</span> <span style="COLOR: #000000"> <br /></span><span style="COLOR: #008080">150</span> <span style="COLOR: #000000"> loader.Load(</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">http://bbs.blueidea.com/images/blue/logo.gif</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">,<br /></span><span style="COLOR: #008080">151</span> <span style="COLOR: #000000">             </span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">http://gg.blueidea.com/2006/chinaok/208x32.gif</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">,<br /></span><span style="COLOR: #008080">152</span> <span style="COLOR: #000000">            </span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">http://gg.blueidea.com/2006/now/208x32.gif</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">,<br /></span><span style="COLOR: #008080">153</span> <span style="COLOR: #000000">            </span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">http://gg.blueidea.com/2006/gongyi/banner.jpg</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">,<br /></span><span style="COLOR: #008080">154</span> <span style="COLOR: #000000">            </span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">http://gg.blueidea.com/2006/flash8/pepsi.gif</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">,<br /></span><span style="COLOR: #008080">155</span> <span style="COLOR: #000000">            </span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">http://www.google.com/intl/zh-CN_ALL/images/logo.gif</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">);<br /></span><span style="COLOR: #008080">156</span> <span style="COLOR: #000000"></span><span style="COLOR: #000000">&lt;/</span><span style="COLOR: #000000">script</span><span style="COLOR: #000000">&gt;</span></div></strong></div><img src ="http://www.cnitblog.com/asfman/aggbug/17975.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cnitblog.com/asfman/" target="_blank">汪杰</a> 2006-10-14 16:16 <a href="http://www.cnitblog.com/asfman/articles/17975.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>css</title><link>http://www.cnitblog.com/asfman/articles/17934.html</link><dc:creator>汪杰</dc:creator><author>汪杰</author><pubDate>Fri, 13 Oct 2006 04:57:00 GMT</pubDate><guid>http://www.cnitblog.com/asfman/articles/17934.html</guid><wfw:comment>http://www.cnitblog.com/asfman/comments/17934.html</wfw:comment><comments>http://www.cnitblog.com/asfman/articles/17934.html#Feedback</comments><slash:comments>1</slash:comments><wfw:commentRss>http://www.cnitblog.com/asfman/comments/commentRss/17934.html</wfw:commentRss><trackback:ping>http://www.cnitblog.com/asfman/services/trackbacks/17934.html</trackback:ping><description><![CDATA[@charset "gb2312";<br />/* PR css 全局设置 */<br />* {font:12px "Arial","宋体","Tahoma","QQ 50198763",sans-serif;}/*12px大，字体优先：Arial,然后:宋体,Tahoma,族科:sans-serif*/<br />html,body {height:100%;}/*设置浏览器高度为100%*/<br />body,form,menu,dir,fieldset,blockquote,p,pre,ul,ol,dl,dd,h1,h2,h3,h4,h5,h6 {padding:0;margin:0;}/*设置body,form,menu,dir,fieldset,blockquote,p,pre,ul,ol,dl,dd,h1,h2,h3,h4,h5,h6内外补丁为0*/<br />div,p {display:block;}/*所有div,p为块元素*/<br />ul,ol,dl {list-style:none;}/*所有项目符号显示无*/<br />img {border:0;}/*所有图片边框无*/<br />a {text-decoration:none;}/*所有链接无修饰[上,下划线,虚线...]*/<br />a:hover {text-decoration:underline;}/*所有链接鼠标放上时为下划线*/<br />button {cursor:pointer;}/*所有按钮鼠标放上时为手型标志*/<br />/* 全局设置完毕 */ <img src ="http://www.cnitblog.com/asfman/aggbug/17934.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cnitblog.com/asfman/" target="_blank">汪杰</a> 2006-10-13 12:57 <a href="http://www.cnitblog.com/asfman/articles/17934.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>处理responseBody</title><link>http://www.cnitblog.com/asfman/articles/17903.html</link><dc:creator>汪杰</dc:creator><author>汪杰</author><pubDate>Thu, 12 Oct 2006 06:56:00 GMT</pubDate><guid>http://www.cnitblog.com/asfman/articles/17903.html</guid><wfw:comment>http://www.cnitblog.com/asfman/comments/17903.html</wfw:comment><comments>http://www.cnitblog.com/asfman/articles/17903.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cnitblog.com/asfman/comments/commentRss/17903.html</wfw:commentRss><trackback:ping>http://www.cnitblog.com/asfman/services/trackbacks/17903.html</trackback:ping><description><![CDATA[1.vbs<br />Function asfman_BytesToStr(Body,cset)<br />  Dim ADOS<br />  Set ADOS=Server.CreateObject("ADODB.Stream")<br />With ADOS<br />      .Type=1 '1means bytes 2means text<br />      .Mode=3 'in fact,it mustn't been set<br />      .Open<br />      .Write Body<br />      .Position=0 ' move the position to the head<br />      .Type=2<br />      .CharSet=cset<br />asfman_BytesToStr=.ReadText<br />      .Close<br />End with<br />Set ADOS=nothing<br />End Function<br /><br />2.use append and appendchunk<br />function asfman(html) {<br />   var rs=new ActiveXObject("ADODB.Recordset");<br />   rs.Fields.Append("asfman",201,1);<br />   rs.Open();<br />   rs.AddNew();<br />   rs.fields.item(0).AppendChunk(html);<br />   rs.Update();<br />   temp=rs(0).value;<br />   rs.Close();<br />   delete rs;<br />  return temp;<br />}<br />3.cookie 解码<br />&lt;script language=Vbscript&gt;<br />Function vbChar(str)<br /> vbChar=Chr(str)<br />End Function<br />&lt;/script&gt;<br />&lt;script language=Javascript&gt;<br /> var glbEncode=new Array();<br /> function reCode(str) {<br />  var str=str.replace(/%([A-Z].)%(.{2}))/g,"@$1$2";<br />  var t=str.split("@"),k,l=t.length;<br /> for(var i=0;i&lt;l;i++) {<br />   k=t[i].substring(0,4);<br />  if(!glbEncode[k])<br />  glbEncode[k]=escape(vbChar(eval("0x"+k)));<br /> t[i]=glbEncode[k]+t[i].substring(4);<br /> }<br />str=unescape(t.join(""));<br />return str.match(/%([A-Z].)%(.{2})/g)?reCode(str):str.replace(/\+/g,"&amp;nbsp;");<br />}<br />&lt;/script&gt;<img src ="http://www.cnitblog.com/asfman/aggbug/17903.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cnitblog.com/asfman/" target="_blank">汪杰</a> 2006-10-12 14:56 <a href="http://www.cnitblog.com/asfman/articles/17903.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>pixelHeight</title><link>http://www.cnitblog.com/asfman/articles/17768.html</link><dc:creator>汪杰</dc:creator><author>汪杰</author><pubDate>Mon, 09 Oct 2006 08:26:00 GMT</pubDate><guid>http://www.cnitblog.com/asfman/articles/17768.html</guid><wfw:comment>http://www.cnitblog.com/asfman/comments/17768.html</wfw:comment><comments>http://www.cnitblog.com/asfman/articles/17768.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cnitblog.com/asfman/comments/commentRss/17768.html</wfw:commentRss><trackback:ping>http://www.cnitblog.com/asfman/services/trackbacks/17768.html</trackback:ping><description><![CDATA[
		<p>&lt;style&gt;<br />#content {<br /> font-size: 14px;<br /> width: 200px;<br /> height: 50px;<br /> background: #eee;<br /> padding: 10px;<br /> border: 4px #ccc double;<br /> overflow: hidden;<br />}<br />#key {<br /> color: red;<br /> float: right;<br /> margin-top:-15px;<br /> border:1px #ccc solid;<br /> padding:5px;<br /> cursor:hand;<br />}<br />&lt;/style&gt;<br />&lt;script&gt;<br />var s=5;<br />var minheight=50;<br />var maxheight=350;<br />function shoppingcat(){<br /> var key = document.getElementById("key").innerText;<br /> if(key=="展开"){<br />  content.style.pixelHeight+=s;<br />  if(content.style.pixelHeight&lt;maxheight){<br />   setTimeout("shoppingcat();",1);<br />  }else{<br />   document.getElementById("key").innerText="关闭";<br />  }<br /> }else{<br />  content.style.pixelHeight-=s;<br />  if(content.style.pixelHeight&gt;minheight){<br />   setTimeout("shoppingcat();",1);<br />  }else{<br />   document.getElementById("key").innerText="展开";<br />  }<br /> }<br />}<br />&lt;/script&gt;<br />&lt;div id="content"&gt; <br />孤雁儿<br />&lt;span id="key" onclick="shoppingcat();"&gt;展开&lt;/span&gt;&lt;br&gt;&lt;br&gt;<br />世人作梅词，下笔便俗。予试作一篇，乃知前言不妄耳。&lt;br&gt;&lt;br&gt;<br />藤床纸帐朝眠起，&lt;br&gt; <br />说不尽、无佳思。&lt;br&gt;<br />沈香烟断玉炉寒，&lt;br&gt;<br />伴我情怀如水。&lt;br&gt;<br />笛声三弄，&lt;br&gt;<br />梅心惊破，&lt;br&gt;<br />多少春情意。&lt;br&gt;&lt;br&gt;</p>
		<p>小风疏雨萧萧地，&lt;br&gt;<br />又催下、千行泪。&lt;br&gt;<br />吹箫人去玉楼空，&lt;br&gt; <br />肠断与谁同倚？<br />一枝折得，&lt;br&gt;<br />人间天上，&lt;br&gt;<br />没个人堪寄。<br />&lt;/div&gt;</p>
<img src ="http://www.cnitblog.com/asfman/aggbug/17768.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cnitblog.com/asfman/" target="_blank">汪杰</a> 2006-10-09 16:26 <a href="http://www.cnitblog.com/asfman/articles/17768.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>图片飘飘</title><link>http://www.cnitblog.com/asfman/articles/17765.html</link><dc:creator>汪杰</dc:creator><author>汪杰</author><pubDate>Mon, 09 Oct 2006 07:50:00 GMT</pubDate><guid>http://www.cnitblog.com/asfman/articles/17765.html</guid><wfw:comment>http://www.cnitblog.com/asfman/comments/17765.html</wfw:comment><comments>http://www.cnitblog.com/asfman/articles/17765.html#Feedback</comments><slash:comments>1</slash:comments><wfw:commentRss>http://www.cnitblog.com/asfman/comments/commentRss/17765.html</wfw:commentRss><trackback:ping>http://www.cnitblog.com/asfman/services/trackbacks/17765.html</trackback:ping><description><![CDATA[javascript:R=0; x1=.1; y1=.05; x2=.25; y2=.24; x3=1.6; y3=.24; x4=300; y4=200; x5=300; y5=200; DI=document.images; DIL=DI.length; function A(){for(i=0; i-DIL; i++){DIS=DI[ i ].style; DIS.position='absolute'; DIS.left=Math.sin(R*x1+i*x2+x3)*x4+x5; DIS.top=Math.cos(R*y1+i*y2+y3)*y4+y5}R++}setInterval('A()',5); void(0);<img src ="http://www.cnitblog.com/asfman/aggbug/17765.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cnitblog.com/asfman/" target="_blank">汪杰</a> 2006-10-09 15:50 <a href="http://www.cnitblog.com/asfman/articles/17765.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>滑动层展开效果</title><link>http://www.cnitblog.com/asfman/articles/17756.html</link><dc:creator>汪杰</dc:creator><author>汪杰</author><pubDate>Mon, 09 Oct 2006 03:09:00 GMT</pubDate><guid>http://www.cnitblog.com/asfman/articles/17756.html</guid><wfw:comment>http://www.cnitblog.com/asfman/comments/17756.html</wfw:comment><comments>http://www.cnitblog.com/asfman/articles/17756.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cnitblog.com/asfman/comments/commentRss/17756.html</wfw:commentRss><trackback:ping>http://www.cnitblog.com/asfman/services/trackbacks/17756.html</trackback:ping><description><![CDATA[
		<p>&lt;style&gt;<br />#content {<br /> font-size: 14px;<br /> width: 200px;<br /> height: 50px;<br /> background: #eee;<br /> padding: 10px;<br /> border: 4px #ccc double;<br /> overflow: hidden;<br />}<br />#key {<br /> color: red;<br /> float: right;<br /> margin-top: -20px;<br />}<br />&lt;/style&gt;<br />&lt;script&gt;<br />var s=5;<br />var minheight=50;<br />var maxheight=400;<br />function shoppingcat(){<br /> var key = document.getElementById("key").innerText;<br /> if(key=="展开"){<br />  content.style.pixelHeight+=s;<br />  if(content.style.pixelHeight&lt;maxheight){<br />   setTimeout("shoppingcat();",1);<br />  }else{<br />   document.getElementById("key").innerText="关闭";<br />  }<br /> }else{<br />  content.style.pixelHeight-=s;<br />  if(content.style.pixelHeight&gt;minheight){<br />   setTimeout("shoppingcat();",1);<br />  }else{<br />   document.getElementById("key").innerText="展开";<br />  }<br /> }<br />}<br />&lt;/script&gt;<br />&lt;div id="content"&gt; <br />孤雁儿<br />&lt;span id="key" onclick="shoppingcat();"&gt;展开&lt;/span&gt;&lt;br&gt;&lt;br&gt;<br />世人作梅词，下笔便俗。予试作一篇，乃知前言不妄耳。&lt;br&gt;&lt;br&gt;<br />藤床纸帐朝眠起，&lt;br&gt; <br />说不尽、无佳思。&lt;br&gt;<br />沈香烟断玉炉寒，&lt;br&gt;<br />伴我情怀如水。&lt;br&gt;<br />笛声三弄，&lt;br&gt;<br />梅心惊破，&lt;br&gt;<br />多少春情意。&lt;br&gt;&lt;br&gt;</p>
		<p>小风疏雨萧萧地，&lt;br&gt;<br />又催下、千行泪。&lt;br&gt;<br />吹箫人去玉楼空，&lt;br&gt; <br />肠断与谁同倚？<br />一枝折得，&lt;br&gt;<br />人间天上，&lt;br&gt;<br />没个人堪寄。<br />&lt;/div&gt;</p>
<img src ="http://www.cnitblog.com/asfman/aggbug/17756.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cnitblog.com/asfman/" target="_blank">汪杰</a> 2006-10-09 11:09 <a href="http://www.cnitblog.com/asfman/articles/17756.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>urldecode函数</title><link>http://www.cnitblog.com/asfman/articles/17753.html</link><dc:creator>汪杰</dc:creator><author>汪杰</author><pubDate>Mon, 09 Oct 2006 02:46:00 GMT</pubDate><guid>http://www.cnitblog.com/asfman/articles/17753.html</guid><wfw:comment>http://www.cnitblog.com/asfman/comments/17753.html</wfw:comment><comments>http://www.cnitblog.com/asfman/articles/17753.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cnitblog.com/asfman/comments/commentRss/17753.html</wfw:commentRss><trackback:ping>http://www.cnitblog.com/asfman/services/trackbacks/17753.html</trackback:ping><description><![CDATA[
		<p>asp 里面没有urldecode函数，好象aspx里有吧，我不太清楚，但asp里面还是用得很多。在网上查找了有别人写的urldecode函数，但是这个函数有错误，而且在一些方面写得比较难理解。而且有错误，当里面有生僻双字节文字时就会产生错误，如“乄”经urlencoder后为“%81W”，解码就不能成功。</p>
		<p> 其实双字节编码在这里只要把"W"也编成16进制ASC码就可以。</p>
		<p> 知识点：计算机里的cookie也是经过urlencode编码的，所以urldecode对破解cookie也很有用呵。</p>
		<p> 下面是源代码：</p>
		<p> Function URLDecode(enStr)<br /> dim deStr<br /> dim c,i,v<br /> deStr=""<br /> for i=1 to len(enStr)<br /> c=Mid(enStr,i,1)<br /> if c="%" then<br /> v=eval("&amp;h"+Mid(enStr,i+1,2))<br /> if v&lt;128 then<br /> deStr=deStr&amp;chr(v)<br /> i=i+2<br /> else<br /> if isvalidhex(mid(enstr,i,3)) then<br /> if isvalidhex(mid(enstr,i+3,3)) then<br /> v=eval("&amp;h"+Mid(enStr,i+1,2)+Mid(enStr,i+4,2))<br /> deStr=deStr&amp;chr(v)<br /> i=i+5<br /> else<br /> v=eval("&amp;h"+Mid(enStr,i+1,2)+cstr(hex(asc(Mid(enStr,i+3,1)))))<br /> deStr=deStr&amp;chr(v)<br /> i=i+3<br /> end if<br /> else<br /> destr=destr&amp;c<br /> end if<br /> end if<br /> else<br /> if c="+" then<br /> deStr=deStr&amp;" "<br /> else<br /> deStr=deStr&amp;c<br /> end if<br /> end if<br /> next<br /> URLDecode=deStr<br /> end function</p>
		<p> function isvalidhex(str)<br /> isvalidhex=true<br /> str=ucase(str)<br /> if len(str)&lt;&gt;3 then isvalidhex=false:exit function<br /> if left(str,1)&lt;&gt;"%" then isvalidhex=false:exit function<br /> c=mid(str,2,1)<br /> if not (((c&gt;="0") and (c&lt;="9")) or ((c&gt;="A") and (c&lt;="Z"))) then isvalidhex=false:exit function<br /> c=mid(str,3,1)<br /> if not (((c&gt;="0") and (c&lt;="9")) or ((c&gt;="A") and (c&lt;="Z"))) then isvalidhex=false:exit function<br /> end function</p>
		<p> 你用此方法解码“%81W”看看，可以了。</p>
		<p> 当然，你还可以玩点小段，使之成为自己的一种字符串加密方式。</p>
<img src ="http://www.cnitblog.com/asfman/aggbug/17753.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cnitblog.com/asfman/" target="_blank">汪杰</a> 2006-10-09 10:46 <a href="http://www.cnitblog.com/asfman/articles/17753.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>asp进制转换</title><link>http://www.cnitblog.com/asfman/articles/17752.html</link><dc:creator>汪杰</dc:creator><author>汪杰</author><pubDate>Mon, 09 Oct 2006 02:39:00 GMT</pubDate><guid>http://www.cnitblog.com/asfman/articles/17752.html</guid><wfw:comment>http://www.cnitblog.com/asfman/comments/17752.html</wfw:comment><comments>http://www.cnitblog.com/asfman/articles/17752.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cnitblog.com/asfman/comments/commentRss/17752.html</wfw:commentRss><trackback:ping>http://www.cnitblog.com/asfman/services/trackbacks/17752.html</trackback:ping><description><![CDATA[
		<div>
				<p>&lt;%<br /><strong>1、'UTF转GB---将UTF8编码文字转换为GB编码文字<br /></strong>function UTF2GB(UTFStr) </p>
				<p>for Dig=1 to len(UTFStr) <br /><font color="#0000ff">  '如果UTF8编码文字以%开头则进行转换</font><br />  if mid(UTFStr,Dig,1)="%" then <br />    <font color="#0000ff"> 'UTF8编码文字大于8则转换为汉字</font><br />    if len(UTFStr) &gt;= Dig+8 then <br />       GBStr=GBStr &amp; ConvChinese(mid(UTFStr,Dig,9)) <br />       Dig=Dig+8 <br />    else <br />      GBStr=GBStr &amp; mid(UTFStr,Dig,1) <br />    end if <br />  else <br />     GBStr=GBStr &amp; mid(UTFStr,Dig,1) <br />  end if <br />next <br />UTF2GB=GBStr <br />end function </p>
				<p>
						<font color="#0000ff">'UTF8编码文字将转换为汉字</font>
						<br />function ConvChinese(x) <br />   A=split(mid(x,2),"%") <br />   i=0 <br />   j=0 <br />  for i=0 to ubound(A) <br />     A(i)=c16to2(A(i)) <br />  next <br />  for i=0 to ubound(A)-1 <br />    DigS=instr(A(i),"0") <br />    Unicode="" <br />    for j=1 to DigS-1 <br />      if j=1 then <br />        A(i)=right(A(i),len(A(i))-DigS) <br />        Unicode=Unicode &amp; A(i) <br />      else <br />         i=i+1 <br />         A(i)=right(A(i),len(A(i))-2) <br />         Unicode=Unicode &amp; A(i) <br />      end if <br />    next </p>
				<p>    if len(c2to16(Unicode))=4 then <br />       ConvChinese=ConvChinese &amp; chrw(int("&amp;H" &amp; c2to16(Unicode))) <br />    else <br />       ConvChinese=ConvChinese &amp; chr(int("&amp;H" &amp; c2to16(Unicode))) <br />    end if <br />  next <br />end function </p>
				<p>
						<font color="#0000ff">'二进制代码转换为十六进制代码</font>
						<br />function c2to16(x)<br />   i=1 <br />   for i=1 to len(x) step 4 <br />      c2to16=c2to16 &amp; hex(c2to10(mid(x,i,4))) <br />   next <br />end function </p>
				<p>
						<font color="#0000ff">'二进制代码转换为十进制代码</font>
						<br />function c2to10(x)<br />   c2to10=0 <br />   if x="0" then exit function <br />     i=0 <br />   for i= 0 to len(x) -1 <br />      if mid(x,len(x)-i,1)="1" then c2to10=c2to10+2^(i) <br />   next <br />end function </p>
				<p>
						<font color="#0000ff">'十六进制代码转换为二进制代码<br /></font>function c16to2(x) <br />    i=0 <br />    for i=1 to len(trim(x)) <br />      tempstr= c10to2(cint(int("&amp;h" &amp; mid(x,i,1)))) <br />      do while len(tempstr)&lt;4 <br />         tempstr="0" &amp; tempstr <br />      loop <br />      c16to2=c16to2 &amp; tempstr <br />   next <br />end function </p>
				<p>
						<font color="#0000ff">'十进制代码转换为二进制代码</font>
						<br />function c10to2(x) <br />   mysign=sgn(x) <br />   x=abs(x) <br />   DigS=1 <br />   do <br />      if x&lt;2^DigS then <br />        exit do <br />      else <br />        DigS=DigS+1 <br />      end if <br />   loop <br />   tempnum=x </p>
				<p>   i=0 <br />   for i=DigS to 1 step-1 <br />      if tempnum&gt;=2^(i-1) then <br />         tempnum=tempnum-2^(i-1) <br />         c10to2=c10to2 &amp; "1" <br />      else <br />         c10to2=c10to2 &amp; "0" <br />      end if <br />   next <br />   if mysign=-1 then c10to2="-" &amp; c10to2 <br />end function</p>
				<p>
						<strong>2、'GB转UTF8--将GB编码文字转换为UTF8编码文字</strong>
				</p>
				<p>Function toUTF8(szInput)<br />    Dim wch, uch, szRet<br />    Dim x<br />    Dim nAsc, nAsc2, nAsc3<br /><font color="#0000ff">    '如果输入参数为空，则退出函数</font><br />    If szInput = "" Then<br />        toUTF8 = szInput<br />        Exit Function<br />    End If<br /><font color="#0000ff">    '开始转换</font><br />     For x = 1 To Len(szInput)<br />     <font color="#0000ff">   '利用mid函数分拆GB编码文字</font><br />        wch = Mid(szInput, x, 1)<br />      <font color="#0000ff">  '利用ascW函数返回每一个GB编码文字的Unicode字符代码<br />        '注：asc函数返回的是ANSI 字符代码，注意区别<br /></font>        nAsc = AscW(wch)<br />        If nAsc &lt; 0 Then nAsc = nAsc + 65536<br />    <br />        If (nAsc And &amp;HFF80) = 0 Then<br />            szRet = szRet &amp; wch<br />        Else<br />            If (nAsc And &amp;HF000) = 0 Then<br />                uch = "%" &amp; Hex(((nAsc \ 2 ^ 6)) Or &amp;HC0) &amp; Hex(nAsc And &amp;H3F Or &amp;H80)<br />                szRet = szRet &amp; uch<br />            Else<br />         <font color="#0000ff">      'GB编码文字的Unicode字符代码在0800 - FFFF之间采用三字节模版<br /></font>                uch = "%" &amp; Hex((nAsc \ 2 ^ 12) Or &amp;HE0) &amp; "%" &amp; _<br />                            Hex((nAsc \ 2 ^ 6) And &amp;H3F Or &amp;H80) &amp; "%" &amp; _<br />                            Hex(nAsc And &amp;H3F Or &amp;H80)<br />                szRet = szRet &amp; uch<br />            End If<br />        End If<br />    Next<br />        <br />    toUTF8 = szRet<br />End Function</p>
				<p>
						<strong>3、'GB转unicode---将GB编码文字转换为unicode编码文字</strong>
				</p>
				<p>function chinese2unicode(Str) <br />  dim i <br />  dim Str_one <br />  dim Str_unicode <br />  if(isnull(Str)) then<br />     exit function<br />  end if<br />  for i=1 to len(Str) <br />    Str_one=Mid(Str,i,1) <br />    Str_unicode=Str_unicode&amp;chr(38) <br />    Str_unicode=Str_unicode&amp;chr(35) <br />    Str_unicode=Str_unicode&amp;chr(120) <br />    Str_unicode=Str_unicode&amp; Hex(ascw(Str_one)) <br />    Str_unicode=Str_unicode&amp;chr(59) <br />  next <br />  chinese2unicode=Str_unicode <br />end function   </p>
				<p>
						<strong>4、'URL解码</strong>
						<br />Function URLDecode(enStr)<br />dim deStr<br />dim c,i,v<br />deStr=""<br />for i=1 to len(enStr)<br />  c=Mid(enStr,i,1)<br />  if c="%" then<br />   v=eval("&amp;h"+Mid(enStr,i+1,2))<br />   if v&lt;128 then<br />    deStr=deStr&amp;chr(v)<br />    i=i+2<br />   else<br />    if isvalidhex(mid(enstr,i,3)) then<br />     if isvalidhex(mid(enstr,i+3,3)) then<br />      v=eval("&amp;h"+Mid(enStr,i+1,2)+Mid(enStr,i+4,2))<br />      deStr=deStr&amp;chr(v)<br />      i=i+5<br />     else<br />      v=eval("&amp;h"+Mid(enStr,i+1,2)+cstr(hex(asc(Mid(enStr,i+3,1)))))<br />      deStr=deStr&amp;chr(v)<br />      i=i+3 <br />     end if <br />    else <br />     destr=destr&amp;c<br />    end if<br />   end if<br />  else<br />   if c="+" then<br />    deStr=deStr&amp;" "<br />   else<br />    deStr=deStr&amp;c<br />   end if<br />  end if<br />next<br />URLDecode=deStr<br />end function</p>
				<p>
						<font color="#0000ff">'判断是否为有效的十六进制代码</font>
						<br />function isvalidhex(str)<br />dim c<br />isvalidhex=true<br />str=ucase(str)<br />if len(str)&lt;&gt;3 then isvalidhex=false:exit function<br />if left(str,1)&lt;&gt;"%" then isvalidhex=false:exit function<br />  c=mid(str,2,1)<br />if not (((c&gt;="0") and (c&lt;="9")) or ((c&gt;="A") and (c&lt;="Z"))) then isvalidhex=false:exit function<br />  c=mid(str,3,1)<br />if not (((c&gt;="0") and (c&lt;="9")) or ((c&gt;="A") and (c&lt;="Z"))) then isvalidhex=false:exit function<br />end function<br />%&gt;</p>
		</div>
<img src ="http://www.cnitblog.com/asfman/aggbug/17752.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cnitblog.com/asfman/" target="_blank">汪杰</a> 2006-10-09 10:39 <a href="http://www.cnitblog.com/asfman/articles/17752.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>Ajax技术简介 </title><link>http://www.cnitblog.com/asfman/articles/17426.html</link><dc:creator>汪杰</dc:creator><author>汪杰</author><pubDate>Wed, 27 Sep 2006 17:37:00 GMT</pubDate><guid>http://www.cnitblog.com/asfman/articles/17426.html</guid><wfw:comment>http://www.cnitblog.com/asfman/comments/17426.html</wfw:comment><comments>http://www.cnitblog.com/asfman/articles/17426.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cnitblog.com/asfman/comments/commentRss/17426.html</wfw:commentRss><trackback:ping>http://www.cnitblog.com/asfman/services/trackbacks/17426.html</trackback:ping><description><![CDATA[
		<h3 class="storytitle">
				<a href="http://shuai.bloghome.cn/posts/37117">Ajax技术简介</a>
		</h3>
		<div class="meta">
				<ul class="post-categories">
						<li>
								<a title="学习IT的心得" href="http://shuai.bloghome.cn/post_categories/33889">电脑网络</a>
						</li>
				</ul>作者 jiayishuai @ 2006-07-01 20:14:23 </div>
		<div class="storycontent" id="article_main" style="CLEAR: both">分三步来说明如何使用 Ajax 技术来做开发。<br /><br />一、用 javascript 操作 xmlhttp 对象<br /><br />二、服务器部对xmlhttp请求的响应（PHP范例）<br /><br />三、xmldom 的使用方法<br /><br /><br />那费话少讲，先说第一部份：<br /><br />一、用 javascript 操作 xmlhttp 对象<br /><br />IE7, Mozilla ,Firefox等浏览器中，javascript是内置有 XMLHttpRequest 这个对象的，但IE5+则没有，需要用如下方法来启动：<br />//IE 6<br />try{ xhttp = new ActiveXObject("Msxml2.XMLHTTP");} catch(e){ ; }<br />//IE5+<br />if(xhttp == null) try { xhttp = new ActiveXObject("Microsoft.XMLHTTP");} catch(e){ ; }<br /><br />那考虑不同浏览器的兼容，启动一个xmlhttp一般都要按如下方式：<br /><br /><div class="smalltxt" style="FONT-WEIGHT: bold; MARGIN-LEFT: 2em; MARGIN-RIGHT: 2em"><div style="FLOAT: left">CODE:</div><div style="FLOAT: right; TEXT-ALIGN: right"><a class="smalltxt" onclick="copycode(findobj('code0'));" href="http://www.itdoor.org/viewthread.php?tid=1774&amp;extra=page%3D1#">[Copy to clipboard]</a></div></div><div class="altbg2" id="code0" style="CLEAR: both; BORDER-RIGHT: #476797 1px solid; PADDING-RIGHT: 10px; BORDER-TOP: #476797 1px solid; PADDING-LEFT: 10px; PADDING-BOTTOM: 10px; MARGIN: 3px 2em 2em; BORDER-LEFT: #476797 1px solid; WORD-BREAK: break-all; PADDING-TOP: 5px; BORDER-BOTTOM: #476797 1px solid">var xhttp = null;<br /><br />if(window.XMLHttpRequest){ //IE7, Mozilla ,Firefox 等浏览器内置该对象<br /><br />  xhttp = new XMLHttpRequest();<br />  <br />}else if(window.ActiveXObject){ //IE6、IE5<br /><br />  try{ xhttp = new ActiveXObject("Msxml2.XMLHTTP");} catch (e){ ; }<br />  <br />  if( xhttp == null) try { xhttp = new ActiveXObject("Microsoft.XMLHTTP");} catch (e){; }<br />  <br />}</div>对于 xmlhttp 的使用，一般遵守如下的顺序：<br /><br />1、初始化 xmlhttp 对象（上文）；<br /><br />2、打开链接<br /><br />方法<br />xhttp.open("GET", purl, true);<br /><br />参数一：用 GET 或 POST 方式发送数据<br /><br />参数二、请求网址（只能请求你服务器上的资源，一般浏览器安全限制不能读取跨域的数据）<br /><br />参数三、true 表示异步传输（服务器返回信息完成前，你可以进行其它操作），false 表示阻断方式的传输。<br /><br />3、设定要发送的 http 请求头<br /><br />方法：<br /><br />xhttp.setRequestHeader(key,value);<br /><br />一般来说，默认要发送的头是：<br />xhttp.setRequestHeader("Content-Type","application/x-www-form-urlencoded");<br /><br />这种表示发送的内容类型的请求头用于发送文本数据，而且javascript默认是以unicode发送的<br /><br />还有另外一种形式是：<br />xhttp.setRequestHeader("Content-Type","multipart/form-data");<br /><br />是表示发送二制形式的数据，由于安全性原因，javascript一般不能用这种方式来发送数据，所以这个头一般没什么用。<br /><br />如果你的网站开启了使用 refer 参数来防盗链，那么你必须用这个方法指定 Refer 参数，或者如果用户需要登录才能进行某操作，那么要指定 Cookie 的请求头。<br /><br />4、send 数据<br /><br />方法：xhttp.send(postdata);<br /><br />对于用 get攻手请求，不需要指定postdata，直接用 test.php?a=a&amp;b=b 这样形式的网址来请求即可。<br /><br />如果是post方式，需要用 key1=value2&amp;key2=value2 这样的形式来对数据进行处理，把它合并在 postdata 字串中，然后发送。<br /><br />注意事项：<br /><font color="#0000ff"><br />javascript默认发送数据的方式是unicode，处理返回的数据必须是utf-8格式，因此，在发送的时候，需要用escape()函数来处理 postdata和网址的value，在服务器上必须还原这些value，并把unicode转为页面编码值，因此如果用 jsp 或 asp.net 都会比较简单，但如果用php处理起来是什么费劲的，等下会教你如何做。<br /></font><br /><br />5、确认服务器返回资料完成下载<br /><br />[1] 如果用阻断的方式来发送请求，那么直接用 if(xhttp.readyState == 4)就能判断是否完成。<br /><br />readyState 的具体属性值为：<br />0 没open<br />1 没send<br />2 状态未知<br />3 正在传送<br />4 传送完成<br /><br />当然为了保障起见，还需要加多一重判断<br /><br />就是 if(xhttp.status == 200)<br /><br />status 就是 http 协议里的返回头代码<br /><br />1xx 表示（唉呀，忘记了）<br />2xx 表示成功的信息<br />3xx 表示页面转移<br />4xx 页面不存在<br />5xx 表示服务器的各种错误<br /><br />如果你的页面没特殊处理，一般用 if(xhttp.status == 200)  来确信内容返回是正确的<br /><br /><br />[2] 如果用异步传输，需要用 onreadystatechange 的事件来监听<br /><br />xhttp.onreadystatechange = function()<br />{<br />   //这里来进行上面阻断方式的判断<br />   if(myajax.xhttp.readyState == 4){<br />                if(myajax.xhttp.status == 200){<br />                  //要进行的后续操作<br />                }<br />        }<br />}<br /><br />6、获取返回结果<br /><br />属性：<br />[1]xhttp.responseBody;<br />[2]xhttp.responseStream;<br />[3]xhttp.responseXml;<br />[4]xhttp.responseText;<br /><br />其中1、2都是二进制的方式，一般很少会用到，4不用看都知道了<br /><br />如果服务端无意外的话[3]返回的是一个xmldom的对象<br /><br />二、服务器部对xmlhttp请求的响应（PHP范例）<br /><br />为了简化操作，在这里把 xmlhttp的各作操作封装为一个类<br /><br /><div class="smalltxt" style="FONT-WEIGHT: bold; MARGIN-LEFT: 2em; MARGIN-RIGHT: 2em"><div style="FLOAT: left">CODE:</div><div style="FLOAT: right; TEXT-ALIGN: right"><a class="smalltxt" onclick="copycode(findobj('code1'));" href="http://www.itdoor.org/viewthread.php?tid=1774&amp;extra=page%3D1#">[Copy to clipboard]</a></div></div><div class="altbg2" id="code1" style="CLEAR: both; BORDER-RIGHT: #476797 1px solid; PADDING-RIGHT: 10px; BORDER-TOP: #476797 1px solid; PADDING-LEFT: 10px; PADDING-BOTTOM: 10px; MARGIN: 3px 2em 2em; BORDER-LEFT: #476797 1px solid; WORD-BREAK: break-all; PADDING-TOP: 5px; BORDER-BOTTOM: #476797 1px solid">function DedeAjax(WiteOKFunc){ //WiteOKFunc 为异步状态事件处理函数<br /><br />//xmlhttp和xmldom对象<br />this.xhttp = null;<br />this.xdom = null;<br /><br />//post或get发送数据的键值对<br />this.keys = Array();<br />this.values = Array();<br />this.keyCount = -1;<br /><br />//http请求头<br />this.rkeys = Array();<br />this.rvalues = Array();<br />this.rkeyCount = -1;<br />//请求头类型<br />this.rtype = 'text';<br /><br />//初始化xmlhttp<br />if(window.XMLHttpRequest){//IE7, Mozilla ,Firefox 等浏览器内置该对象<br />     this.xhttp = new XMLHttpRequest();<br />}else if(window.ActiveXObject){//IE6、IE5<br />     try { this.xhttp = new ActiveXObject("Msxml2.XMLHTTP");} catch (e) { }<br />     if (this.xhttp == null) try { this.xhttp = new ActiveXObject("Microsoft.XMLHTTP");} catch (e) { }<br />}<br />this.xhttp.onreadystatechange = WiteOKFunc;<br />//rs: responseBody、responseStream、responseXml、responseText<br /><br />//以下为成员函数<br />//--------------------------------<br /><br />//初始化xmldom<br />this.InitXDom = function(){<br />  var obj = null;<br />  if (typeof(DOMParser) != "undefined") { // Gecko、Mozilla、Firefox<br />    var parser = new DOMParser();<br />    obj = parser.parseFromString(xmlText, "text/xml");<br />  } else { // IE<br />    try { obj = new ActiveXObject("MSXML2.DOMDocument");} catch (e) { }<br />    if (obj == null) try { obj = new ActiveXObject("Microsoft.XMLDOM"); } catch (e) { }<br />  }<br />  this.xdom = obj;<br />};<br /><br />//增加一个POST或GET键值对<br />this.AddKey = function(skey,svalue){<br />        this.keyCount++;<br />        this.keys[this.keyCount] = skey;<br />        this.values[this.keyCount] = escape(svalue);<br />};<br /><br />//增加一个Http请求头键值对<br />this.AddHead = function(skey,svalue){<br />        this.rkeyCount++;<br />        this.rkeys[this.rkeyCount] = skey;<br />        this.rvalues[this.rkeyCount] = svalue;<br />};<br /><br />//清除当前对象的哈希表参数<br />this.ClearSet = function(){<br />        this.keyCount = -1;<br />        this.keys = Array();<br />        this.values = Array();<br />        this.rkeyCount = -1;<br />        this.rkeys = Array();<br />        this.rvalues = Array();<br />};<br /><br />//发送http请求头<br />this.SendHead = function(){<br />        if(this.rkeyCount!=-1){ //发送用户自行设定的请求头<br />          for(;i&lt;=this.rkeyCount;i++){<br />                  this.xhttp.setRequestHeader(this.rkeys[i],this.rvalues[i]);<br />          }<br />  }<br />　if(this.rtype=='binary'){<br />          this.xhttp.setRequestHeader("Content-Type","multipart/form-data");<br />  }else{<br />          this.xhttp.setRequestHeader("Content-Type","application/x-www-form-urlencoded");<br />  }<br />};<br /><br />//用Post方式发送数据<br />this.SendPost = function(purl){<br />        var pdata = "";<br />        var i=0;<br />        this.state = 0;<br />        this.xhttp.open("POST", purl, true);<br />        this.SendHead();<br />  if(this.keyCount!=-1){ //post数据<br />          for(;i&lt;=this.keyCount;i++){<br />                  if(pdata=="") pdata = this.keys[i]+'='+this.values[i];<br />                  else pdata += "&amp;"+this.keys[i]+'='+this.values[i];<br />          }<br />  }<br />  this.xhttp.send(pdata);<br />};<br /><br />//用GET方式发送数据<br />this.SendGet = function(purl){<br />        var gkey = "";<br />        var i=0;<br />        this.state = 0;<br />        if(this.keyCount!=-1){ //get参数<br />          for(;i&lt;=this.keyCount;i++){<br />                  if(gkey=="") gkey = this.keys[i]+'='+this.values[i];<br />                  else gkey += "&amp;"+this.keys[i]+'='+this.values[i];<br />          }<br />          if(purl.indexOf('?')==-1) purl = purl + '?' + gkey;<br />          else  purl = purl + '&amp;' + gkey;<br />  }<br />        this.xhttp.open("GET", purl, true);<br />        this.SendHead();<br />  this.xhttp.send();<br />};<br /><br />} // End Class DedeAjax</div>上面代码保存为： dedeajax.js<br /><br />ok 那现在做个最简单的测试吧<br />test.htm<br /><br /><div class="smalltxt" style="FONT-WEIGHT: bold; MARGIN-LEFT: 2em; MARGIN-RIGHT: 2em"><div style="FLOAT: left">CODE:</div><div style="FLOAT: right; TEXT-ALIGN: right"><a class="smalltxt" onclick="copycode(findobj('code2'));" href="http://www.itdoor.org/viewthread.php?tid=1774&amp;extra=page%3D1#">[Copy to clipboard]</a></div></div><div class="altbg2" id="code2" style="CLEAR: both; BORDER-RIGHT: #476797 1px solid; PADDING-RIGHT: 10px; BORDER-TOP: #476797 1px solid; PADDING-LEFT: 10px; PADDING-BOTTOM: 10px; MARGIN: 3px 2em 2em; BORDER-LEFT: #476797 1px solid; WORD-BREAK: break-all; PADDING-TOP: 5px; BORDER-BOTTOM: #476797 1px solid">&lt;script language='javascript'  src='dedeajax.js'&gt;&lt;/script&gt;<br />&lt;script language='javascript'&gt;<br />function WiteOK()<br />{<br />   var myinfo = document.getElementById("myinfo");<br />    if(myajax.xhttp.readyState == 4){<br />        if(myajax.xhttp.status == 200){<br />            myinfo.innerHTML = myajax.xhttp.responseText;<br />        }<br />    }<br />}<br />var myajax = new DedeAjax(WiteOK);<br />myajax.AddKey("key1","----------------------------");<br />myajax.SendPost("test.php");<br /><br />&lt;/script&gt;<br /><br />&lt;div id='myinfo'&gt;&lt;div&gt;</div>test.php<br /><br /><div class="smalltxt" style="FONT-WEIGHT: bold; MARGIN-LEFT: 2em; MARGIN-RIGHT: 2em"><div style="FLOAT: left">CODE:</div><div style="FLOAT: right; TEXT-ALIGN: right"><a class="smalltxt" onclick="copycode(findobj('code3'));" href="http://www.itdoor.org/viewthread.php?tid=1774&amp;extra=page%3D1#">[Copy to clipboard]</a></div></div><div class="altbg2" id="code3" style="CLEAR: both; BORDER-RIGHT: #476797 1px solid; PADDING-RIGHT: 10px; BORDER-TOP: #476797 1px solid; PADDING-LEFT: 10px; PADDING-BOTTOM: 10px; MARGIN: 3px 2em 2em; BORDER-LEFT: #476797 1px solid; WORD-BREAK: break-all; PADDING-TOP: 5px; BORDER-BOTTOM: #476797 1px solid">&lt;?<br />header("Content-Type: text/html; charset=gb2312");<br />echo $_POST['key1'];<br />?&gt;</div>看到了什么了呢？不用激动，真正让你头痛的东西还没有出来。<br /><br />把类里面的<br /><br /><div class="smalltxt" style="FONT-WEIGHT: bold; MARGIN-LEFT: 2em; MARGIN-RIGHT: 2em"><div style="FLOAT: left">CODE:</div><div style="FLOAT: right; TEXT-ALIGN: right"><a class="smalltxt" onclick="copycode(findobj('code4'));" href="http://www.itdoor.org/viewthread.php?tid=1774&amp;extra=page%3D1#">[Copy to clipboard]</a></div></div><div class="altbg2" id="code4" style="CLEAR: both; BORDER-RIGHT: #476797 1px solid; PADDING-RIGHT: 10px; BORDER-TOP: #476797 1px solid; PADDING-LEFT: 10px; PADDING-BOTTOM: 10px; MARGIN: 3px 2em 2em; BORDER-LEFT: #476797 1px solid; WORD-BREAK: break-all; PADDING-TOP: 5px; BORDER-BOTTOM: #476797 1px solid">this.AddKey = function(skey,svalue){<br />   this.keyCount++;<br />   this.keys[this.keyCount] = skey;<br />   this.values[this.keyCount] = svalue;//escape(svalue);<br />};</div>escape 屏蔽掉<br /><br />发送<br />myajax.AddKey("key1","-----中---国----人-----");<br /><br />看到什么了，乱码是吧？呵呵，这回开始头大了<br /><br />先把 escape放回去<br />this.values[this.keyCount] = escape(svalue);<br /><br />那么看到的就是<br />-----%u4E2D---%u56FD----%u4EBA-----<br /><br />如何把  %u4E2D  这些东西弄回来呢？对于php而言这是一个很复杂的问题，如果用asp就简单多了<br /><br />下面是我写的一个函数：<br /><br /><div class="smalltxt" style="FONT-WEIGHT: bold; MARGIN-LEFT: 2em; MARGIN-RIGHT: 2em"><div style="FLOAT: left">CODE:</div><div style="FLOAT: right; TEXT-ALIGN: right"><a class="smalltxt" onclick="copycode(findobj('code5'));" href="http://www.itdoor.org/viewthread.php?tid=1774&amp;extra=page%3D1#">[Copy to clipboard]</a></div></div><div class="altbg2" id="code5" style="CLEAR: both; BORDER-RIGHT: #476797 1px solid; PADDING-RIGHT: 10px; BORDER-TOP: #476797 1px solid; PADDING-LEFT: 10px; PADDING-BOTTOM: 10px; MARGIN: 3px 2em 2em; BORDER-LEFT: #476797 1px solid; WORD-BREAK: break-all; PADDING-TOP: 5px; BORDER-BOTTOM: #476797 1px solid">//unicode url编码转gbk编码函数<br />function Unicode2Gbk($str)<br />{<br />        //载入对照词典<br />        if(!isset($GLOBALS['GbkUniDic']))<br />        {<br />          $ds = file("./data/gbk_unicode.dic");<br />          foreach($ds as $l){<br />                  $GLOBALS['GbkUniDic'][hexdec('0x'.substr($l,0,4))] = substr($l,5,4);<br />          }<br />  }<br />  //处理字符串<br />  $glen = strlen($str);<br />  $okstr = "";<br />  for($i=0; $i &lt; $glen; $i++)<br />  {<br />           if( $glen-$i &gt; 4){<br />                    if($str[$i]=='%' &amp;&amp; $str[$i+1]=='u'){<br />                              $uni = hexdec('0x'.substr($str,$i+2,4));<br />                              if(isset($GLOBALS['GbkUniDic'][$uni])){<br />                                      $uni = $GLOBALS['GbkUniDic'][$uni];<br />                                      $okstr .= chr(hexdec(substr($uni,0,2))).chr(hexdec(substr($uni,2,2)));<br />                              }<br />                              else $okstr .= "&amp;#{".hexdec("0x".$uni).";";<br />                              $i = $i+5;<br />                    }<br />                    else $okstr .= $str[$i];<br />           }<br />           else $okstr .= $str[$i];<br />  }<br />  return $okstr;<br />}</div>词典文件： http://www.ce86.com/myimg/data.rar<br /><br /><br />把test.php 输出改为<br /><br />echo Unicode2Gbk($_POST['key1']);<br /><br />正常了吧:lol:<br /><br />以下说下面和xml有关的东西的了<br /><br />三、xmldom 的使用方法<br /><br />由于本文仅是牵针引线的作用，这一章就简单些，因为针对的是 php ，如果针对的是 asp.net 或 jsp 写涉及 web server 类的通信，已经不单纯是 ajax  的问题了，本章的任务是把<br /><br />test2.php<br /><br /><div class="smalltxt" style="FONT-WEIGHT: bold; MARGIN-LEFT: 2em; MARGIN-RIGHT: 2em"><div style="FLOAT: left">CODE:</div><div style="FLOAT: right; TEXT-ALIGN: right"><a class="smalltxt" onclick="copycode(findobj('code6'));" href="http://www.itdoor.org/viewthread.php?tid=1774&amp;extra=page%3D1#">[Copy to clipboard]</a></div></div><div class="altbg2" id="code6" style="CLEAR: both; BORDER-RIGHT: #476797 1px solid; PADDING-RIGHT: 10px; BORDER-TOP: #476797 1px solid; PADDING-LEFT: 10px; PADDING-BOTTOM: 10px; MARGIN: 3px 2em 2em; BORDER-LEFT: #476797 1px solid; WORD-BREAK: break-all; PADDING-TOP: 5px; BORDER-BOTTOM: #476797 1px solid">&lt;?<br />header("Content-Type: text/xml; charset=gb2312");<br />echo '&lt;'.'?'."xml version=\"1.0\" encoding=\"gb2312\" ".'?'."&gt;<br />&lt;myhome&gt;<br />  &lt;item sex=\"男\"&gt;我是小一&lt;/item&gt;<br />  &lt;item sex=\"女\"&gt;我是小二&lt;/item&gt;<br />&lt;/myhome&gt;<br />";<br />?&gt;</div>这个xml文档在客户端用自己的方式展现出来。<br /><br />因为xml这种东西比较麻烦，所以语法也必须严格，test2.htm的页面的源码为<br /><br /><div class="smalltxt" style="FONT-WEIGHT: bold; MARGIN-LEFT: 2em; MARGIN-RIGHT: 2em"><div style="FLOAT: left">CODE:</div><div style="FLOAT: right; TEXT-ALIGN: right"><a class="smalltxt" onclick="copycode(findobj('code7'));" href="http://www.itdoor.org/viewthread.php?tid=1774&amp;extra=page%3D1#">[Copy to clipboard]</a></div></div><div class="altbg2" id="code7" style="CLEAR: both; BORDER-RIGHT: #476797 1px solid; PADDING-RIGHT: 10px; BORDER-TOP: #476797 1px solid; PADDING-LEFT: 10px; PADDING-BOTTOM: 10px; MARGIN: 3px 2em 2em; BORDER-LEFT: #476797 1px solid; WORD-BREAK: break-all; PADDING-TOP: 5px; BORDER-BOTTOM: #476797 1px solid">&lt;html&gt;<br />&lt;head&gt;<br />&lt;meta http-equiv="Content-Type" content="text/html; charset=gb2312"&gt;<br />&lt;title&gt;ajax测试&lt;/title&gt;<br />&lt;/head&gt;<br />&lt;body onload="WiteLoadDocument()"&gt;<br />&lt;script language='javascript'  src='dedeajax.js'&gt;&lt;/script&gt;<br />&lt;script language='javascript'&gt;<br />var myajax = new DedeAjax(WiteOK);<br />function WiteOK()<br />{<br />   var myinfo = document.getElementById("myinfo");<br />   var mydom = null;<br />   myinfo.innerHTML = "以下是处理结果：&lt;br/&gt;";<br />   if(myajax.xhttp.readyState == 4){<br />     mydom = myajax.xhttp.responseXml;<br />     alert(mydom);<br />   }<br />}<br />function WiteLoadDocument()<br />{<br />   myajax.SendGet("test2.php");       <br />}<br />&lt;/script&gt;<br />&lt;div id='myinfo'&gt;&lt;div&gt;<br />&lt;/body&gt;<br />&lt;/html&gt;</div>在IE中测试一下，如果弹出的对话框是 [object] 就表示成功获得返回的xml的xmldoc了。<br /><br />那下面是处理：<br /><br /><div class="smalltxt" style="FONT-WEIGHT: bold; MARGIN-LEFT: 2em; MARGIN-RIGHT: 2em"><div style="FLOAT: left">CODE:</div><div style="FLOAT: right; TEXT-ALIGN: right"><a class="smalltxt" onclick="copycode(findobj('code8'));" href="http://www.itdoor.org/viewthread.php?tid=1774&amp;extra=page%3D1#">[Copy to clipboard]</a></div></div><div class="altbg2" id="code8" style="CLEAR: both; BORDER-RIGHT: #476797 1px solid; PADDING-RIGHT: 10px; BORDER-TOP: #476797 1px solid; PADDING-LEFT: 10px; PADDING-BOTTOM: 10px; MARGIN: 3px 2em 2em; BORDER-LEFT: #476797 1px solid; WORD-BREAK: break-all; PADDING-TOP: 5px; BORDER-BOTTOM: #476797 1px solid">function WiteOK()<br />{<br />   var myinfo = document.getElementById("myinfo");<br />   var mydom = null;<br />   myinfo.innerHTML = "以下是处理结果：&lt;br/&gt;";<br />   if(myajax.xhttp.readyState == 4){<br />     mydom = myajax.xhttp.responseXml;<br />     var nodeList = mydom.selectNodes("/myhome/item");<br />     var mynode = null;<br />     var myatt = null;<br />     var mysex = "";<br />     for(i=1;i&lt;=nodeList.length;i++)<br />     {<br />              mynode = nodeList[i-1];<br />              for(j=0;j &lt; myinfo.attributes.length;j++)<br />              {<br />                       if(!mynode.attributes[j]) break;<br />                       myatt = mynode.attributes[j];<br />                       if(myatt.name=='sex') mysex = myatt.value;<br />              }<br />              myinfo.innerHTML += "我是："+mynode.text+"，我的性别是："+ mysex +"&lt;br/&gt;";<br />     }<br />   }<br />}</div>结果：<br /><br /><div class="smalltxt" style="FONT-WEIGHT: bold; MARGIN-LEFT: 2em; MARGIN-RIGHT: 2em"><div style="FLOAT: left">CODE:</div><div style="FLOAT: right; TEXT-ALIGN: right"><a class="smalltxt" onclick="copycode(findobj('code9'));" href="http://www.itdoor.org/viewthread.php?tid=1774&amp;extra=page%3D1#">[Copy to clipboard]</a></div></div><div class="altbg2" id="code9" style="CLEAR: both; BORDER-RIGHT: #476797 1px solid; PADDING-RIGHT: 10px; BORDER-TOP: #476797 1px solid; PADDING-LEFT: 10px; PADDING-BOTTOM: 10px; MARGIN: 3px 2em 2em; BORDER-LEFT: #476797 1px solid; WORD-BREAK: break-all; PADDING-TOP: 5px; BORDER-BOTTOM: #476797 1px solid">以下是处理结果：<br />我是：我是小一，我的性别是：男<br />我是：我是小二，我的性别是：女</div>OK，目的已经达到<br /><br />关于dom的部份只在IE6中测试过，可能在firefox中会有问题，大家可能参考与兼容性有关的文档 <br /></div>
<img src ="http://www.cnitblog.com/asfman/aggbug/17426.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cnitblog.com/asfman/" target="_blank">汪杰</a> 2006-09-28 01:37 <a href="http://www.cnitblog.com/asfman/articles/17426.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>XML中特殊字符出现乱码的解决</title><link>http://www.cnitblog.com/asfman/articles/17173.html</link><dc:creator>汪杰</dc:creator><author>汪杰</author><pubDate>Fri, 22 Sep 2006 00:30:00 GMT</pubDate><guid>http://www.cnitblog.com/asfman/articles/17173.html</guid><wfw:comment>http://www.cnitblog.com/asfman/comments/17173.html</wfw:comment><comments>http://www.cnitblog.com/asfman/articles/17173.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cnitblog.com/asfman/comments/commentRss/17173.html</wfw:commentRss><trackback:ping>http://www.cnitblog.com/asfman/services/trackbacks/17173.html</trackback:ping><description><![CDATA[
		<span style="FONT-SIZE: 12px; LINE-HEIGHT: 1.7em">
				<b>作者：琥珀 @ 2006-9-20 </b>
				<br />
				<a href="http://www.51ajax.com/" target="_blank">
						<font color="#333366">http://www.51ajax.com</font>
				</a>
				<br />
				<br />昨天有朋友问到XML中特殊字符显示有误的问题，搜集了N多资料，终于找到一个解决方案，权当抛砖引玉，给大家提供个思路，希望能有更好的方法。<br /><br /><b>1.问题描述</b><br />XML文档中，一些特殊ASCII字符，显示会有问题，如音乐符号&#xE;，即使包含在&lt; ! [CDATA[ ] ]中也不行，提示javascript错误：文本内容中发现无效字符。<br /><br />注：本文中的特殊字符主要是指音乐符号<font color="red"><b>&#xE;</b></font>等ASCII码小于32的其中一些字符<br /><br /><b>2.参考文档</b><br /><br />1)网址：<a href="http://www.pcdog.com/p/html/20041215/151220044979_1.htm" target="_blank"><font color="#333366">http://www.pcdog.com/p/html/20041215/151220044979_1.htm</font></a><br />update:@2006-9-21 这篇文章与本文要解决的特殊字符不是一类问题，仅供参考<br /><br /><b>3.最终解决方案</b><br /><br />1)在网上找到一张ASCII字符表，这个表是解决问题的关键，地址如下：<br /><br /><a href="http://www.51ajax.com/demo/ascii/ascii.htm" target="_blank"><font color="#333366">http://www.51ajax.com/demo/ascii/ascii.htm</font></a><br /><br />ASCII 码大致可以分作三部分组成。   第一部分由 00H 到 1FH 共 32 个，一般用来通讯或作为控制之用，有些字符可显示于屏幕，有些则无法显示在屏幕上，但能看到其效果(例如换行字符、归位字符)。<br /><br />第二部分是由 20H 到 7FH 共 96 个，这 95 个字符是用来表示阿拉伯数字、英文字母大小写和底线、括号等符号，都可以显示在屏幕上。<br /><br />第三部分由 80H 到 0FFH 共 128 个字符，一般称为『扩充字符』，这 128 个扩充字符是由 IBM 制定的，并非标准的 ASCII 码。这些字符是用来表示框线、音标和其它欧洲非英语系的字母。<br /><br />2)具体方法<br />从第一部分的表中可以看到音乐符号&#xE;的ASCII是14（十进制），产生问题的原因在于ASCII码小于32的符号有些在屏幕上显示时会有问题，解决的方法如下：<br /><br />在提交入库前用Javascript将ASCII码小于32的字符用escape()函数编码，然后入库，如&#xE;编码后将变为%0E，其它字符不变，这样在XML中显示不会出现问题，当用Javascript对XML进行解析时，再用unescape()函数对内容进行解码，这样会将%0E显示为&#xE;。<br /><br />我写了一个Javascript函数(只适用于少量数据)，可以实现对ASCII码在32以下的字符进行编码。<br /><br />Javascript函数如下：<br /><br /><div class="smalltxt" style="MARGIN-TOP: 1em; FONT-WEIGHT: bold; MARGIN-BOTTOM: 1em"><div style="FLOAT: left">CODE:</div><div style="FLOAT: right; TEXT-ALIGN: right"><a class="smalltxt" onclick="copycode(findobj('code0'));" href="http://bbs.blueidea.com/thread-2677860-1-3.html###"><font color="#333366">[Copy to clipboard]</font></a></div></div><div class="altbg2" id="code0" style="CLEAR: both; BORDER-RIGHT: #666688 1px solid; PADDING-RIGHT: 10px; BORDER-TOP: #666688 1px solid; PADDING-LEFT: 10px; PADDING-BOTTOM: 10px; MARGIN: 3px 2em 2em; BORDER-LEFT: #666688 1px solid; WORD-BREAK: break-all; PADDING-TOP: 5px; BORDER-BOTTOM: #666688 1px solid">function escapeAscii(s){<br />  var ss=s<br />  var strNew=""<br />  for(var i=0;i&lt;s.length;i++){<br />      strNew+=(ss.charCodeAt(0,1)&lt;32?(escape(ss.substring(0,1))):(ss.substring(0,1)))<br />      ss=ss.substring(1,ss.length)<br />    }<br />   return strNew<br />}<br />    </div>做了一个Demo页，可对字符串进行编码、解码，这是地址：<a href="http://www.51ajax.com/demo/ascii/index.html" target="_blank"><font color="#333366">http://www.51ajax.com/demo/ascii/index.html</font></a><br />也在<a href="http://www.51ajax.com/guestbook" target="_blank"><font color="#333366">AJAX留言板</font></a>测试一下，已按上述方式在入库前进行了编码，读取时再解码。<br />这是AJAX留言板的XML页地址：<a href="http://www.51ajax.com/guestbook/guestbook.php?action=get" target="_blank"><font color="#333366">http://www.51ajax.com/guestbook/guestbook.php?action=get</font></a><br /><br /><b>4.存在问题</b><br />当数据量比较大时，存在效率问题，我对正则不熟，哪位达人如能用正则写个函数，那应该算是一个比较好的解决方案了。<br /></span>
<img src ="http://www.cnitblog.com/asfman/aggbug/17173.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cnitblog.com/asfman/" target="_blank">汪杰</a> 2006-09-22 08:30 <a href="http://www.cnitblog.com/asfman/articles/17173.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>AJAX回调模块与调用模块</title><link>http://www.cnitblog.com/asfman/articles/15197.html</link><dc:creator>汪杰</dc:creator><author>汪杰</author><pubDate>Sun, 13 Aug 2006 07:53:00 GMT</pubDate><guid>http://www.cnitblog.com/asfman/articles/15197.html</guid><wfw:comment>http://www.cnitblog.com/asfman/comments/15197.html</wfw:comment><comments>http://www.cnitblog.com/asfman/articles/15197.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cnitblog.com/asfman/comments/commentRss/15197.html</wfw:commentRss><trackback:ping>http://www.cnitblog.com/asfman/services/trackbacks/15197.html</trackback:ping><description><![CDATA[
		<div class="Content-body" id="logPanel">这几天忙着在将所有的AJAX应用程序模块化,然后在仔细研究Dave Crane,Eric Pascarello,Darren James合著的&lt;Ajax in Action&gt;后,发现老外还真是牛啊,比起目前出的其他5本ajax书来说,该书完全是一部权威级的著作,那几本就很小儿科了.<br /><br />从潜到深描述一下我又新学到的东西:<br />首先就是完全的模块化写法,从prototype里面偷来一点简化思想,从代码开始讲起吧.<br /><br />声明ID是在写调用对象的程序中必不可少的,目前我是这样来写的:<br /><div class="UBBPanel"><div class="UBBTitle"><img style="MARGIN: 0px 2px -3px 0px" alt="程序代码" src="http://www.cnrui.cn/blog/images/code.gif" /> 程序代码</div><div class="UBBContent"><br />function $(objID) {<br />  return document.getElementById(objID)<br />}<br /></div></div><br />以后需要调用ID的时候直接$(IDName),是不是方便了很多.<br /><br />经典的位置在这里:<br /><div class="UBBPanel"><div class="UBBTitle"><img style="MARGIN: 0px 2px -3px 0px" alt="程序代码" src="http://www.cnrui.cn/blog/images/code.gif" /> 程序代码</div><div class="UBBContent"><br />function $() {<br />  return document.getElementById(arguments[0])<br />}<br /></div></div><br />这样写也同样可以,很多人都不知道arguments是个什么东西,其实他几是对应的函数参数数组,第一个参数就是arguments[0],第二个就是arguments[1],以此类推.不过arguments属于是一个伪数组,不能直接用操作数组的方式操作arguments,而要使用定义原形的方式,这个我会专门用一篇日志来解说的.<br /><br />按照这个思想我又写了一个定义标签名字的函数:<br /><div class="UBBPanel"><div class="UBBTitle"><img style="MARGIN: 0px 2px -3px 0px" alt="程序代码" src="http://www.cnrui.cn/blog/images/code.gif" /> 程序代码</div><div class="UBBContent"><br />function $f(objName) {<br />  return document.getElementsByName(objName)[0]<br />}<br /></div></div><br />getElementsByName就是调用HTML里面所有标签名的一个数组对象,通过指定标签名,来查找对象的方法.<br /><br />好了,开始将回调函数模块.<br />估计很多人都使用过window.onload,而在大型项目中,可能设计到要onload很多函数,而又不可能每个页面都使用不同的onload,因为这样做会很麻烦.所以我们要想到一种思路,如何可以按需回调函数.<br />先看代码:<br /><div class="UBBPanel"><div class="UBBTitle"><img style="MARGIN: 0px 2px -3px 0px" alt="程序代码" src="http://www.cnrui.cn/blog/images/code.gif" /> 程序代码</div><div class="UBBContent"><br />window.$loads = new Array()<br />window.$load = function(func,arg){<br />    window.$loads[window.$loads.length] = [func,(arg) ? arg : ""];<br />}<br />window.onload = function(){<br />    for(var i=0; i &lt; window.$loads.length; i++){<br />        var func = window.$loads[i][0];<br />        func(window.$loads[i][1])<br />    }<br />}<br /></div></div><br />估计现在你应该知道怎么做了.因为页面加载的时候,总要首先加载window内容,所以我们扩展一个window对象数组,然后动态将所要使用的回调函数按需要写在不同的位置,而一旦页面加载,可以只加载所需要的本页面函数.<br />加载的方法就是在不同页面写上window.$load(funcName,argument),是不是很方便了。<br />我扩展了一下这个模块,可以加载函数的参数,当然,你不用加载参数的时候可以不写argument.<br />这个模块的思路就是利用onload的一个循环,把需要加载的函数从数组中读书,然后一各个运行他.<br /><br />AJAX的核心功能调用,就是通过后台JS与服务器之间进行交互,可能我们需要调用服务器的不同,所需要实现的功能不同,而写出很多相类似的核心调用代码,这样不仅加重了工作量,更为将来代码的维护造成了极大的不方便.同样我在Dave的思路上将代码继续扩张了一下,可以将这个模块用在不同的AJAX核心数据调用的位置,而且还可以自定义不同调用状态所需要的动作.<br /><br />代码:<br /><div class="UBBPanel"><div class="UBBTitle"><img style="MARGIN: 0px 2px -3px 0px" alt="程序代码" src="http://www.cnrui.cn/blog/images/code.gif" /> 程序代码</div><div class="UBBContent"><br />//ajax组件<br />var ajax = new Object();<br />ajax.$x = function(url,onload,onerror,stateArray){<br />    this.url = url;<br />    this.req = null;<br />    this.onload = onload;<br />    this.onerror = (onerror) ? onerror : this.defaultError;<br />    this.stateNum = (stateArray) ? stateArray : false;<br />    this.loadXMLDoc(url);<br />}<br />ajax.$x.prototype = {<br />    loadXMLDoc:function(url){<br />        if(window.XMLHttpRequest){<br />            this.req = new XMLHttpRequest();<br />            if(this.req.overrideMimeType){<br />                    this.req.overrideMimeType('text/xml');<br />            }<br />        }else if(window.ActiveXObject){<br />            try{<br />                this.req = new ActiveXObject("Msxml3.XMLHTTP");<br />            }catch(e){<br />                try{<br />                    this.req = new ActiveXObject("Msxml2.XMLHTTP");<br />                }catch(e){<br />                    try{<br />                        this.req = new ActiveXObject("Microsoft.XMLHTTP");<br />                    }catch(e){}<br />                }<br />            }<br />        }<br />        if(this.req){<br />            try{<br />                var loader = this;<br />                this.req.onreadystatechange = function(){<br />                    loader.onReadyState.call(loader)<br />                }<br />                this.req.open("GET",url,true);<br />                this.req.send(null);<br />            }catch(err){<br />                this.onerror.call(this);<br />            }<br />        }<br />    },<br />    onReadyState:function(){<br />        var req = this.req;<br />        var ready = req.readyState;<br />        if(this.stateNum &amp;&amp; ready &gt;= 1 &amp;&amp; ready &lt;= 3){<br />            this.stateNum[ready-1].call(this);<br />        }else if(ready == 4){<br />            var httpStatus = req.status;<br />            if(httpStatus == 200 || httpStatus == 0){<br />                this.onload.call(this);<br />            }else{<br />                this.onerror.call(this);<br />            }<br />        }<br />    },<br />    defaultError:function(){<br />        alert("数据连接错误!"<br />            + "\n\nreadyState: " + this.req.readyState<br />            + "\nstatus: " + this.req.status<br />            + "\nheafers: " + this.req.getAllResponseHeaders()<br />            )<br />    }<br />}<br /></div></div><br /><br />不要给这段代码所吓住了,这个代码基本上可以在不改动的情况下，满足你所有的AJAX核心数据调用功能.而这个思路就是传统的OOP(面向对象Object-Oriented Programming)编程思想.可能你会觉得不可思议,是啊,之前我也给OOP吓倒了,不过在接触大量程序语言后发现,这是个非常优秀的思想,而我也非常乐意地接受了他.我可以这样说,当你拥有某种思想意识后,对于程序这个东西的掌握,是水到渠成的.当javascript使用了这样的思路,相信传统的程序员也会汗颜轻视了js.<br /><br />我只讲一下这个控件的调用方式,用我的验证码提示作为事例吧,这个东西我还没发过,呵呵!<br /><div class="UBBPanel"><div class="UBBTitle"><img style="MARGIN: 0px 2px -3px 0px" alt="程序代码" src="http://www.cnrui.cn/blog/images/code.gif" /> 程序代码</div><div class="UBBContent"><br />//检查验证码对错<br />function checkCode(){<br />//设定数据交换的服务器端URL<br />    var url = "common/checkCode.asp?timeStamp="+new Date().getTime();<br />//调用AJAX数据核心模块<br />//第一个参数是URL地址,<br />//第二个参数是AJAX数据与服务器交互成功后所要调用的函数名<br />//第三个参数是AJAX数据交互失败所调用的函数名,当然,你可以不写,因为我在模块里定义了一个默认的出错处理函数<br />//第四个参数是你需要在数据调用过程中的每个状态所需要调用的函数,同样你也可以不写,那么就不使用其他状态回调,记住这个是一个数组名,就是你需要按照这个方法写每个状态的回调函数:tocheck1 function(){}, function tocheck2(){},function  tocheck3(){},切记!<br />    var checks = new ajax.$x(url,toCheck,toCheckError)<br />}<br />//数据调用成功后的回调函数<br />function toCheck(){<br />    var res = this.req.responseXML.documentElement;<br />    var vadcode = res.getElementsByTagName("codes")[0].firstChild.nodeValue;<br />    var newtxt = document.forms[0].validate.value.toLowerCase()<br />    if(newtxt == vadcode){<br />        $("codetxt").innerHTML = "验证码正确！";<br />    }else if(newtxt.length &lt; 4){<br />        $("codetxt").innerHTML = "验证码未完成！"<br />    }else{<br />        $("codetxt").innerHTML = "验证码错误！提示：&lt;label ondblclick='toCopyCode(this);'&gt;" + vadcode + "&lt;/label&gt;"<br />    }<br />}<br />//这是一个小彩蛋,留给你发现吧<br />function toCopyCode(thisCode){<br />    document.forms[0].validate.value = thisCode.innerHTML;<br />    $("codetxt").innerHTML = "验证码正确！";<br />}<br />//数据调用失败处理<br />function toCheckError(){<br />    $("codetxt").innerHTML = "验证码检测错误！";<br />}<br />var oldCom,timeID<br />//这个是检测你输入的验证码过程需要调用的动作<br />function onComChange(){<br />    var inputxt = document.forms[0].validate.value<br />    if(inputxt != oldCom &amp;&amp; Trim(inputxt) != ""){<br />        oldCom = inputxt;<br />        checkCode("recode")<br />    }else if(inputxt.length == 0){<br />        $("codetxt").innerHTML = "请输入验证码！"<br />    }<br />    timeID = setTimeout(onComChange,100)<br />}<br />//当离开输入验证码框后,停止验证<br />function onblurs(){<br />    clearTimeout(timeID)<br />}</div></div></div>
<img src ="http://www.cnitblog.com/asfman/aggbug/15197.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cnitblog.com/asfman/" target="_blank">汪杰</a> 2006-08-13 15:53 <a href="http://www.cnitblog.com/asfman/articles/15197.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>send and post </title><link>http://www.cnitblog.com/asfman/articles/13552.html</link><dc:creator>汪杰</dc:creator><author>汪杰</author><pubDate>Wed, 12 Jul 2006 08:12:00 GMT</pubDate><guid>http://www.cnitblog.com/asfman/articles/13552.html</guid><wfw:comment>http://www.cnitblog.com/asfman/comments/13552.html</wfw:comment><comments>http://www.cnitblog.com/asfman/articles/13552.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cnitblog.com/asfman/comments/commentRss/13552.html</wfw:commentRss><trackback:ping>http://www.cnitblog.com/asfman/services/trackbacks/13552.html</trackback:ping><description><![CDATA[
		<button onclick="b1()">调用底下这个方法传递POST数据</button>
		<code>
				<pre>
						<script><![CDATA[
document.write(conv(b1))
]]&gt;</script>function b1(){
	var post="user=sheneyan&amp;pw=1234";
	xml.open("POST","testAjaxPost.php",false); 
	xml.setrequestheader("content-length",post.length); 
	xml.setrequestheader("content-type","application/x-www-form-urlencoded"); 
	xml.send(post);
	alert(xml.responseText);
}
</pre>
		</code>
		<button onclick="b2()">调用底下这个方法解析无意义数据</button>
		<code>
				<pre>
						<script><![CDATA[
document.write(conv(b2))
]]&gt;</script>function b2(){
	var post="12qwrf";
	xml.open("POST","testAjaxPost.php?data",false); 
	xml.send(post);
	alert(xml.responseText);
}
</pre>
		</code>
		<button onclick="b3()">调用底下这个方法传递GET数据</button>
		<code>
				<pre>
						<script><![CDATA[
document.write(conv(b3))
]]&gt;</script>function b3(){
	var get="user=sheneyan&amp;pw=1234";
	xml.open("GET","testAjaxPost.php?"+get,false); 
	xml.send();
	alert(xml.responseText);
}
</pre>
		</code>
		<button onclick="b4()">调用底下这个方法传递GET和POST数据</button>
		<code>
				<pre>
						<script><![CDATA[
document.write(conv(b4))
]]&gt;</script>function b4(){
	var get="user=sheneyan&amp;pw=1234";
	var post="_user=帅青蛙&amp;_pw=4321";
	xml.open("POST","testAjaxPost.php?"+get,false); 
	xml.setrequestheader("content-length",post.length); 
	xml.setrequestheader("content-type","application/x-www-form-urlencoded"); 
	xml.send(post);
	alert(xml.responseText);
}
</pre>
		</code>
		<font face="宋体, MS Song">testAjaxPost.php的源代码： </font>
		<code>
				<pre>&lt;?
if (!isset($_GET["data"])){
	$c=count($_POST);
	echo "post参数有".$c."个\n";
	if ($c&gt;0){
		echo "分别是：\n\n";
		foreach ($_POST as $k=&gt;$v){
			echo urldecode($k)."=&gt;".urldecode($v)."\n";
		}
	}
	$c=count($_GET);
	echo "--------------\nget参数有".$c."个\n";
	if ($c&gt;0){
		echo "分别是：\n\n";
		foreach ($_GET as $k=&gt;$v){
			echo urldecode($k)."=&gt;".urldecode($v)."\n";
		}
	}
}
else{
	echo($HTTP_RAW_POST_DATA);
}
?&gt;
</pre>
		</code>
<img src ="http://www.cnitblog.com/asfman/aggbug/13552.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cnitblog.com/asfman/" target="_blank">汪杰</a> 2006-07-12 16:12 <a href="http://www.cnitblog.com/asfman/articles/13552.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item></channel></rss>