<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>无风的港湾 &#187; js</title>
	<atom:link href="http://www.5bay.cn/tag/js/feed" rel="self" type="application/rss+xml" />
	<link>http://www.5bay.cn</link>
	<description>让你我停泊~</description>
	<lastBuildDate>Fri, 16 Dec 2011 09:18:11 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3</generator>
		<item>
		<title>ASP防注入新方式，希望对大家是有用的</title>
		<link>http://www.5bay.cn/server-building/aspeaojie.html</link>
		<comments>http://www.5bay.cn/server-building/aspeaojie.html#comments</comments>
		<pubDate>Wed, 28 Jul 2010 02:00:27 +0000</pubDate>
		<dc:creator>江小邪</dc:creator>
				<category><![CDATA[服务器构建&安全]]></category>
		<category><![CDATA[ASP]]></category>
		<category><![CDATA[js]]></category>
		<category><![CDATA[sql]]></category>
		<category><![CDATA[url]]></category>
		<category><![CDATA[人]]></category>
		<category><![CDATA[代码]]></category>
		<category><![CDATA[工具]]></category>
		<category><![CDATA[数据]]></category>
		<category><![CDATA[数据库]]></category>
		<category><![CDATA[方法]]></category>
		<category><![CDATA[程序]]></category>
		<category><![CDATA[类]]></category>
		<category><![CDATA[网站]]></category>
		<category><![CDATA[诫]]></category>
		<category><![CDATA[连接]]></category>
		<category><![CDATA[防注入]]></category>

		<guid isPermaLink="false">http://www.5bay.cn/?p=527</guid>
		<description><![CDATA[<a href="http://www.5bay.cn/server-building/aspeaojie.html"><img align="left" hspace="5" width="150" height="150" src="http://www.5bay.cn/wp-content/plugins/thumbnail-for-excerpts/tfe_no_thumb.png" class="alignleft wp-post-image tfe" alt="" title="" /></a>最近我的网站经常把js脚本注入到数据，清除了又来。先后在网上找了很多的方法，还是没有用的，十分恼火。 首先先告诉大家一个批量清除代码的sql语句。 update 表名 set 字段=replace(字段,&#8217;script src=http://3b3.org/c.js&#62; 1、分析那些无聊的人，或者有些病态的人究竟做了些什么 。 通过iis的日志或者microsoft urlscan 日志查看，在一些通过id查询数据库内容的时候后面被人加了一段很长的字符窜。 %%3B%%44%%65%%43%%4C%%61%%52%%45%%类似这样的字符窜，一定是其他的方式编码 首先我们先用工具分析下如此之长的字符窜究竟包含了些什么内容。 通过批量替换工具把%%全部替换成空，然后把得到的字符串通过其他的转码工具，转成字符窜。 ;DeCLaRE @S NvArCHaR(4000);SeT @S=CaSt(0&#215;45这里代码去掉了06F007200 aS NvArChAR(4000));ExEc(@S);&#8211; 就是一段与通过id查询数据库同时执行的sql，就给数据库某些表的字段加入了js病毒连接。 2、所以我们的原来的防sql注入的字符串就需要升级了。 如果过滤16进制 ; 对应 3B DeCLaRE 对应 4465434C615245 @ 对应 40 NvArCHaR 对应 4E76417243486152 set 对应 536554 CaSt 对应 43615374 as 对应 6153 exec 对应 45784563 - 对应 2D 把16进制的代码用&#124;隔开放到injdata 里面 injdata = [...]]]></description>
			<content:encoded><![CDATA[<p>最近我的网站经常把js脚本注入到数据，清除了又来。先后在网上找了很多的方法，还是没有用的，十分恼火。</p>
<p>首先先告诉大家一个批量清除代码的sql语句。</p>
<p>update 表名 set 字段=replace(字段,&#8217;script src=http://3b3.org/c.<a href="http://www.5bay.cn/tag/js" class="st_tag internal_tag" rel="tag" title="标签 js 下的日志">js</a>&gt;<br />
1、分析那些无聊的人，或者有些病态的人究竟做了些什么 。</p>
<p>通过iis的日志或者microsoft urlscan 日志查看，在一些通过id查询数据库内容的时候后面被人加了一段很长的字符窜。</p>
<p>%%3B%%44%%65%%43%%4C%%61%%52%%45%%类似这样的字符窜，一定是其他的方式编码</p>
<p>首先我们先用工具分析下如此之长的字符窜究竟包含了些什么内容。</p>
<p>通过批量替换工具把%%全部替换成空，然后把得到的字符串通过其他的转码工具，转成字符窜。</p>
<p>;DeCLaRE @S NvArCHaR(4000);SeT @S=CaSt(0&#215;45这里代码去掉了06F007200 aS NvArChAR(4000));ExEc(@S);&#8211;</p>
<p>就是一段与通过id查询数据库同时执行的sql，就给数据库某些表的字段加入了js病毒连接。</p>
<p>2、所以我们的原来的防sql注入的字符串就需要升级了。</p>
<p>如果过滤16进制</p>
<p>; 对应 3B</p>
<p>DeCLaRE 对应 4465434C615245</p>
<p>@ 对应 40</p>
<p>NvArCHaR 对应 4E76417243486152</p>
<p>set 对应 536554</p>
<p>CaSt 对应 43615374</p>
<p>as 对应 6153</p>
<p>exec 对应 45784563</p>
<p>- 对应 2D</p>
<p>把16进制的代码用|隔开放到injdata 里面</p>
<p>injdata = “3B|2D|&#8217;|;|and|exec|insert|select|delete%20from|update|count|”</p>
<p>然后自己测试下，程序是否拦击了这些16进制的代码，本人测试过是可以拦击的，如果不加入这些是不拦击的</p>
<p>照样可以注入到数据库。</p>
<h2  class="related_post_title">相关博文</h2><ul class="related_post"><li>2010年07月26日 -- <a href="http://www.5bay.cn/network-programming/eesoneeajaxeehuai.html" title="基于JSON的高级AJAX开发技术">基于JSON的高级AJAX开发技术</a> (0)</li><li>2010年07月26日 -- <a href="http://www.5bay.cn/network-programming/eeeeeeee.html" title="最令PHP初学者头痛的十四个问题">最令PHP初学者头痛的十四个问题</a> (0)</li><li>2010年07月26日 -- <a href="http://www.5bay.cn/network-programming/phpeefangeredoc.html" title="php的文档句法(heredoc)<<<和PHP字符串操作">php的文档句法(heredoc)<<<和PHP字符串操作</a> (0)</li><li>2010年07月26日 -- <a href="http://www.5bay.cn/network-programming/eejaxeeeeee.html" title="使用Ajax时的十个常犯的错误">使用Ajax时的十个常犯的错误</a> (0)</li><li>2010年07月26日 -- <a href="http://www.5bay.cn/network-programming/phpeezhanchang.html" title="PHP安全之数据过滤">PHP安全之数据过滤</a> (0)</li><li>2010年05月23日 -- <a href="http://www.5bay.cn/server-building/rsyncxiangjie.html" title="Rsync详解">Rsync详解</a> (0)</li><li>2010年05月23日 -- <a href="http://www.5bay.cn/network-programming/phpfengzhuangchangyongjavascriptweijsleiyibiankuaisudiaoyong.html" title="PHP封装常用Javascript为JS类以便快速调用">PHP封装常用Javascript为JS类以便快速调用</a> (1)</li><li>2010年05月23日 -- <a href="http://www.5bay.cn/server-building/mysqlyouhuajiquanwensousuo.html" title="mysql优化及全文搜索">mysql优化及全文搜索</a> (0)</li><li>2010年07月26日 -- <a href="http://www.5bay.cn/network-programming/phpeeeeeeeehuai.html" title="PHP对文本数据库的基本操作方法">PHP对文本数据库的基本操作方法</a> (0)</li><li>2010年07月26日 -- <a href="http://www.5bay.cn/network-programming/ajaxeeee.html" title="Ajax的工作原理">Ajax的工作原理</a> (1)</li><li>2010年07月26日 -- <a href="http://www.5bay.cn/network-programming/ajax.html" title="AJAX的各种控件和类库">AJAX的各种控件和类库</a> (0)</li><li>2010年07月26日 -- <a href="http://www.5bay.cn/network-programming/xmlhttpe.html" title="XMLHTTP对象封装技术">XMLHTTP对象封装技术</a> (0)</li><li>2010年07月26日 -- <a href="http://www.5bay.cn/network-programming/ajaxxuan.html" title="ajax的缺点">ajax的缺点</a> (0)</li><li>2010年05月23日 -- <a href="http://www.5bay.cn/server-building/eacceleratoryumemcachedequbieyuyongtu.html" title="eAccelerator与memcache的区别与用途">eAccelerator与memcache的区别与用途</a> (2)</li><li>2010年07月26日 -- <a href="http://www.5bay.cn/network-programming/phpeecketee.html" title="PHP和Socket简介">PHP和Socket简介</a> (0)</li></ul>
	标签Tags：<a href="http://www.5bay.cn/tag/asp" title="ASP" rel="tag">ASP</a>, <a href="http://www.5bay.cn/tag/js" title="js" rel="tag">js</a>, <a href="http://www.5bay.cn/tag/sql" title="sql" rel="tag">sql</a>, <a href="http://www.5bay.cn/tag/url" title="url" rel="tag">url</a>, <a href="http://www.5bay.cn/tag/%E4%BA%BA" title="人" rel="tag">人</a>, <a href="http://www.5bay.cn/tag/%E4%BB%A3%E7%A0%81" title="代码" rel="tag">代码</a>, <a href="http://www.5bay.cn/tag/%E5%B7%A5%E5%85%B7" title="工具" rel="tag">工具</a>, <a href="http://www.5bay.cn/tag/%E6%95%B0%E6%8D%AE" title="数据" rel="tag">数据</a>, <a href="http://www.5bay.cn/tag/%E6%95%B0%E6%8D%AE%E5%BA%93" title="数据库" rel="tag">数据库</a>, <a href="http://www.5bay.cn/tag/%E6%96%B9%E6%B3%95" title="方法" rel="tag">方法</a>, <a href="http://www.5bay.cn/category/server-building" title="服务器构建&amp;安全" rel="tag">服务器构建&amp;安全</a>, <a href="http://www.5bay.cn/tag/%E7%A8%8B%E5%BA%8F" title="程序" rel="tag">程序</a>, <a href="http://www.5bay.cn/tag/%E7%B1%BB" title="类" rel="tag">类</a>, <a href="http://www.5bay.cn/tag/%E7%BD%91%E7%AB%99" title="网站" rel="tag">网站</a>, <a href="http://www.5bay.cn/tag/e" title="诫" rel="tag">诫</a>, <a href="http://www.5bay.cn/tag/%E8%BF%9E%E6%8E%A5" title="连接" rel="tag">连接</a>, <a href="http://www.5bay.cn/tag/%E9%98%B2%E6%B3%A8%E5%85%A5" title="防注入" rel="tag">防注入</a><br />
]]></content:encoded>
			<wfw:commentRss>http://www.5bay.cn/server-building/aspeaojie.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>AJAX的各种控件和类库</title>
		<link>http://www.5bay.cn/network-programming/ajax.html</link>
		<comments>http://www.5bay.cn/network-programming/ajax.html#comments</comments>
		<pubDate>Sun, 25 Jul 2010 16:49:49 +0000</pubDate>
		<dc:creator>江小邪</dc:creator>
				<category><![CDATA[JavaScript&Ajax]]></category>
		<category><![CDATA[网络编程]]></category>
		<category><![CDATA[ajax]]></category>
		<category><![CDATA[ASP]]></category>
		<category><![CDATA[asp.net]]></category>
		<category><![CDATA[css]]></category>
		<category><![CDATA[div]]></category>
		<category><![CDATA[html]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[js]]></category>
		<category><![CDATA[web]]></category>
		<category><![CDATA[xml]]></category>
		<category><![CDATA[xmlhttp]]></category>
		<category><![CDATA[人]]></category>
		<category><![CDATA[代码]]></category>
		<category><![CDATA[区别]]></category>
		<category><![CDATA[对象]]></category>
		<category><![CDATA[属性]]></category>
		<category><![CDATA[接口]]></category>
		<category><![CDATA[数据]]></category>
		<category><![CDATA[方法]]></category>
		<category><![CDATA[浏览器]]></category>
		<category><![CDATA[类]]></category>
		<category><![CDATA[节点]]></category>
		<category><![CDATA[获取]]></category>
		<category><![CDATA[错误]]></category>
		<category><![CDATA[页面]]></category>

		<guid isPermaLink="false">http://www.5bay.cn/?p=480</guid>
		<description><![CDATA[<a href="http://www.5bay.cn/network-programming/ajax.html"><img align="left" hspace="5" width="150" height="150" src="http://www.5bay.cn/wp-content/plugins/thumbnail-for-excerpts/tfe_no_thumb.png" class="alignleft wp-post-image tfe" alt="" title="" /></a>Ajax控件和类库现在真的太多了，不知不觉中增加了Ajax的神秘性和复杂性，看到版内很多人为此费解和伤神，决定发此贴谈谈本人对Ajax的观点，希望能让大家对Ajax有一个本质的认识。 　　观点一：Ajax和服务器端技术毫不相关 　　严格的说，与传统web开发相比，Ajax是完完全全的客户端技术。由于很多控件封装了客户端和服务器端的通信过程，因此很多问题也因通信而起。事实上，不论何种Ajax技术，服务器端都是返回的一个纯文本流，再由客户端来处理这个文本。这段文本可以是xml格式，也可以是一个Html片段，也可以是一段JavaScript脚本，或者仅是一个字符串。服务器端仅仅是作为一个数据接口，客户端使用XMLHttpRequest对象来请求这个页面，服务器端在页面内写入结果文本，这个过程和普通的web开发没有任何区别。所不同的只是，客户端在异步获取结果后，不是直接显示在页面，而是由客户端的Javascript脚本处理后再显示在页面。至于各种控件所谓的能返回DataSet对象，Date对象，或者其他的数据类型，都是封装了这个处理过程的结果。 　　观点二：DOM模型是Ajax最本质的技术 　　之所以没有把XMLHttpRequest列为最本质的技术，因为本人觉得它实在是太简单了，它只是可以让浏览器在后台请求一个页面，并将其内容交给JavaScript处理。真正的核心应该是：DOM模型，即文档对象模型。在DOM模型里，Html标记都被认为是一个对象，例如：div对象，table对象等等。DOM模型就规定了这些对象所具有的属性、方法和事件。通过这些性质，可以对一个已经显示于浏览器的页面进行内容的修改，例如增加节点、修改节点位置，删除节点等等。而不仅仅是一个innerHTML属性这么简单，虽然这是一个很有用的属性。 　　观点三：在使用Ajax控件前理解它们的实现 　　使用Ajax控件的确可以提高效率，但如果你空中楼阁般使用控件，那就得不偿失了。从一个控件换到另外一个控件又会有一个漫长的学习曲线。所以应该从底层了解其，况且Ajax实在不是什么高深的技术。其实任何东西的最底层其实都是简单的，但如果封装了这些底层的东西，事情会变得复杂和难以理解。以Asp.net为例，它的定制特性可以使得只要在方法前加上[ajax method]类似这样的标志就可以称为一个异步方法，相信这使得Asp.net的Ajax开发显得更加“高效”或者是“神秘”，而更多的事情则被封装了。同样记住一条，任何对服务器端的请求仅仅是返回纯文本，我们不一定要依赖于封装好的处理过程，而完全可以自己来实现。 　　观点四：学好JavaScript 　　在大多数人看来，JavaScript总不是那么一种正规的语言，随便copy一段就碰巧能运行，学过c之类的人，一看也能看懂，而且在浏览器中常常有脚本错误提示，所以潜意识觉得总不能付之以大任。事实上，要学好Ajax，这就完全是一种错误的看法。javascript作为一种脚本语言，其语法的确不是很严格，但并不妨碍其完成诸多复杂的任务，没有JavaScript，就没有Ajax。所以本人强烈建议，学Ajax前，一定要好好研究一番JavaScript，一般来讲，如果能顺利看懂prototype框架的代码（如：prototype-1.3.1.js），你的JavaScript水平就基本过关了。同时对DOM模型也可以算有一个基本的了解。 　　观点五：Ajax点缀：CSS 　　用JavaScript控制CSS其实很简单，基本上每个DOM对象都有一个style对象，只要把css属性里的”-”去掉，并让随后的字母变为大写就可以作为属性使用了，例如：element.style.backgroundColor=”#f00&#8243;;在css是：选择符 {background-color:#f00} 　　一口气说这么多，希望对大家有点用处。 相关博文2010年07月26日 -- XMLHTTP对象封装技术 (0)2010年07月26日 -- 基于JSON的高级AJAX开发技术 (0)2010年07月26日 -- Ajax的工作原理 (1)2010年07月26日 -- 使用Ajax时的十个常犯的错误 (0)2010年07月26日 -- ajax的缺点 (0)2010年07月26日 -- 了解Ajax中的Get和Post (0)2010年07月26日 -- PHP和Socket简介 (0)2010年05月23日 -- 《高性能网站建设指南》读书笔记 (0)2010年07月26日 -- AJAX应用程序开发七宗罪 (0)2010年07月26日 -- AJAX初学:IE缓存页面的问题 (0)2010年07月26日 -- ajax基础知识:js事件触发大全 (0)2010年07月26日 -- PHP安全之数据过滤 (0)2010年05月23日 -- mysql优化及全文搜索 (0)2010年05月23日 -- [...]]]></description>
			<content:encoded><![CDATA[<p>Ajax控件和类库现在真的太多了，不知不觉中增加了Ajax的神秘性和复杂性，看到版内很多人为此费解和伤神，决定发此贴谈谈本人对Ajax的观点，希望能让大家对Ajax有一个本质的认识。 </p>
<p>　　观点一：Ajax和服务器端技术毫不相关 </p>
<p>　　严格的说，与传统web开发相比，Ajax是完完全全的客户端技术。由于很多控件封装了客户端和服务器端的通信过程，因此很多问题也因通信而起。事实上，不论何种Ajax技术，服务器端都是返回的一个纯文本流，再由客户端来处理这个文本。这段文本可以是xml格式，也可以是一个Html片段，也可以是一段JavaScript脚本，或者仅是一个字符串。服务器端仅仅是作为一个数据接口，客户端使用XMLHttpRequest对象来请求这个页面，服务器端在页面内写入结果文本，这个过程和普通的web开发没有任何区别。所不同的只是，客户端在异步获取结果后，不是直接显示在页面，而是由客户端的Javascript脚本处理后再显示在页面。至于各种控件所谓的能返回DataSet对象，Date对象，或者其他的数据类型，都是封装了这个处理过程的结果。 </p>
<p>　　观点二：DOM模型是Ajax最本质的技术 </p>
<p>　　之所以没有把XMLHttpRequest列为最本质的技术，因为本人觉得它实在是太简单了，它只是可以让浏览器在后台请求一个页面，并将其内容交给JavaScript处理。真正的核心应该是：DOM模型，即文档对象模型。在DOM模型里，Html标记都被认为是一个对象，例如：div对象，table对象等等。DOM模型就规定了这些对象所具有的属性、方法和事件。通过这些性质，可以对一个已经显示于浏览器的页面进行内容的修改，例如增加节点、修改节点位置，删除节点等等。而不仅仅是一个innerHTML属性这么简单，虽然这是一个很有用的属性。 </p>
<p>　　观点三：在使用Ajax控件前理解它们的实现 </p>
<p>　　使用Ajax控件的确可以提高效率，但如果你空中楼阁般使用控件，那就得不偿失了。从一个控件换到另外一个控件又会有一个漫长的学习曲线。所以应该从底层了解其，况且Ajax实在不是什么高深的技术。其实任何东西的最底层其实都是简单的，但如果封装了这些底层的东西，事情会变得复杂和难以理解。以Asp.net为例，它的定制特性可以使得只要在方法前加上[ajax method]类似这样的标志就可以称为一个异步方法，相信这使得Asp.net的Ajax开发显得更加“高效”或者是“神秘”，而更多的事情则被封装了。同样记住一条，任何对服务器端的请求仅仅是返回纯文本，我们不一定要依赖于封装好的处理过程，而完全可以自己来实现。 </p>
<p>　　观点四：学好JavaScript </p>
<p>　　在大多数人看来，JavaScript总不是那么一种正规的语言，随便copy一段就碰巧能运行，学过c之类的人，一看也能看懂，而且在浏览器中常常有脚本错误提示，所以潜意识觉得总不能付之以大任。事实上，要学好Ajax，这就完全是一种错误的看法。javascript作为一种脚本语言，其语法的确不是很严格，但并不妨碍其完成诸多复杂的任务，没有JavaScript，就没有Ajax。所以本人强烈建议，学Ajax前，一定要好好研究一番JavaScript，一般来讲，如果能顺利看懂prototype框架的代码（如：prototype-1.3.1.js），你的JavaScript水平就基本过关了。同时对DOM模型也可以算有一个基本的了解。 </p>
<p>　　观点五：Ajax点缀：CSS </p>
<p>　　用JavaScript控制CSS其实很简单，基本上每个DOM对象都有一个style对象，只要把css属性里的”-”去掉，并让随后的字母变为大写就可以作为属性使用了，例如：element.style.backgroundColor=”#f00&#8243;;在css是：选择符 {background-color:#f00} </p>
<p>　　一口气说这么多，希望对大家有点用处。 </p>
<h2  class="related_post_title">相关博文</h2><ul class="related_post"><li>2010年07月26日 -- <a href="http://www.5bay.cn/network-programming/xmlhttpe.html" title="XMLHTTP对象封装技术">XMLHTTP对象封装技术</a> (0)</li><li>2010年07月26日 -- <a href="http://www.5bay.cn/network-programming/eesoneeajaxeehuai.html" title="基于JSON的高级AJAX开发技术">基于JSON的高级AJAX开发技术</a> (0)</li><li>2010年07月26日 -- <a href="http://www.5bay.cn/network-programming/ajaxeeee.html" title="Ajax的工作原理">Ajax的工作原理</a> (1)</li><li>2010年07月26日 -- <a href="http://www.5bay.cn/network-programming/eejaxeeeeee.html" title="使用Ajax时的十个常犯的错误">使用Ajax时的十个常犯的错误</a> (0)</li><li>2010年07月26日 -- <a href="http://www.5bay.cn/network-programming/ajaxxuan.html" title="ajax的缺点">ajax的缺点</a> (0)</li><li>2010年07月26日 -- <a href="http://www.5bay.cn/network-programming/eejaxeeetpit.html" title="了解Ajax中的Get和Post ">了解Ajax中的Get和Post </a> (0)</li><li>2010年07月26日 -- <a href="http://www.5bay.cn/network-programming/phpeecketee.html" title="PHP和Socket简介">PHP和Socket简介</a> (0)</li><li>2010年05月23日 -- <a href="http://www.5bay.cn/server-building/gaoxingnengwangzhanjianshezhinandushubiji.html" title="《高性能网站建设指南》读书笔记">《高性能网站建设指南》读书笔记</a> (0)</li><li>2010年07月26日 -- <a href="http://www.5bay.cn/network-programming/ajaxeeaoe.html" title="AJAX应用程序开发七宗罪">AJAX应用程序开发七宗罪</a> (0)</li><li>2010年07月26日 -- <a href="http://www.5bay.cn/network-programming/ajaxeeieeeeeting.html" title="AJAX初学:IE缓存页面的问题">AJAX初学:IE缓存页面的问题</a> (0)</li><li>2010年07月26日 -- <a href="http://www.5bay.cn/network-programming/ajaxeeeeseeao.html" title="ajax基础知识:js事件触发大全">ajax基础知识:js事件触发大全</a> (0)</li><li>2010年07月26日 -- <a href="http://www.5bay.cn/network-programming/phpeezhanchang.html" title="PHP安全之数据过滤">PHP安全之数据过滤</a> (0)</li><li>2010年05月23日 -- <a href="http://www.5bay.cn/server-building/mysqlyouhuajiquanwensousuo.html" title="mysql优化及全文搜索">mysql优化及全文搜索</a> (0)</li><li>2010年05月23日 -- <a href="http://www.5bay.cn/network-programming/phpzhongdememcachehanshukumemcachefunctions.html" title="PHP中的Memcache函数库（Memcache Functions）">PHP中的Memcache函数库（Memcache Functions）</a> (0)</li><li>2010年07月28日 -- <a href="http://www.5bay.cn/server-building/aspeaojie.html" title="ASP防注入新方式，希望对大家是有用的">ASP防注入新方式，希望对大家是有用的</a> (0)</li></ul>
	标签Tags：<a href="http://www.5bay.cn/tag/ajax" title="ajax" rel="tag">ajax</a>, <a href="http://www.5bay.cn/tag/asp" title="ASP" rel="tag">ASP</a>, <a href="http://www.5bay.cn/tag/aspnet" title="asp.net" rel="tag">asp.net</a>, <a href="http://www.5bay.cn/tag/css" title="css" rel="tag">css</a>, <a href="http://www.5bay.cn/tag/div" title="div" rel="tag">div</a>, <a href="http://www.5bay.cn/tag/html" title="html" rel="tag">html</a>, <a href="http://www.5bay.cn/tag/javascript" title="javascript" rel="tag">javascript</a>, <a href="http://www.5bay.cn/category/network-programming/javascript-ajax" title="JavaScript&amp;Ajax" rel="tag">JavaScript&amp;Ajax</a>, <a href="http://www.5bay.cn/tag/js" title="js" rel="tag">js</a>, <a href="http://www.5bay.cn/tag/web" title="web" rel="tag">web</a>, <a href="http://www.5bay.cn/tag/xml" title="xml" rel="tag">xml</a>, <a href="http://www.5bay.cn/tag/xmlhttp" title="xmlhttp" rel="tag">xmlhttp</a>, <a href="http://www.5bay.cn/tag/%E4%BA%BA" title="人" rel="tag">人</a>, <a href="http://www.5bay.cn/tag/%E4%BB%A3%E7%A0%81" title="代码" rel="tag">代码</a>, <a href="http://www.5bay.cn/tag/%E5%8C%BA%E5%88%AB" title="区别" rel="tag">区别</a>, <a href="http://www.5bay.cn/tag/%E5%AF%B9%E8%B1%A1" title="对象" rel="tag">对象</a>, <a href="http://www.5bay.cn/tag/%E5%B1%9E%E6%80%A7" title="属性" rel="tag">属性</a>, <a href="http://www.5bay.cn/tag/%E6%8E%A5%E5%8F%A3" title="接口" rel="tag">接口</a>, <a href="http://www.5bay.cn/tag/%E6%95%B0%E6%8D%AE" title="数据" rel="tag">数据</a>, <a href="http://www.5bay.cn/tag/%E6%96%B9%E6%B3%95" title="方法" rel="tag">方法</a>, <a href="http://www.5bay.cn/tag/%E6%B5%8F%E8%A7%88%E5%99%A8" title="浏览器" rel="tag">浏览器</a>, <a href="http://www.5bay.cn/tag/%E7%B1%BB" title="类" rel="tag">类</a>, <a href="http://www.5bay.cn/category/network-programming" title="网络编程" rel="tag">网络编程</a>, <a href="http://www.5bay.cn/tag/%E8%8A%82%E7%82%B9" title="节点" rel="tag">节点</a>, <a href="http://www.5bay.cn/tag/%E8%8E%B7%E5%8F%96" title="获取" rel="tag">获取</a>, <a href="http://www.5bay.cn/tag/%E9%94%99%E8%AF%AF" title="错误" rel="tag">错误</a>, <a href="http://www.5bay.cn/tag/%E9%A1%B5%E9%9D%A2" title="页面" rel="tag">页面</a><br />
]]></content:encoded>
			<wfw:commentRss>http://www.5bay.cn/network-programming/ajax.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>innerHTML、innerText和outerHTML的用法</title>
		<link>http://www.5bay.cn/network-programming/innerhtmleenertexteeterhtmlqia.html</link>
		<comments>http://www.5bay.cn/network-programming/innerhtmleenertexteeterhtmlqia.html#comments</comments>
		<pubDate>Sun, 25 Jul 2010 16:46:30 +0000</pubDate>
		<dc:creator>江小邪</dc:creator>
				<category><![CDATA[JavaScript&Ajax]]></category>
		<category><![CDATA[网络编程]]></category>
		<category><![CDATA[div]]></category>
		<category><![CDATA[html]]></category>
		<category><![CDATA[ie]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[js]]></category>
		<category><![CDATA[对象]]></category>
		<category><![CDATA[属性]]></category>
		<category><![CDATA[正则表达式]]></category>
		<category><![CDATA[浏览器]]></category>
		<category><![CDATA[诫]]></category>
		<category><![CDATA[说明]]></category>

		<guid isPermaLink="false">http://www.5bay.cn/?p=474</guid>
		<description><![CDATA[<a href="http://www.5bay.cn/network-programming/innerhtmleenertexteeterhtmlqia.html"><img align="left" hspace="5" width="150" height="150" src="http://www.5bay.cn/wp-content/plugins/thumbnail-for-excerpts/tfe_no_thumb.png" class="alignleft wp-post-image tfe" alt="" title="" /></a>用法： &#60;div id=”test”&#62; &#60;span style=”color:red”&#62;test1&#60;/span&#62; test2 &#60;/div&#62; 在JS中可以使用： test.innerHTML: 　　也就是从对象的起始位置到终止位置的全部内容,包括Html标签。 　　上例中的test.innerHTML的值也就是“&#60;span style=”color:red”&#62;test1&#60;/span&#62; test2 ”。 test.innerText: 　　从起始位置到终止位置的内容, 但它去除Html标签 　　上例中的text.innerTest的值也就是“test1 test2”, 其中span标签去除了。 test.outerHTML: 　　除了包含innerHTML的全部内容外, 还包含对象标签本身。 　　上例中的text.outerHTML的值也就是&#60;div id=”test”&#62;&#60;span style=”color:red”&#62;test1&#60;/span&#62; test2&#60;/div&#62; 完整示例： &#60;div id=”test”&#62; &#60;span style=”color:red”&#62;test1&#60;/span&#62; test2 &#60;/div&#62; &#60;a href=”javascript:alert(test.innerHTML)”&#62;innerHTML内容&#60;/a&#62; &#60;a href=”javascript:alert(test.innerText)”&#62;inerHTML内容&#60;/a&#62; &#60;a href=”javascript:alert(test.outerHTML)”&#62;outerHTML内容&#60;/a&#62; 特别说明： 　　innerHTML是符合W3C标准的属性，而innerText只适用于IE浏览器，因此，尽可能地去使用innerHTML，而少用innerText，如果要输出不含HTML标签的内容，可以使用innerHTML取得包含HTML标签的内容后，再用正则表达式去除HTML标签，下面是一个简单的符合W3C标准的示例： &#60;a href=”javascript:alert(document.getElementById(&#8216;test&#8217;).innerHTML.replace(/&#60;.+?&#62;/gim,”))”&#62;无HTML,符合W3C标准&#60;/a&#62; 相关博文2010年07月26日 -- Ajax的工作原理 (1)2010年07月26日 -- 基于JSON的高级AJAX开发技术 (0)2010年07月26日 -- AJAX的各种控件和类库 (0)2010年07月26日 -- [...]]]></description>
			<content:encoded><![CDATA[<p>用法：</p>
<p>&lt;<a href="http://www.5bay.cn/tag/div" class="st_tag internal_tag" rel="tag" title="标签 div 下的日志">div</a> id=”test”&gt;<br />
&lt;span style=”color:red”&gt;test1&lt;/span&gt; test2<br />
&lt;/div&gt;</p>
<p>在JS中可以使用：</p>
<p>test.innerHTML:</p>
<p>　　也就是从对象的起始位置到终止位置的全部内容,包括Html标签。<br />
　　上例中的test.innerHTML的值也就是“&lt;span style=”color:red”&gt;test1&lt;/span&gt; test2 ”。</p>
<p>test.innerText:</p>
<p>　　从起始位置到终止位置的内容, 但它去除Html标签<br />
　　上例中的text.innerTest的值也就是“test1 test2”, 其中span标签去除了。</p>
<p>test.outerHTML:</p>
<p>　　除了包含innerHTML的全部内容外, 还包含对象标签本身。<br />
　　上例中的text.outerHTML的值也就是&lt;div id=”test”&gt;&lt;span style=”color:red”&gt;test1&lt;/span&gt; test2&lt;/div&gt;</p>
<p>完整示例：</p>
<p>&lt;div id=”test”&gt;<br />
&lt;span style=”color:red”&gt;test1&lt;/span&gt; test2<br />
&lt;/div&gt;</p>
<p>&lt;a href=”<a href="http://www.5bay.cn/tag/javascript" class="st_tag internal_tag" rel="tag" title="标签 javascript 下的日志">javascript</a>:alert(test.innerHTML)”&gt;innerHTML内容&lt;/a&gt;<br />
&lt;a href=”javascript:alert(test.innerText)”&gt;inerHTML内容&lt;/a&gt;<br />
&lt;a href=”javascript:alert(test.outerHTML)”&gt;outerHTML内容&lt;/a&gt;</p>
<p>特别说明：</p>
<p>　　innerHTML是符合W3C标准的属性，而innerText只适用于IE浏览器，因此，尽可能地去使用innerHTML，而少用innerText，如果要输出不含HTML标签的内容，可以使用innerHTML取得包含HTML标签的内容后，再用正则表达式去除HTML标签，下面是一个简单的符合W3C标准的示例：</p>
<p>&lt;a href=”javascript:alert(document.getElementById(&#8216;test&#8217;).innerHTML.replace(/&lt;.+?&gt;/gim,”))”&gt;无HTML,符合W3C标准&lt;/a&gt;</p>
<h2  class="related_post_title">相关博文</h2><ul class="related_post"><li>2010年07月26日 -- <a href="http://www.5bay.cn/network-programming/ajaxeeee.html" title="Ajax的工作原理">Ajax的工作原理</a> (1)</li><li>2010年07月26日 -- <a href="http://www.5bay.cn/network-programming/eesoneeajaxeehuai.html" title="基于JSON的高级AJAX开发技术">基于JSON的高级AJAX开发技术</a> (0)</li><li>2010年07月26日 -- <a href="http://www.5bay.cn/network-programming/ajax.html" title="AJAX的各种控件和类库">AJAX的各种控件和类库</a> (0)</li><li>2010年07月26日 -- <a href="http://www.5bay.cn/network-programming/xmlhttpe.html" title="XMLHTTP对象封装技术">XMLHTTP对象封装技术</a> (0)</li><li>2010年07月26日 -- <a href="http://www.5bay.cn/network-programming/ajaxxuan.html" title="ajax的缺点">ajax的缺点</a> (0)</li><li>2010年05月23日 -- <a href="http://www.5bay.cn/server-building/nginxderewriteguize.html" title="nginx的rewrite规则">nginx的rewrite规则</a> (1)</li><li>2010年07月28日 -- <a href="http://www.5bay.cn/server-building/webshelleechueeee.html" title="Webshell下破解计算机管理员密码">Webshell下破解计算机管理员密码</a> (0)</li><li>2010年07月26日 -- <a href="http://www.5bay.cn/network-programming/ajaxeeaoe.html" title="AJAX应用程序开发七宗罪">AJAX应用程序开发七宗罪</a> (0)</li><li>2010年07月26日 -- <a href="http://www.5bay.cn/network-programming/eejaxeeeeee.html" title="使用Ajax时的十个常犯的错误">使用Ajax时的十个常犯的错误</a> (0)</li><li>2010年07月26日 -- <a href="http://www.5bay.cn/network-programming/ajaxeeeeseeao.html" title="ajax基础知识:js事件触发大全">ajax基础知识:js事件触发大全</a> (0)</li><li>2010年05月23日 -- <a href="http://www.5bay.cn/network-programming/tupianlunhuanleiie7opffchromeceshitongguo.html" title="图片轮换类，IE7、OP、FF、Chrome测试通过">图片轮换类，IE7、OP、FF、Chrome测试通过</a> (2)</li><li>2011年06月29日 -- <a href="http://www.5bay.cn/android%e7%ac%94%e8%ae%b0/androidzaixiankaifagongjuappinventor.html" title="Android在线开发工具 App Inventor">Android在线开发工具 App Inventor</a> (0)</li><li>2010年07月28日 -- <a href="http://www.5bay.cn/server-building/aoeempirebakeebshell.html" title="帝国备份王(Empirebak)拿webshell">帝国备份王(Empirebak)拿webshell</a> (0)</li><li>2010年07月26日 -- <a href="http://www.5bay.cn/network-programming/phpeefangeredoc.html" title="php的文档句法(heredoc)<<<和PHP字符串操作">php的文档句法(heredoc)<<<和PHP字符串操作</a> (0)</li><li>2010年07月22日 -- <a href="http://www.5bay.cn/me/csseeeeyao.html" title="CSS 中的太极拳口诀">CSS 中的太极拳口诀</a> (0)</li></ul>
	标签Tags：<a href="http://www.5bay.cn/tag/div" title="div" rel="tag">div</a>, <a href="http://www.5bay.cn/tag/html" title="html" rel="tag">html</a>, <a href="http://www.5bay.cn/tag/ie" title="ie" rel="tag">ie</a>, <a href="http://www.5bay.cn/tag/javascript" title="javascript" rel="tag">javascript</a>, <a href="http://www.5bay.cn/category/network-programming/javascript-ajax" title="JavaScript&amp;Ajax" rel="tag">JavaScript&amp;Ajax</a>, <a href="http://www.5bay.cn/tag/js" title="js" rel="tag">js</a>, <a href="http://www.5bay.cn/tag/%E5%AF%B9%E8%B1%A1" title="对象" rel="tag">对象</a>, <a href="http://www.5bay.cn/tag/%E5%B1%9E%E6%80%A7" title="属性" rel="tag">属性</a>, <a href="http://www.5bay.cn/tag/%E6%AD%A3%E5%88%99%E8%A1%A8%E8%BE%BE%E5%BC%8F" title="正则表达式" rel="tag">正则表达式</a>, <a href="http://www.5bay.cn/tag/%E6%B5%8F%E8%A7%88%E5%99%A8" title="浏览器" rel="tag">浏览器</a>, <a href="http://www.5bay.cn/category/network-programming" title="网络编程" rel="tag">网络编程</a>, <a href="http://www.5bay.cn/tag/e" title="诫" rel="tag">诫</a>, <a href="http://www.5bay.cn/tag/%E8%AF%B4%E6%98%8E" title="说明" rel="tag">说明</a><br />
]]></content:encoded>
			<wfw:commentRss>http://www.5bay.cn/network-programming/innerhtmleenertexteeterhtmlqia.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>XMLHTTP对象封装技术</title>
		<link>http://www.5bay.cn/network-programming/xmlhttpe.html</link>
		<comments>http://www.5bay.cn/network-programming/xmlhttpe.html#comments</comments>
		<pubDate>Sun, 25 Jul 2010 16:43:39 +0000</pubDate>
		<dc:creator>江小邪</dc:creator>
				<category><![CDATA[JavaScript&Ajax]]></category>
		<category><![CDATA[网络编程]]></category>
		<category><![CDATA[ajax]]></category>
		<category><![CDATA[code]]></category>
		<category><![CDATA[div]]></category>
		<category><![CDATA[html]]></category>
		<category><![CDATA[js]]></category>
		<category><![CDATA[url]]></category>
		<category><![CDATA[xml]]></category>
		<category><![CDATA[xmlhttp]]></category>
		<category><![CDATA[中文]]></category>
		<category><![CDATA[人]]></category>
		<category><![CDATA[代码]]></category>
		<category><![CDATA[初始值]]></category>
		<category><![CDATA[区别]]></category>
		<category><![CDATA[对象]]></category>
		<category><![CDATA[属性]]></category>
		<category><![CDATA[数据]]></category>
		<category><![CDATA[方法]]></category>
		<category><![CDATA[获取]]></category>
		<category><![CDATA[表单]]></category>
		<category><![CDATA[诫]]></category>
		<category><![CDATA[错误]]></category>
		<category><![CDATA[页面]]></category>

		<guid isPermaLink="false">http://www.5bay.cn/?p=470</guid>
		<description><![CDATA[<a href="http://www.5bay.cn/network-programming/xmlhttpe.html"><img align="left" hspace="5" width="150" height="150" src="http://www.5bay.cn/wp-content/plugins/thumbnail-for-excerpts/tfe_no_thumb.png" class="alignleft wp-post-image tfe" alt="" title="" /></a>Ajax技术的实现主要依赖于xmlhttprequest，但我们在调用其来进行异步数据的传输时，由于xmlhttp是个短线过程（处理事件完成后就销毁）如果不对该对象进行包装处理的话，就不得不在需要调用的地方重新构建xmlhttprequest，每次调用都要写一大段的代码，实在不是个好办法。好在现在很多开源的ajax框架都提供了对xmlhttp封装的方案。这里以ajaxtags自带的prototype-1.4.0.js为母版，来看看如何将xmlhttp对象封装成一个可复用的方法。 在prototype.js中，首先定义了一个变量：Ajax var Ajax = { getTransport: function() { return Try.these( function() {return new ActiveXObject(&#8216;Msxml2.XMLHTTP&#8217;)}, function() {return new ActiveXObject(&#8216;Microsoft.XMLHTTP&#8217;)}, function() {return new XMLHttpRequest()} ) &#124;&#124; false; }, activeRequestCount: 0 } 变量返回了一个xmlhttprequest，可以看到，如果我们调用了Ajax.getTransport()，每次都会返回一个新的xmlhttprequest对象。 在Ajax变量中定义了一个基础方法Ajax.Base和该基础方法的原型（初始时，每个脚本方法默认都有个空的原型，该原型会继承Object的原型，如果我们在Object中改变了原型，则所有的脚本方法都会被改变。） 该基础方法被Ajax.Request所继承，注意的是，如果在Ajax.Request中填充了继承的原型的同名方法或变量，则会实现重载。 Ajax.Base原型中最主要的是setOptions方法，过会我们就会用到。 setOptions: function(options) { this.options = { method: &#8216;post&#8217;, asynchronous: true, parameters: ” } prototype中对request是通过定义Ajax.Request原型（Ajax.Request.prototype）来实现的。 但我们并不能直接对Ajax.Request进行调用，主要原因是Ajax.Request并没有提供一个统一处理的过程。而且我们可能需要通过request 再取得response。（试想一下，客户那边发出一条信息，都始终没与收到回复，那是会让人觉得很恼火的事~），prototype同样为我们封装好了resoponse（Ajax.Responders），但两者都是相互独立的，如何把他们进行整合呢？ 在 prototype中给我们提供了两个方案，一个是Ajax.Updater，另一个是Ajax.PeriodicalUpdater，两个共同点都是必须传入3个参数： container： response数据要传达的位置，该位置通过html标签的id进行定义，比如你要把返回的数据输出到html中的某个＜div＞中，则只要把container改成该id的值就可以了。如果找不到该container，则会发生脚本错误。 url： [...]]]></description>
			<content:encoded><![CDATA[<p>Ajax技术的实现主要依赖于xmlhttprequest，但我们在调用其来进行异步数据的传输时，由于xmlhttp是个短线过程（处理事件完成后就销毁）如果不对该对象进行包装处理的话，就不得不在需要调用的地方重新构建xmlhttprequest，每次调用都要写一大段的代码，实在不是个好办法。好在现在很多开源的ajax框架都提供了对xmlhttp封装的方案。这里以ajaxtags自带的prototype-1.4.0.js为母版，来看看如何将xmlhttp对象封装成一个可复用的方法。</p>
<p>在prototype.js中，首先定义了一个变量：<a href="http://www.5bay.cn/tag/ajax" class="st_tag internal_tag" rel="tag" title="标签 ajax 下的日志">Ajax</a><br />
var Ajax = {<br />
getTransport: function() {<br />
return Try.these(<br />
function() {return new ActiveXObject(&#8216;Msxml2.XMLHTTP&#8217;)},<br />
function() {return new ActiveXObject(&#8216;Microsoft.XMLHTTP&#8217;)},<br />
function() {return new XMLHttpRequest()}<br />
) || false;<br />
},</p>
<p>activeRequestCount: 0<br />
}</p>
<p>变量返回了一个xmlhttprequest，可以看到，如果我们调用了Ajax.getTransport()，每次都会返回一个新的xmlhttprequest对象。<br />
<span id="more-470"></span><br />
在Ajax变量中定义了一个基础方法Ajax.Base和该基础方法的原型（初始时，每个脚本方法默认都有个空的原型，该原型会继承Object的原型，如果我们在Object中改变了原型，则所有的脚本方法都会被改变。） 该基础方法被Ajax.Request所继承，注意的是，如果在Ajax.Request中填充了继承的原型的同名方法或变量，则会实现重载。</p>
<p>Ajax.Base原型中最主要的是setOptions方法，过会我们就会用到。<br />
setOptions: function(options) {<br />
this.options = {<br />
method: &#8216;post&#8217;,<br />
asynchronous: true,<br />
parameters: ”<br />
}</p>
<p>prototype中对request是通过定义Ajax.Request原型（Ajax.Request.prototype）来实现的。</p>
<p>但我们并不能直接对Ajax.Request进行调用，主要原因是Ajax.Request并没有提供一个统一处理的过程。而且我们可能需要通过request 再取得response。（试想一下，客户那边发出一条信息，都始终没与收到回复，那是会让人觉得很恼火的事~），prototype同样为我们封装好了resoponse（Ajax.Responders），但两者都是相互独立的，如何把他们进行整合呢？</p>
<p>在 prototype中给我们提供了两个方案，一个是Ajax.Updater，另一个是Ajax.PeriodicalUpdater，两个共同点都是必须传入3个参数：</p>
<p>container：</p>
<p>response数据要传达的位置，该位置通过html标签的id进行定义，比如你要把返回的数据输出到html中的某个＜<a href="http://www.5bay.cn/tag/div" class="st_tag internal_tag" rel="tag" title="标签 div 下的日志">div</a>＞中，则只要把container改成该id的值就可以了。如果找不到该container，则会发生脚本错误。</p>
<p><a href="http://www.5bay.cn/tag/url" class="st_tag internal_tag" rel="tag" title="标签 url 下的日志">url</a>：</p>
<p>request请求要传递的目的地。该目的地应该是个servlet或jspservlet，因为request对象只能被servlet中的do***方法自动获取。</p>
<p>options：</p>
<p>结构应该与上面Ajax.Base定义的setOptions（）中的option结构相同，如果为空或不写，则采用 Ajax.Base定义的初始值（没有传递任何参数时使用）。</p>
<p>两者的区别在与Ajax.Updater返回给container的是完整的responseText，只有在responseText完全取得又没发生异常时才会把内容写到container里面，而PeriodicalUpdater在获取responseText时，不管是否已经完整取得，就把内容填进container，直到发生异常或完全取得responseText。大多数情况应该使用第一种方法，因为第一种方法在发生异常时会把异常信息显示在container里面，而第二种就不一定了。</p>
<p>既然已经把xmlhttp封装好了，我们只需要设置好前面所说的3个参数就可以了，要注意的是，设置options参数，一定要按照base中的options结构进行设置，如果我们使用post方法，还可以在opitons中设置postBody属性，把要传递的queryString 放到body中,一个使用post方法进行传递的脚本例子如下：</p>
<p>/*表单提交用post方法*/<br />
function doRequest(container,paraments,url){<br />
var options ={<br />
method: &#8216;post&#8217;,<br />
asynchronous: true,<br />
postBody: paraments<br />
};<br />
new Ajax.Updater(container,url,options);<br />
}</p>
<p>最后不得不说的是中文编码问题，prototype对传递的参数都进行了编码转换工作，每个传递值通过encodeURIComponent　进行了处理．编码会被转换成utf－8，在后台获取request时，应该统一使用request.setCharacterEncoding(“UTF-8&#8243;)对request设置编码，而不必管页面的编码格式是什么．如果使用post方法进行传递数据，则会自动执行:</p>
<p>request．setHeader(&#8216;Content-type&#8217;,'application/x-www-form-urlencoded&#8217;).确保传递数据编码格式的正确.</p>
<h2  class="related_post_title">相关博文</h2><ul class="related_post"><li>2010年07月26日 -- <a href="http://www.5bay.cn/network-programming/ajax.html" title="AJAX的各种控件和类库">AJAX的各种控件和类库</a> (0)</li><li>2010年07月26日 -- <a href="http://www.5bay.cn/network-programming/eesoneeajaxeehuai.html" title="基于JSON的高级AJAX开发技术">基于JSON的高级AJAX开发技术</a> (0)</li><li>2010年07月26日 -- <a href="http://www.5bay.cn/network-programming/ajaxeeee.html" title="Ajax的工作原理">Ajax的工作原理</a> (1)</li><li>2010年07月26日 -- <a href="http://www.5bay.cn/network-programming/eejaxeeeeee.html" title="使用Ajax时的十个常犯的错误">使用Ajax时的十个常犯的错误</a> (0)</li><li>2010年07月26日 -- <a href="http://www.5bay.cn/network-programming/ajaxxuan.html" title="ajax的缺点">ajax的缺点</a> (0)</li><li>2010年07月26日 -- <a href="http://www.5bay.cn/network-programming/eeeeeeee.html" title="最令PHP初学者头痛的十四个问题">最令PHP初学者头痛的十四个问题</a> (0)</li><li>2010年07月26日 -- <a href="http://www.5bay.cn/network-programming/phpeezhanchang.html" title="PHP安全之数据过滤">PHP安全之数据过滤</a> (0)</li><li>2010年07月26日 -- <a href="http://www.5bay.cn/network-programming/ajaxeeaoe.html" title="AJAX应用程序开发七宗罪">AJAX应用程序开发七宗罪</a> (0)</li><li>2010年07月26日 -- <a href="http://www.5bay.cn/network-programming/ajaxeeieeeeeting.html" title="AJAX初学:IE缓存页面的问题">AJAX初学:IE缓存页面的问题</a> (0)</li><li>2010年07月26日 -- <a href="http://www.5bay.cn/network-programming/eejaxeeetpit.html" title="了解Ajax中的Get和Post ">了解Ajax中的Get和Post </a> (0)</li><li>2010年07月28日 -- <a href="http://www.5bay.cn/server-building/aspeaojie.html" title="ASP防注入新方式，希望对大家是有用的">ASP防注入新方式，希望对大家是有用的</a> (0)</li><li>2010年07月26日 -- <a href="http://www.5bay.cn/network-programming/phpeecketee.html" title="PHP和Socket简介">PHP和Socket简介</a> (0)</li><li>2010年07月26日 -- <a href="http://www.5bay.cn/network-programming/phpeeeeeeeehuai.html" title="PHP对文本数据库的基本操作方法">PHP对文本数据库的基本操作方法</a> (0)</li><li>2010年05月23日 -- <a href="http://www.5bay.cn/server-building/mysqlyouhuajiquanwensousuo.html" title="mysql优化及全文搜索">mysql优化及全文搜索</a> (0)</li><li>2010年05月23日 -- <a href="http://www.5bay.cn/network-programming/phpzhongdememcachehanshukumemcachefunctions.html" title="PHP中的Memcache函数库（Memcache Functions）">PHP中的Memcache函数库（Memcache Functions）</a> (0)</li></ul>
	标签Tags：<a href="http://www.5bay.cn/tag/ajax" title="ajax" rel="tag">ajax</a>, <a href="http://www.5bay.cn/tag/code" title="code" rel="tag">code</a>, <a href="http://www.5bay.cn/tag/div" title="div" rel="tag">div</a>, <a href="http://www.5bay.cn/tag/html" title="html" rel="tag">html</a>, <a href="http://www.5bay.cn/category/network-programming/javascript-ajax" title="JavaScript&amp;Ajax" rel="tag">JavaScript&amp;Ajax</a>, <a href="http://www.5bay.cn/tag/js" title="js" rel="tag">js</a>, <a href="http://www.5bay.cn/tag/url" title="url" rel="tag">url</a>, <a href="http://www.5bay.cn/tag/xml" title="xml" rel="tag">xml</a>, <a href="http://www.5bay.cn/tag/xmlhttp" title="xmlhttp" rel="tag">xmlhttp</a>, <a href="http://www.5bay.cn/tag/%E4%B8%AD%E6%96%87" title="中文" rel="tag">中文</a>, <a href="http://www.5bay.cn/tag/%E4%BA%BA" title="人" rel="tag">人</a>, <a href="http://www.5bay.cn/tag/%E4%BB%A3%E7%A0%81" title="代码" rel="tag">代码</a>, <a href="http://www.5bay.cn/tag/%E5%88%9D%E5%A7%8B%E5%80%BC" title="初始值" rel="tag">初始值</a>, <a href="http://www.5bay.cn/tag/%E5%8C%BA%E5%88%AB" title="区别" rel="tag">区别</a>, <a href="http://www.5bay.cn/tag/%E5%AF%B9%E8%B1%A1" title="对象" rel="tag">对象</a>, <a href="http://www.5bay.cn/tag/%E5%B1%9E%E6%80%A7" title="属性" rel="tag">属性</a>, <a href="http://www.5bay.cn/tag/%E6%95%B0%E6%8D%AE" title="数据" rel="tag">数据</a>, <a href="http://www.5bay.cn/tag/%E6%96%B9%E6%B3%95" title="方法" rel="tag">方法</a>, <a href="http://www.5bay.cn/category/network-programming" title="网络编程" rel="tag">网络编程</a>, <a href="http://www.5bay.cn/tag/%E8%8E%B7%E5%8F%96" title="获取" rel="tag">获取</a>, <a href="http://www.5bay.cn/tag/%E8%A1%A8%E5%8D%95" title="表单" rel="tag">表单</a>, <a href="http://www.5bay.cn/tag/e" title="诫" rel="tag">诫</a>, <a href="http://www.5bay.cn/tag/%E9%94%99%E8%AF%AF" title="错误" rel="tag">错误</a>, <a href="http://www.5bay.cn/tag/%E9%A1%B5%E9%9D%A2" title="页面" rel="tag">页面</a><br />
]]></content:encoded>
			<wfw:commentRss>http://www.5bay.cn/network-programming/xmlhttpe.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>ajax基础知识:js事件触发大全</title>
		<link>http://www.5bay.cn/network-programming/ajaxeeeeseeao.html</link>
		<comments>http://www.5bay.cn/network-programming/ajaxeeeeseeao.html#comments</comments>
		<pubDate>Sun, 25 Jul 2010 16:42:48 +0000</pubDate>
		<dc:creator>江小邪</dc:creator>
				<category><![CDATA[JavaScript&Ajax]]></category>
		<category><![CDATA[网络编程]]></category>
		<category><![CDATA[ajax]]></category>
		<category><![CDATA[js]]></category>
		<category><![CDATA[menu]]></category>
		<category><![CDATA[seo]]></category>
		<category><![CDATA[web]]></category>
		<category><![CDATA[大全]]></category>
		<category><![CDATA[容器]]></category>
		<category><![CDATA[对象]]></category>
		<category><![CDATA[属性]]></category>
		<category><![CDATA[数据]]></category>
		<category><![CDATA[浏览器]]></category>
		<category><![CDATA[系统]]></category>
		<category><![CDATA[页面]]></category>
		<category><![CDATA[鼠标]]></category>

		<guid isPermaLink="false">http://www.5bay.cn/?p=468</guid>
		<description><![CDATA[<a href="http://www.5bay.cn/network-programming/ajaxeeeeseeao.html"><img align="left" hspace="5" width="150" height="150" src="http://www.5bay.cn/wp-content/plugins/thumbnail-for-excerpts/tfe_no_thumb.png" class="alignleft wp-post-image tfe" alt="" title="" /></a>onactivate 当对象设置为活动元素时触发。 onbeforeactivate 对象要被设置为当前元素前立即触发。 onbeforecut 当选中区从文档中删除之前在源对象触发。 onbeforedeactivate 在 activeElement 从当前对象变为父文档其它对象之前立即触发。 onbeforeeditfocus 在包含于可编辑元素内的对象进入用户界面激活状态前或可编辑容器变成控件选中区前触发。 onbeforepaste 在选中区从系统剪贴板粘贴到文档前在目标对象上触发。 onclick 在用户用鼠标左键单击对象时触发。 oncontextmenu 在用户使用鼠标右键单击客户区打开上下文菜单时触发。 oncontrolselect 当用户将要对该对象制作一个控件选中区时触发。 oncut 当对象或选中区从文档中删除并添加到系统剪贴板上时在源元素上触发。 ondblclick 当用户双击对象时触发。 ondeactivate 当 activeElement 从当前对象变为父文档其它对象时触发。 ondrag 当进行拖曳操作时在源对象上持续触发。 ondragend 当用户在拖曳操作结束后释放鼠标时在源对象上触发。 ondragenter 当用户拖曳对象到一个合法拖曳目标时在目标元素上触发。 ondragleave 当用户在拖曳操作过程中将鼠标移出合法拖曳目标时在目标对象上触发。 ondragover 当用户拖曳对象划过合法拖曳目标时持续在目标元素上触发。 ondragstart 当用户开始拖曳文本选中区或选中对象时在源对象上触发。 ondrop 当鼠标按钮在拖曳操作过程中释放时在目标对象上触发。 onfocusin 当元素将要被设置为焦点之前触发。 onfocusout 在移动焦点到其它元素之后立即触发于当前拥有焦点的元素上触发。 onhelp 当用户在浏览器为当前窗口时按 F1 键时触发。 onkeydown 当用户按下键盘按键时触发。 onkeypress 当用户按下字面键时触发。 onkeyup [...]]]></description>
			<content:encoded><![CDATA[<p>onactivate 当对象设置为活动元素时触发。<br />
onbeforeactivate 对象要被设置为当前元素前立即触发。<br />
onbeforecut 当选中区从文档中删除之前在源对象触发。<br />
onbeforedeactivate 在 activeElement 从当前对象变为父文档其它对象之前立即触发。<br />
onbeforeeditfocus 在包含于可编辑元素内的对象进入用户界面激活状态前或可编辑容器变成控件选中区前触发。<br />
onbeforepaste 在选中区从系统剪贴板粘贴到文档前在目标对象上触发。<br />
onclick 在用户用鼠标左键单击对象时触发。<br />
oncontextmenu 在用户使用鼠标右键单击客户区打开上下文菜单时触发。<br />
oncontrolselect 当用户将要对该对象制作一个控件选中区时触发。<br />
oncut 当对象或选中区从文档中删除并添加到系统剪贴板上时在源元素上触发。<br />
ondblclick 当用户双击对象时触发。<br />
ondeactivate 当 activeElement 从当前对象变为父文档其它对象时触发。<br />
ondrag 当进行拖曳操作时在源对象上持续触发。<br />
ondragend 当用户在拖曳操作结束后释放鼠标时在源对象上触发。<br />
ondragenter 当用户拖曳对象到一个合法拖曳目标时在目标元素上触发。<br />
ondragleave 当用户在拖曳操作过程中将鼠标移出合法拖曳目标时在目标对象上触发。<br />
ondragover 当用户拖曳对象划过合法拖曳目标时持续在目标元素上触发。<br />
ondragstart 当用户开始拖曳文本选中区或选中对象时在源对象上触发。<br />
ondrop 当鼠标按钮在拖曳操作过程中释放时在目标对象上触发。<br />
onfocusin 当元素将要被设置为焦点之前触发。<br />
onfocusout 在移动焦点到其它元素之后立即触发于当前拥有焦点的元素上触发。<br />
onhelp 当用户在浏览器为当前窗口时按 F1 键时触发。<br />
onkeydown 当用户按下键盘按键时触发。<br />
onkeypress 当用户按下字面键时触发。<br />
onkeyup 当用户释放键盘按键时触发。<br />
onmousedown 当用户用任何鼠标按钮单击对象时触发。<br />
onmousemove 当用户将鼠标划过对象时触发。<br />
onmouseout 当用户将鼠标指针移出对象边界时触发。<br />
onmouseover 当用户将鼠标指针移动到对象内时触发。<br />
onmouseup 当用户在鼠标位于对象之上时释放鼠标按钮时触发。<br />
onmousewheel 当鼠标滚轮按钮旋转时触发。<br />
onmove 当对象移动时触发。<br />
onmoveend 当对象停止移动时触发。<br />
onmovestart 当对象开始移动时触发。<br />
onpaste 当用户粘贴数据以便从系统剪贴板向文档传送数据时在目标对象上触发。<br />
onpropertychange 当在对象上发生对象上发生属性更改时触发。<br />
onreadystatechange 当对象状态变更时触发。<br />
onresizeend 当用户更改完控件选中区中对象的尺寸时触发。<br />
onresizestart 当用户开始更改控件选中区中对象的尺寸时触发。<br />
onselectionchange 当文档的选中状态改变时触发。<br />
onstop 当用户单击停止按钮或离开 <a href="http://www.5bay.cn/tag/web" class="st_tag internal_tag" rel="tag" title="标签 web 下的日志">Web</a> 页面时触发。 </p>
<h2  class="related_post_title">相关博文</h2><ul class="related_post"><li>2010年07月26日 -- <a href="http://www.5bay.cn/network-programming/ajaxeeee.html" title="Ajax的工作原理">Ajax的工作原理</a> (1)</li><li>2010年07月26日 -- <a href="http://www.5bay.cn/network-programming/ajax.html" title="AJAX的各种控件和类库">AJAX的各种控件和类库</a> (0)</li><li>2010年07月26日 -- <a href="http://www.5bay.cn/network-programming/ajaxxuan.html" title="ajax的缺点">ajax的缺点</a> (0)</li><li>2010年07月26日 -- <a href="http://www.5bay.cn/network-programming/eesoneeajaxeehuai.html" title="基于JSON的高级AJAX开发技术">基于JSON的高级AJAX开发技术</a> (0)</li><li>2010年07月26日 -- <a href="http://www.5bay.cn/network-programming/xmlhttpe.html" title="XMLHTTP对象封装技术">XMLHTTP对象封装技术</a> (0)</li><li>2010年07月26日 -- <a href="http://www.5bay.cn/network-programming/phpeecketee.html" title="PHP和Socket简介">PHP和Socket简介</a> (0)</li><li>2010年07月26日 -- <a href="http://www.5bay.cn/network-programming/eejaxeeeeee.html" title="使用Ajax时的十个常犯的错误">使用Ajax时的十个常犯的错误</a> (0)</li><li>2010年05月23日 -- <a href="http://www.5bay.cn/server-building/nginxderewriteguize.html" title="nginx的rewrite规则">nginx的rewrite规则</a> (1)</li><li>2010年05月23日 -- <a href="http://www.5bay.cn/server-building/gaoxingnengwangzhanjianshezhinandushubiji.html" title="《高性能网站建设指南》读书笔记">《高性能网站建设指南》读书笔记</a> (0)</li><li>2011年06月29日 -- <a href="http://www.5bay.cn/game-development/zishenshejishitonyventricejiexishoujiyouxikaifadesigecengci.html" title="资深设计师Tony Ventrice解析手机游戏开发的四个层次">资深设计师Tony Ventrice解析手机游戏开发的四个层次</a> (0)</li><li>2010年07月26日 -- <a href="http://www.5bay.cn/network-programming/innerhtmleenertexteeterhtmlqia.html" title="innerHTML、innerText和outerHTML的用法">innerHTML、innerText和outerHTML的用法</a> (0)</li><li>2010年07月26日 -- <a href="http://www.5bay.cn/network-programming/eejaxeeetpit.html" title="了解Ajax中的Get和Post ">了解Ajax中的Get和Post </a> (0)</li><li>2010年05月23日 -- <a href="http://www.5bay.cn/server-building/rsyncxiangjie.html" title="Rsync详解">Rsync详解</a> (0)</li><li>2010年05月23日 -- <a href="http://www.5bay.cn/server-building/mysqlyouhuajiquanwensousuo.html" title="mysql优化及全文搜索">mysql优化及全文搜索</a> (0)</li><li>2008年10月17日 -- <a href="http://www.5bay.cn/game-development/%E6%9C%8D%E5%8A%A1%E5%99%A8%E6%B6%88%E6%81%AF%E7%9A%84%E5%B9%BF%E6%92%AD.html" title="服务器消息的广播">服务器消息的广播</a> (0)</li></ul>
	标签Tags：<a href="http://www.5bay.cn/tag/ajax" title="ajax" rel="tag">ajax</a>, <a href="http://www.5bay.cn/category/network-programming/javascript-ajax" title="JavaScript&amp;Ajax" rel="tag">JavaScript&amp;Ajax</a>, <a href="http://www.5bay.cn/tag/js" title="js" rel="tag">js</a>, <a href="http://www.5bay.cn/tag/menu" title="menu" rel="tag">menu</a>, <a href="http://www.5bay.cn/tag/seo" title="seo" rel="tag">seo</a>, <a href="http://www.5bay.cn/tag/web" title="web" rel="tag">web</a>, <a href="http://www.5bay.cn/tag/%E5%A4%A7%E5%85%A8" title="大全" rel="tag">大全</a>, <a href="http://www.5bay.cn/tag/%E5%AE%B9%E5%99%A8" title="容器" rel="tag">容器</a>, <a href="http://www.5bay.cn/tag/%E5%AF%B9%E8%B1%A1" title="对象" rel="tag">对象</a>, <a href="http://www.5bay.cn/tag/%E5%B1%9E%E6%80%A7" title="属性" rel="tag">属性</a>, <a href="http://www.5bay.cn/tag/%E6%95%B0%E6%8D%AE" title="数据" rel="tag">数据</a>, <a href="http://www.5bay.cn/tag/%E6%B5%8F%E8%A7%88%E5%99%A8" title="浏览器" rel="tag">浏览器</a>, <a href="http://www.5bay.cn/tag/%E7%B3%BB%E7%BB%9F" title="系统" rel="tag">系统</a>, <a href="http://www.5bay.cn/category/network-programming" title="网络编程" rel="tag">网络编程</a>, <a href="http://www.5bay.cn/tag/%E9%A1%B5%E9%9D%A2" title="页面" rel="tag">页面</a>, <a href="http://www.5bay.cn/tag/%E9%BC%A0%E6%A0%87" title="鼠标" rel="tag">鼠标</a><br />
]]></content:encoded>
			<wfw:commentRss>http://www.5bay.cn/network-programming/ajaxeeeeseeao.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>ajax的缺点</title>
		<link>http://www.5bay.cn/network-programming/ajaxxuan.html</link>
		<comments>http://www.5bay.cn/network-programming/ajaxxuan.html#comments</comments>
		<pubDate>Sun, 25 Jul 2010 16:41:11 +0000</pubDate>
		<dc:creator>江小邪</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[网络编程]]></category>
		<category><![CDATA[ajax]]></category>
		<category><![CDATA[code]]></category>
		<category><![CDATA[google]]></category>
		<category><![CDATA[html]]></category>
		<category><![CDATA[ie]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[js]]></category>
		<category><![CDATA[web]]></category>
		<category><![CDATA[人]]></category>
		<category><![CDATA[代码]]></category>
		<category><![CDATA[兼容]]></category>
		<category><![CDATA[可用性]]></category>
		<category><![CDATA[应用程序]]></category>
		<category><![CDATA[收藏]]></category>
		<category><![CDATA[数据]]></category>
		<category><![CDATA[方法]]></category>
		<category><![CDATA[浏览器]]></category>
		<category><![CDATA[版本]]></category>
		<category><![CDATA[程序]]></category>
		<category><![CDATA[系统]]></category>
		<category><![CDATA[自身]]></category>
		<category><![CDATA[解决]]></category>
		<category><![CDATA[诫]]></category>
		<category><![CDATA[链接]]></category>
		<category><![CDATA[错误]]></category>
		<category><![CDATA[页面]]></category>

		<guid isPermaLink="false">http://www.5bay.cn/?p=466</guid>
		<description><![CDATA[<a href="http://www.5bay.cn/network-programming/ajaxxuan.html"><img align="left" hspace="5" width="150" height="150" src="http://www.5bay.cn/wp-content/plugins/thumbnail-for-excerpts/tfe_no_thumb.png" class="alignleft wp-post-image tfe" alt="" title="" /></a>下面是我对一部分缺陷的看法： 为Ajax而Ajax(Using Ajax for the sake of Ajax.) 很同意这点，当一个技术本身的生存意义由于它自身的亮点而被抹杀，不知道是这个技术的幸运还是不幸。 干掉了back按钮(Breaking the back button) back按钮是一个标准的web站点UI的重要功能。然后，后退按钮没法和js很好的合作…… gmail似乎作的很好？不过没去仔细看过gmail如何实现后退和js相容的，被这个mistake一提醒，也许这也是ue的一个切口哦。 点击的时候没有提供一个可视化的提示(Not giving immediate visual cues for clicking widgets) ……也许是我没看懂，觉得写这段的人自相矛盾。。他说没提供可视化提示，不过是拿gmail右上角的红色提示作为例子。 阻挡了离线用户于门外(Leaving offline people behind) 看标题就清楚了，不过我持保留意见，web application和离线浏览本身似乎就存在着矛盾，要整合，可能要动很多脑子 别让我等(Don’t make me wait) 不过，ajax本身就存在着如果客户端的带宽不够，它的展示就会一塌糊涂的问题，这是它的先天缺陷，也是它崛起的先天因素－－由于网速和带宽的不断增大，使得服务端与客户端的频繁通信成为可能。 显式的传递敏感信息(Sending sensitive information in the clear) 使用js传递数据，本身似乎就存在着这个风险，在我找到反对意见之前，我倾向认同这点－－https协议除外。 假设ajax发展是一个单平台的发展。(Assuming AJAX development is single platform development) 作者文中的观点是ajax由于必须兼容多个浏览器，而没法做到只需要编码到标准的js就行，还要考虑到各个浏览器的问题……这个是js的问题，和ajax关系不大吧？ 忘掉了可能多人在同时使用同一个应用(Forgetting that multiple people might [...]]]></description>
			<content:encoded><![CDATA[<p>下面是我对一部分缺陷的看法：</p>
<p>为Ajax而Ajax(Using <a href="http://www.5bay.cn/tag/ajax" class="st_tag internal_tag" rel="tag" title="标签 ajax 下的日志">Ajax</a> for the sake of <a href="http://www.5bay.cn/tag/ajax" class="st_tag internal_tag" rel="tag" title="标签 ajax 下的日志">Ajax</a>.)</p>
<p>很同意这点，当一个技术本身的生存意义由于它自身的亮点而被抹杀，不知道是这个技术的幸运还是不幸。</p>
<p>干掉了back按钮(Breaking the back button)</p>
<p>back按钮是一个标准的web站点UI的重要功能。然后，后退按钮没法和js很好的合作……<br />
gmail似乎作的很好？不过没去仔细看过gmail如何实现后退和js相容的，被这个mistake一提醒，也许这也是ue的一个切口哦。</p>
<p>点击的时候没有提供一个可视化的提示(Not giving immediate visual cues for clicking widgets)</p>
<p>……也许是我没看懂，觉得写这段的人自相矛盾。。他说没提供可视化提示，不过是拿gmail右上角的红色提示作为例子。<span id="more-466"></span></p>
<p>阻挡了离线用户于门外(Leaving offline people behind)</p>
<p>看标题就清楚了，不过我持保留意见，<a href="http://www.5bay.cn/tag/web" class="st_tag internal_tag" rel="tag" title="标签 web 下的日志">web</a> application和离线浏览本身似乎就存在着矛盾，要整合，可能要动很多脑子</p>
<p>别让我等(Don’t make me wait)</p>
<p>不过，ajax本身就存在着如果客户端的带宽不够，它的展示就会一塌糊涂的问题，这是它的先天缺陷，也是它崛起的先天因素－－由于网速和带宽的不断增大，使得服务端与客户端的频繁通信成为可能。</p>
<p>显式的传递敏感信息(Sending sensitive information in the clear)</p>
<p>使用js传递数据，本身似乎就存在着这个风险，在我找到反对意见之前，我倾向认同这点－－https协议除外。</p>
<p>假设ajax发展是一个单平台的发展。(Assuming AJAX development is single platform development)</p>
<p>作者文中的观点是ajax由于必须兼容多个浏览器，而没法做到只需要编码到标准的js就行，还要考虑到各个浏览器的问题……这个是js的问题，和ajax关系不大吧？</p>
<p>忘掉了可能多人在同时使用同一个应用(Forgetting that multiple people might be using the same application at the same time)</p>
<p>嗯，这其实是一个同步的问题，在b/s系统中这是一个麻烦的问题……当然，也许并不麻烦，做一个标记位就解决了吧？</p>
<p>太多代码让浏览器慢下来(Too much code makes the browser slow)</p>
<p>呃……同意这点，虽然在代码优化之后会有很大改善，但js本身运行速度慢这个缺陷还是会成为一个瓶颈。</p>
<p>不计划要那些禁用或者没有js的用户(Not having a plan for those who do not enable or have JavaScript)</p>
<p>呃……我在页面上用ajax的时候就准备放弃这些用户了，我没google那么闲，作两套系统，一套用ajax，一套纯页面。不过养成一个良好的编码习惯还是有必要，比如在超链接中不要直接设置href=”javascript:&#8230;”而使用onmouseup或者onclick来触发事件，偶尔也为别人考虑考虑嘛，而且我也不能保证我的js程序在所有的浏览器上通吃。</p>
<p>不期然的页面闪烁和改变(Blinking and changing parts of the page unexpectedly)</p>
<p>我没经历过以前网页中blink标签的骚扰，所以我对作者的反感有点摸不着头脑，我觉得在适当的提示之后刷新某块页面总比整个页面的刷新看起来舒服。</p>
<p>没法把超链接发给朋友以及收藏(Not using links I can pass to friends or bookmark)</p>
<p>嘿嘿，这就是我上面提及的那点，如果编码习惯够好－－而且时间够多，在超链接中为非js用户和js用户提供两套方案是可行的。</p>
<p>同步导致的批量操作(Asynchronously performing batch operations)</p>
<p>作者的意思是说ajax一次性把原来要分几次作的操作一次做掉，而导致他没法跟踪每个元素变化，没法回溯，呃……也许是有这种需求吧。。不过似乎也是可以解决的吧？</p>
<p>导致页面滚动并让我迷失位置（Scrolling the page and making me lose my place）</p>
<p>作者认为插入文本到一个页面中会导致页面发生滚动，并让其迷失方向，我没看过这么恶心的效果，没法评价，不过我对于一些ajax的导航作的不好表示不满意，我经常会迷失于一些ajax程序中而不知道我刚才上一步到了哪里……</p>
<p>发明了新的UI习惯（Inventing new UI conventions）</p>
<p>呵呵，作者用了一句话来描述这个缺点：“点击一个不明显的东东来产生一个不明显的结果”。这个归纳倒是满准确的，在很多ajax程序中，用户完全是作为一个瞎子，在抖抖索索的摸着这个ajax程序大象，在到处瞎点一气并瞎拖一气之后才掌握这个程序的用法。但是换个角度来说，最开始的web页面不也是一样？没有开始的困难接触，不会有之后的进步，只要有足够的帮助，上手任何东西都应该不会太难－－除非这东西本来就不想让人觉得好用，那就是其它的问题了。</p>
<p>阻止了爬虫（Blocking Spidering）</p>
<p>同意这点，我在犹豫着使用ajax的时候，就在考虑爬虫对js的不感冒，以及爬虫该如何理解我那些以奇怪方式加载的页面，去解析ajax库似乎是一个不可能的事情，爬虫又不是人脑，如果爬虫可以媲美人脑，那就是《骇客帝国4》了。</p>
<p>字符集（Character Sets）</p>
<p>ajax本身对字符集的支持比较缺失，这个这个……设置成utf-8吧，不过作者最后也是这么说的。</p>
<p>使用超链接改变状态（Changing state with links (GET requests)）</p>
<p>作者认为主流的ajax应用程序都是用get方式来工作，而这违反了W3对GET和POST方法的使用建议……我少见多怪，主流的ajax应用程序我没怎么去看，不知道是不是真的都用get，虽然ajax编码用get简单，但不表示ajax不能用post吧？</p>
<p>没有连带改变页面中其它相关部分（Not cascading local changes to other parts of the page）</p>
<p>因为ajax让人很容易控制页面中的特定部分，所以也容易导致过于关注某个点而失去对整体布局的关注。嗯嗯……这是编码的问题，表怪到ajax头上。</p>
<p>问题报告（Problem reporting）</p>
<p>作者认为服务端的程序错误，很容易再现并捕捉，而客户端的错误要重现就比较麻烦，嗯，支持这点，不过还是和ajax关系不大……</p>
<p>投资回报(Return on Investment)</p>
<p>作者认为ajax能够提升应用程序的可用性，但是富客户端程序并不会比纯html版本好多少……忽略这个观点，来人，把作者拖出去，账责五十</p>
<p>拙劣地模仿浏览器页面跳转行为（Mimicing browser page navigation behavior imperfectly）</p>
<p>……忽略，没看到作者所描述的情况。</p>
<h2  class="related_post_title">相关博文</h2><ul class="related_post"><li>2010年07月26日 -- <a href="http://www.5bay.cn/network-programming/eejaxeeeeee.html" title="使用Ajax时的十个常犯的错误">使用Ajax时的十个常犯的错误</a> (0)</li><li>2010年07月26日 -- <a href="http://www.5bay.cn/network-programming/ajaxeeee.html" title="Ajax的工作原理">Ajax的工作原理</a> (1)</li><li>2010年07月26日 -- <a href="http://www.5bay.cn/network-programming/eesoneeajaxeehuai.html" title="基于JSON的高级AJAX开发技术">基于JSON的高级AJAX开发技术</a> (0)</li><li>2010年07月26日 -- <a href="http://www.5bay.cn/network-programming/ajaxeeaoe.html" title="AJAX应用程序开发七宗罪">AJAX应用程序开发七宗罪</a> (0)</li><li>2010年07月26日 -- <a href="http://www.5bay.cn/network-programming/eeeeeeee.html" title="最令PHP初学者头痛的十四个问题">最令PHP初学者头痛的十四个问题</a> (0)</li><li>2010年07月26日 -- <a href="http://www.5bay.cn/network-programming/ajax.html" title="AJAX的各种控件和类库">AJAX的各种控件和类库</a> (0)</li><li>2010年07月26日 -- <a href="http://www.5bay.cn/network-programming/phpeecketee.html" title="PHP和Socket简介">PHP和Socket简介</a> (0)</li><li>2010年07月26日 -- <a href="http://www.5bay.cn/network-programming/peeeeee.html" title="深入探讨PHP中的内存管理问题">深入探讨PHP中的内存管理问题</a> (0)</li><li>2010年07月26日 -- <a href="http://www.5bay.cn/network-programming/xmlhttpe.html" title="XMLHTTP对象封装技术">XMLHTTP对象封装技术</a> (0)</li><li>2010年05月23日 -- <a href="http://www.5bay.cn/server-building/mysqlyouhuajiquanwensousuo.html" title="mysql优化及全文搜索">mysql优化及全文搜索</a> (0)</li><li>2010年05月23日 -- <a href="http://www.5bay.cn/server-building/rsyncxiangjie.html" title="Rsync详解">Rsync详解</a> (0)</li><li>2010年07月28日 -- <a href="http://www.5bay.cn/server-building/webshelleechueeee.html" title="Webshell下破解计算机管理员密码">Webshell下破解计算机管理员密码</a> (0)</li><li>2010年07月26日 -- <a href="http://www.5bay.cn/network-programming/phpeezhanchang.html" title="PHP安全之数据过滤">PHP安全之数据过滤</a> (0)</li><li>2010年05月23日 -- <a href="http://www.5bay.cn/server-building/gaoxingnengwangzhanjianshezhinandushubiji.html" title="《高性能网站建设指南》读书笔记">《高性能网站建设指南》读书笔记</a> (0)</li><li>2010年05月23日 -- <a href="http://www.5bay.cn/server-building/nginxderewriteguize.html" title="nginx的rewrite规则">nginx的rewrite规则</a> (1)</li></ul>
	标签Tags：<a href="http://www.5bay.cn/tag/ajax" title="ajax" rel="tag">ajax</a>, <a href="http://www.5bay.cn/tag/code" title="code" rel="tag">code</a>, <a href="http://www.5bay.cn/tag/google" title="google" rel="tag">google</a>, <a href="http://www.5bay.cn/tag/html" title="html" rel="tag">html</a>, <a href="http://www.5bay.cn/tag/ie" title="ie" rel="tag">ie</a>, <a href="http://www.5bay.cn/tag/javascript" title="javascript" rel="tag">javascript</a>, <a href="http://www.5bay.cn/tag/js" title="js" rel="tag">js</a>, <a href="http://www.5bay.cn/category/network-programming/php" title="PHP" rel="tag">PHP</a>, <a href="http://www.5bay.cn/tag/web" title="web" rel="tag">web</a>, <a href="http://www.5bay.cn/tag/%E4%BA%BA" title="人" rel="tag">人</a>, <a href="http://www.5bay.cn/tag/%E4%BB%A3%E7%A0%81" title="代码" rel="tag">代码</a>, <a href="http://www.5bay.cn/tag/%E5%85%BC%E5%AE%B9" title="兼容" rel="tag">兼容</a>, <a href="http://www.5bay.cn/tag/%E5%8F%AF%E7%94%A8%E6%80%A7" title="可用性" rel="tag">可用性</a>, <a href="http://www.5bay.cn/tag/%E5%BA%94%E7%94%A8%E7%A8%8B%E5%BA%8F" title="应用程序" rel="tag">应用程序</a>, <a href="http://www.5bay.cn/tag/%E6%94%B6%E8%97%8F" title="收藏" rel="tag">收藏</a>, <a href="http://www.5bay.cn/tag/%E6%95%B0%E6%8D%AE" title="数据" rel="tag">数据</a>, <a href="http://www.5bay.cn/tag/%E6%96%B9%E6%B3%95" title="方法" rel="tag">方法</a>, <a href="http://www.5bay.cn/tag/%E6%B5%8F%E8%A7%88%E5%99%A8" title="浏览器" rel="tag">浏览器</a>, <a href="http://www.5bay.cn/tag/%E7%89%88%E6%9C%AC" title="版本" rel="tag">版本</a>, <a href="http://www.5bay.cn/tag/%E7%A8%8B%E5%BA%8F" title="程序" rel="tag">程序</a>, <a href="http://www.5bay.cn/tag/%E7%B3%BB%E7%BB%9F" title="系统" rel="tag">系统</a>, <a href="http://www.5bay.cn/category/network-programming" title="网络编程" rel="tag">网络编程</a>, <a href="http://www.5bay.cn/tag/%E8%87%AA%E8%BA%AB" title="自身" rel="tag">自身</a>, <a href="http://www.5bay.cn/tag/%E8%A7%A3%E5%86%B3" title="解决" rel="tag">解决</a>, <a href="http://www.5bay.cn/tag/e" title="诫" rel="tag">诫</a>, <a href="http://www.5bay.cn/tag/%E9%93%BE%E6%8E%A5" title="链接" rel="tag">链接</a>, <a href="http://www.5bay.cn/tag/%E9%94%99%E8%AF%AF" title="错误" rel="tag">错误</a>, <a href="http://www.5bay.cn/tag/%E9%A1%B5%E9%9D%A2" title="页面" rel="tag">页面</a><br />
]]></content:encoded>
			<wfw:commentRss>http://www.5bay.cn/network-programming/ajaxxuan.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>基于JSON的高级AJAX开发技术</title>
		<link>http://www.5bay.cn/network-programming/eesoneeajaxeehuai.html</link>
		<comments>http://www.5bay.cn/network-programming/eesoneeajaxeehuai.html#comments</comments>
		<pubDate>Sun, 25 Jul 2010 16:39:46 +0000</pubDate>
		<dc:creator>江小邪</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[网络编程]]></category>
		<category><![CDATA[ajax]]></category>
		<category><![CDATA[div]]></category>
		<category><![CDATA[html]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[js]]></category>
		<category><![CDATA[mod]]></category>
		<category><![CDATA[url]]></category>
		<category><![CDATA[web]]></category>
		<category><![CDATA[xml]]></category>
		<category><![CDATA[人]]></category>
		<category><![CDATA[代码]]></category>
		<category><![CDATA[分离]]></category>
		<category><![CDATA[对象]]></category>
		<category><![CDATA[属性]]></category>
		<category><![CDATA[应用程序]]></category>
		<category><![CDATA[数据]]></category>
		<category><![CDATA[数据库]]></category>
		<category><![CDATA[方法]]></category>
		<category><![CDATA[浏览器]]></category>
		<category><![CDATA[程序]]></category>
		<category><![CDATA[类]]></category>
		<category><![CDATA[网站]]></category>
		<category><![CDATA[自身]]></category>
		<category><![CDATA[诫]]></category>
		<category><![CDATA[链接]]></category>
		<category><![CDATA[面向对象]]></category>

		<guid isPermaLink="false">http://www.5bay.cn/?p=464</guid>
		<description><![CDATA[<a href="http://www.5bay.cn/network-programming/eesoneeajaxeehuai.html"><img align="left" hspace="5" width="150" height="150" src="http://www.5bay.cn/wp-content/plugins/thumbnail-for-excerpts/tfe_no_thumb.png" class="alignleft wp-post-image tfe" alt="" title="" /></a>一、 引言 　　毫无疑问，AJAX已经成为当今Web开发中一种强有力的用户交互技术，但是它的许多可能性应用仍然鲜为人知。在本文中，我们将来共同探讨如何使用JavaScript对象标志(JSON)和JSON分析器在服务器和客户端AJAX引擎之间创建复杂而强有力的JSON数据传输层。我们将详细讨论如何创建一组对象(在其它语言中经常被当作一个包)，如何把这些对象串行化为JSON以发送到服务器端，以及如何把服务器端JSON反串行化为客户端JavaScript对象。 　　提示：你可以在Douglas Crockford的网站上找到本文中使用的JSON分析器。 　　在继续阅读前，本文假定你已经掌握了JavaScript技术并且了解如何创建一个基本的AJAX引擎，并经由AJAX技术向服务器端发出请求和从服务器端接收响应。为了更好地理解本文中示例，你需要下载本文相应的源码文件。 　　二、 开始 　　为了进一步抽象我们的AJAX请求并有助于我们以后在不同的应用程序间共享AJAX引擎代码，本文使用了一个我自己创建的AJAX引擎。为了使用这个引擎，我们简单地导入三个JavaScript文件并且向一个名为AjaxUpdater的对象发出请求。然后，由该引擎来负责处理其它任务，包括把响应代理到在该请求中指定的回调方法中。下面的示例展示了我们如何使用这个引擎发出请求以及导入相关的文件： ＜script type=”text/javascript”src=”javascript/model/Ajax.js”＞＜/script＞ ＜script type=”text/javascript” src=”javascript/model/HTTP.js”＞＜/script＞ ＜script type=”text/javascript” src=”javascript/model/AjaxUpdater.js”＞＜/script＞ ＜script type=”text/javascript”＞ document.load = AjaxUpdater.Update(’GET’， URL， callback); ＜/script＞ 　　首先，让我们来讨论JavaScript对象。 三、 JavaScript对象 　　JavaScript以前经常被误解，似乎它主要用于实现客户浏览器端图形效果。其实，JavaScript是一种强有力的语言，特别当它与AJAX以及一个应用程序的服务器端相结合时;但是，即使在客户端，JavaScript也能够实现远比你预料得多的多的功能。面向对象的JavaScript就是一个示例，它能够使我们创建对象，扩展内在对象，甚至能够把我们的对象创建成包以达到更容易的管理之目的。 　　在本文示例中，我们将创建三个对象：Auto，Car和Wheel。其中，每一个都是简单的对象;在此，我们仅使用它们来展示如何创建一个基本包。 　　首先，Auto对象被声明为一个新的对象： 　　var Auto = new Object(); 　　注意，这个Auto对象将用作Car对象的父类。因此，Car对象将成为Auto对象的一个属性，只不过它被分离到另一个文件中以更易于管理(这个概念经常被用于其它面向对象的语言中，但是在JavaScript中却并不经常提起它)。下面是这个Car对象相应的代码： 　　Auto.Car = new Object(); 　　Auto.Car.color = “#fff”; 　　Auto.Car.setColor = function(_color) 　　{ 　　Auto.Car.color = _color; 　　} 　　Auto.Car.setColor(“#333&#8243;); 　　如你所见，该Car对象是Auto对象的一个子对象—这分明是一种类对象层次结构。这个对象有一个名为color的属性和一个用于设置它的方法。在此，我们把color属性设置为灰色以覆盖掉缺省的白色。当在后面我们串行化该对象时请牢记住这个事实。 　　下一个对象，Wheel，是Car的一个子对象： [...]]]></description>
			<content:encoded><![CDATA[<p>一、 引言</p>
<p>　　毫无疑问，AJAX已经成为当今Web开发中一种强有力的用户交互技术，但是它的许多可能性应用仍然鲜为人知。在本文中，我们将来共同探讨如何使用JavaScript对象标志(JSON)和JSON分析器在服务器和客户端AJAX引擎之间创建复杂而强有力的JSON数据传输层。我们将详细讨论如何创建一组对象(在其它语言中经常被当作一个包)，如何把这些对象串行化为JSON以发送到服务器端，以及如何把服务器端JSON反串行化为客户端JavaScript对象。</p>
<p>　　提示：你可以在Douglas Crockford的网站上找到本文中使用的JSON分析器。</p>
<p>　　在继续阅读前，本文假定你已经掌握了JavaScript技术并且了解如何创建一个基本的AJAX引擎，并经由AJAX技术向服务器端发出请求和从服务器端接收响应。为了更好地理解本文中示例，你需要下载本文相应的源码文件。<span id="more-464"></span></p>
<p>　　二、 开始</p>
<p>　　为了进一步抽象我们的AJAX请求并有助于我们以后在不同的应用程序间共享AJAX引擎代码，本文使用了一个我自己创建的AJAX引擎。为了使用这个引擎，我们简单地导入三个JavaScript文件并且向一个名为AjaxUpdater的对象发出请求。然后，由该引擎来负责处理其它任务，包括把响应代理到在该请求中指定的回调方法中。下面的示例展示了我们如何使用这个引擎发出请求以及导入相关的文件：</p>
<p>＜script type=”text/javascript”src=”javascript/model/Ajax.js”＞＜/script＞<br />
＜script type=”text/javascript” src=”javascript/model/HTTP.js”＞＜/script＞<br />
＜script type=”text/javascript” src=”javascript/model/AjaxUpdater.js”＞＜/script＞<br />
＜script type=”text/javascript”＞<br />
document.load = AjaxUpdater.Update(’GET’， <a href="http://www.5bay.cn/tag/url" class="st_tag internal_tag" rel="tag" title="标签 url 下的日志">URL</a>， callback);<br />
＜/script＞ </p>
<p>　　首先，让我们来讨论JavaScript对象。</p>
<p>三、 JavaScript对象 </p>
<p>　　JavaScript以前经常被误解，似乎它主要用于实现客户浏览器端图形效果。其实，JavaScript是一种强有力的语言，特别当它与AJAX以及一个应用程序的服务器端相结合时;但是，即使在客户端，JavaScript也能够实现远比你预料得多的多的功能。面向对象的JavaScript就是一个示例，它能够使我们创建对象，扩展内在对象，甚至能够把我们的对象创建成包以达到更容易的管理之目的。</p>
<p>　　在本文示例中，我们将创建三个对象：Auto，Car和Wheel。其中，每一个都是简单的对象;在此，我们仅使用它们来展示如何创建一个基本包。</p>
<p>　　首先，Auto对象被声明为一个新的对象：</p>
<p>　　var Auto = new Object(); </p>
<p>　　注意，这个Auto对象将用作Car对象的父类。因此，Car对象将成为Auto对象的一个属性，只不过它被分离到另一个文件中以更易于管理(这个概念经常被用于其它面向对象的语言中，但是在JavaScript中却并不经常提起它)。下面是这个Car对象相应的代码：</p>
<p>　　Auto.Car = new Object();<br />
　　Auto.Car.color = “#fff”;<br />
　　Auto.Car.setColor = function(_color)<br />
　　{<br />
　　Auto.Car.color = _color;<br />
　　}<br />
　　Auto.Car.setColor(“#333&#8243;); </p>
<p>　　如你所见，该Car对象是Auto对象的一个子对象—这分明是一种类对象层次结构。这个对象有一个名为color的属性和一个用于设置它的方法。在此，我们把color属性设置为灰色以覆盖掉缺省的白色。当在后面我们串行化该对象时请牢记住这个事实。</p>
<p>　　下一个对象，Wheel，是Car的一个子对象：</p>
<p>Auto.Car.Wheel = new Object();<br />
Auto.Car.Wheel.color = “#000&#8243;; </p>
<p>　　在此，Wheel是一个基本对象，但是它展示了对象层次中的又一个层。这个对象有一个称为color的缺省值为黑色(“#000”)的属性。</p>
<p>　　下面，让我们来分析一下为什么这些对象如此重要以及我们是如何使用它们提供的简单的属性的。</p>
<p>四、 把JavaScript对象串行化为JSON </p>
<p>　　借助于JSON分析器，我们可以很容易地把刚才创建的JavaScript对象串行化为JSON。首先，我们需要下载该分析器的一个副本，并且要把它添加到文档中。下面是我在本文示例中用于导入该脚本的相应的代码：</p>
<p>＜script type=”text/javascript” src=”javascript/utils/jsonparser.js”＞＜/script＞ </p>
<p>　　我已经把该分析器添加到我的javascript目录，即一个称为utils的子目录下。</p>
<p>　　下面是最终的包括到其中用于导入适当的JavaScript文件的代码片断：</p>
<p>以下是引用片段：<br />
＜script type=”text/javascript” src=”javascript/Auto.js”＞＜/script＞<br />
＜script type=”text/javascript” src=”javascript/Car.js”＞＜/script＞<br />
＜script type=”text/javascript” src=”javascript/Wheel.js”＞＜/script＞<br />
＜script type=”text/javascript” src=”javascript/utils/jsonparser.js”＞＜/script＞<br />
＜script type=”text/javascript” src=”javascript/model/Ajax.js”＞＜/script＞<br />
＜script type=”text/javascript” src=”javascript/model/HTTP.js”＞＜/script＞<br />
＜script type=”text/javascript” src=”javascript/model/AjaxUpdater.js”＞＜/script＞ </p>
<p>　　在导入适当的文件后，我们可以通过把两个div元素和一个onload事件简单地添加到HTML文档中开始串行化。这两个div元素将分别拥有ID：body和loading。其中，这个loading标签将由AJAX引擎使用来指示进度情况，而body标签将用于显示消息。</p>
<p>＜<a href="http://www.5bay.cn/tag/div" class="st_tag internal_tag" rel="tag" title="标签 div 下的日志">div</a> id=”loading”＞＜/<a href="http://www.5bay.cn/tag/div" class="st_tag internal_tag" rel="tag" title="标签 div 下的日志">div</a>＞<br />
＜div id=”body”＞＜/div＞ </p>
<p>　　onload事件相应于body元素并且设置它的innerHTML属性为JavaScript对象(作为一个串行化的JSON字符串)。为了实现这一目的，我在Auto对象上使用了jsonparser.js文件内的toJSONString方法：</p>
<p>＜body onload=”document.getElementById(’body’).innerHTML = ’＜b＞Local objects serialized as JSON＜/b＞<br />
Auto Object: ’+ Auto.toJSONString();”＞ </p>
<p>　　这段代码使用了Auto对象及其所有的子对象，并且使用JSON分析器的toJSONString方法把它们串行化为一个JSON字符串。然后，该数据可以被用作服务器端的一种数据交换格式。</p>
<p>　　你可能还记得，在前面我们曾调用了一个称为setColor的方法来改变Car对象的颜色。当时，我使用它是因为我想向你展示串行化能够在运行时刻的任何点上实现，而且还为了反映出对象中最新的数据。</p>
<p>　　如果你仔细分析一下onload事件，你会注意到，Car和Wheel对象都包装在方括号内，这些方括号代表了父对象(即Auto)。这意味着，该串行化的JavaScript对象能够在运行时刻被发送到服务器端以存储最新的数据，并且也可以在应用程序启动时从服务器端进行接收以便从数据库中检索多数的当前数据。最精彩的部分在于，为了创建一种“无缝”的过程，所有与服务器之间实现的数据交换都可以使用JSON技术来实现。</p>
<p>　　下面，让我们来看一下相同的数据是如何从服务器端接收的，以及它们是如何被使用最新的数据(典型地，来源于一个数据库)串行化为客户端JavaScript对象的。</p>
<p>五、 把JSON反串行化为客户端JavaScript对象 </p>
<p>　　在本文中，我简单地把一个静态文件创建为JSON响应，但是在实际开发中，你可以把这些数据存储在一个数据库中并且使用一种服务器端语言返回它。基于这一能力，我们就可以轻松地创建一种强有力的数据交换过程!在前面，我们已经分析了这一串行化过程。凭基本的AJAX体验，你应该能够理解数据是如何被寄送到服务器端的。现在，让我们着手讨论反串行化的问题。首先来看一个针对本文示例提供的静态JSON文件。这个文件其实是我们在上一节中串行化的数据：</p>
<p>}} </p>
<p>　　作为一个请求JSON文件的示例，当我们点击下列链接时将请求这个串行化的Auto对象：</p>
<p>＜a href=”javascript:AjaxUpdater.Update(’GET’， ’json/data.js’， displayResponse);”＞Get remote JSON＜/a＞ </p>
<p>　　一旦接收到响应消息，我们的称为displayResponse回调方法就会被激活，然后，我们就能够反串行化并开始使用这些对象：</p>
<p>＜script type=”text/javascript”＞<br />
function displayResponse()<br />
{<br />
　if(Ajax.checkReadyState(’loading’) == “OK”)<br />
　{<br />
　　var Auto = Ajax.request.responseText.parseJSON();<br />
　　document.getElementById(“body”).innerHTML += ”<br />
＜b＞Remote JSON unserialized＜/b＞”;<br />
　　document.getElementById(“body”).innerHTML += ”<br />
Car color: “+Auto.Car.color;<br />
　　document.getElementById(“body”).innerHTML += ”<br />
Wheel color: “+Auto.Car.Wheel.color;<br />
　}<br />
}<br />
＜/script＞ </p>
<p>　　这是相当激动人心的一部分!一旦我们拥有了该responseText，我们就能够简单地使用JSON分析器中的parseJSON方法来从串行化的数据中重建我们的Auto对象。借助于这个新的Auto对象，我们就可以调用相应的子对象。这个特征允许我们在服务器和客户端来回发送对象—而不必进行大量的分析工作，然而在以前标准的XML响应情况下我们将却必须这样做。这样以来，我们就可以创建出能够基于AJAX技术来保留自身状态的客户端JavaScript对象</p>
<h2  class="related_post_title">相关博文</h2><ul class="related_post"><li>2010年07月26日 -- <a href="http://www.5bay.cn/network-programming/ajaxeeee.html" title="Ajax的工作原理">Ajax的工作原理</a> (1)</li><li>2010年07月26日 -- <a href="http://www.5bay.cn/network-programming/ajax.html" title="AJAX的各种控件和类库">AJAX的各种控件和类库</a> (0)</li><li>2010年07月26日 -- <a href="http://www.5bay.cn/network-programming/ajaxxuan.html" title="ajax的缺点">ajax的缺点</a> (0)</li><li>2010年07月26日 -- <a href="http://www.5bay.cn/network-programming/eejaxeeeeee.html" title="使用Ajax时的十个常犯的错误">使用Ajax时的十个常犯的错误</a> (0)</li><li>2010年07月26日 -- <a href="http://www.5bay.cn/network-programming/xmlhttpe.html" title="XMLHTTP对象封装技术">XMLHTTP对象封装技术</a> (0)</li><li>2010年07月26日 -- <a href="http://www.5bay.cn/network-programming/ajaxeeaoe.html" title="AJAX应用程序开发七宗罪">AJAX应用程序开发七宗罪</a> (0)</li><li>2010年07月28日 -- <a href="http://www.5bay.cn/server-building/aspeaojie.html" title="ASP防注入新方式，希望对大家是有用的">ASP防注入新方式，希望对大家是有用的</a> (0)</li><li>2010年07月26日 -- <a href="http://www.5bay.cn/network-programming/phpeezhanchang.html" title="PHP安全之数据过滤">PHP安全之数据过滤</a> (0)</li><li>2010年05月23日 -- <a href="http://www.5bay.cn/server-building/rsyncxiangjie.html" title="Rsync详解">Rsync详解</a> (0)</li><li>2010年07月28日 -- <a href="http://www.5bay.cn/server-building/webshelleechueeee.html" title="Webshell下破解计算机管理员密码">Webshell下破解计算机管理员密码</a> (0)</li><li>2010年07月26日 -- <a href="http://www.5bay.cn/network-programming/eeeeeeee.html" title="最令PHP初学者头痛的十四个问题">最令PHP初学者头痛的十四个问题</a> (0)</li><li>2010年05月23日 -- <a href="http://www.5bay.cn/server-building/mysqlyouhuajiquanwensousuo.html" title="mysql优化及全文搜索">mysql优化及全文搜索</a> (0)</li><li>2010年05月23日 -- <a href="http://www.5bay.cn/server-building/gaoxingnengwangzhanjianshezhinandushubiji.html" title="《高性能网站建设指南》读书笔记">《高性能网站建设指南》读书笔记</a> (0)</li><li>2010年07月26日 -- <a href="http://www.5bay.cn/network-programming/phpeecketee.html" title="PHP和Socket简介">PHP和Socket简介</a> (0)</li><li>2010年07月26日 -- <a href="http://www.5bay.cn/network-programming/phpeefangeredoc.html" title="php的文档句法(heredoc)<<<和PHP字符串操作">php的文档句法(heredoc)<<<和PHP字符串操作</a> (0)</li></ul>
	标签Tags：<a href="http://www.5bay.cn/tag/ajax" title="ajax" rel="tag">ajax</a>, <a href="http://www.5bay.cn/tag/div" title="div" rel="tag">div</a>, <a href="http://www.5bay.cn/tag/html" title="html" rel="tag">html</a>, <a href="http://www.5bay.cn/tag/javascript" title="javascript" rel="tag">javascript</a>, <a href="http://www.5bay.cn/tag/js" title="js" rel="tag">js</a>, <a href="http://www.5bay.cn/tag/mod" title="mod" rel="tag">mod</a>, <a href="http://www.5bay.cn/category/network-programming/php" title="PHP" rel="tag">PHP</a>, <a href="http://www.5bay.cn/tag/url" title="url" rel="tag">url</a>, <a href="http://www.5bay.cn/tag/web" title="web" rel="tag">web</a>, <a href="http://www.5bay.cn/tag/xml" title="xml" rel="tag">xml</a>, <a href="http://www.5bay.cn/tag/%E4%BA%BA" title="人" rel="tag">人</a>, <a href="http://www.5bay.cn/tag/%E4%BB%A3%E7%A0%81" title="代码" rel="tag">代码</a>, <a href="http://www.5bay.cn/tag/%E5%88%86%E7%A6%BB" title="分离" rel="tag">分离</a>, <a href="http://www.5bay.cn/tag/%E5%AF%B9%E8%B1%A1" title="对象" rel="tag">对象</a>, <a href="http://www.5bay.cn/tag/%E5%B1%9E%E6%80%A7" title="属性" rel="tag">属性</a>, <a href="http://www.5bay.cn/tag/%E5%BA%94%E7%94%A8%E7%A8%8B%E5%BA%8F" title="应用程序" rel="tag">应用程序</a>, <a href="http://www.5bay.cn/tag/%E6%95%B0%E6%8D%AE" title="数据" rel="tag">数据</a>, <a href="http://www.5bay.cn/tag/%E6%95%B0%E6%8D%AE%E5%BA%93" title="数据库" rel="tag">数据库</a>, <a href="http://www.5bay.cn/tag/%E6%96%B9%E6%B3%95" title="方法" rel="tag">方法</a>, <a href="http://www.5bay.cn/tag/%E6%B5%8F%E8%A7%88%E5%99%A8" title="浏览器" rel="tag">浏览器</a>, <a href="http://www.5bay.cn/tag/%E7%A8%8B%E5%BA%8F" title="程序" rel="tag">程序</a>, <a href="http://www.5bay.cn/tag/%E7%B1%BB" title="类" rel="tag">类</a>, <a href="http://www.5bay.cn/tag/%E7%BD%91%E7%AB%99" title="网站" rel="tag">网站</a>, <a href="http://www.5bay.cn/category/network-programming" title="网络编程" rel="tag">网络编程</a>, <a href="http://www.5bay.cn/tag/%E8%87%AA%E8%BA%AB" title="自身" rel="tag">自身</a>, <a href="http://www.5bay.cn/tag/e" title="诫" rel="tag">诫</a>, <a href="http://www.5bay.cn/tag/%E9%93%BE%E6%8E%A5" title="链接" rel="tag">链接</a>, <a href="http://www.5bay.cn/tag/%E9%9D%A2%E5%90%91%E5%AF%B9%E8%B1%A1" title="面向对象" rel="tag">面向对象</a><br />
]]></content:encoded>
			<wfw:commentRss>http://www.5bay.cn/network-programming/eesoneeajaxeehuai.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>PHP封装常用Javascript为JS类以便快速调用</title>
		<link>http://www.5bay.cn/network-programming/phpfengzhuangchangyongjavascriptweijsleiyibiankuaisudiaoyong.html</link>
		<comments>http://www.5bay.cn/network-programming/phpfengzhuangchangyongjavascriptweijsleiyibiankuaisudiaoyong.html#comments</comments>
		<pubDate>Sat, 22 May 2010 21:32:51 +0000</pubDate>
		<dc:creator>江小邪</dc:creator>
				<category><![CDATA[JavaScript&Ajax]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[网络编程]]></category>
		<category><![CDATA[class]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[js]]></category>
		<category><![CDATA[mysql]]></category>
		<category><![CDATA[server]]></category>
		<category><![CDATA[sql]]></category>
		<category><![CDATA[url]]></category>
		<category><![CDATA[代码]]></category>
		<category><![CDATA[常用]]></category>
		<category><![CDATA[提交表单]]></category>
		<category><![CDATA[数据]]></category>
		<category><![CDATA[数据库]]></category>
		<category><![CDATA[类]]></category>
		<category><![CDATA[表]]></category>
		<category><![CDATA[表单]]></category>
		<category><![CDATA[连接]]></category>
		<category><![CDATA[页面]]></category>

		<guid isPermaLink="false">http://www.5bay.cn/?p=377</guid>
		<description><![CDATA[<a href="http://www.5bay.cn/network-programming/phpfengzhuangchangyongjavascriptweijsleiyibiankuaisudiaoyong.html"><img align="left" hspace="5" width="150" height="150" src="http://www.5bay.cn/wp-content/plugins/thumbnail-for-excerpts/tfe_no_thumb.png" class="alignleft wp-post-image tfe" alt="" title="" /></a>&#60;?php # $Id: js.class.php,v 0.1 p $ // 禁止直接访问该页面 if (basename($HTTP_SERVER_VARS['PHP_SELF']) == &#34;js.class.php&#34;) { &#160;&#160;&#160;&#160; header(&#34;HTTP/1.0 404 Not Found&#34;); } # Purpose 封装了一些常用的Javascript代码，以便在PHP中快速调用 class JS{ &#160;&#160;&#160;&#160; function JS(){} &#160;&#160;&#160;&#160; #返回上页 &#160;&#160;&#160;&#160; # @param $step 返回的层数 默认为1 &#160;&#160;&#160;&#160; function Back($step = -1){ &#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; $msg = &#34;history.go(&#34;.$step.&#34;);&#34;; &#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; JS::_Write($msg); &#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; JS::FreeResource(); &#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; exit; &#160;&#160;&#160;&#160; } &#160;&#160;&#160; # [...]]]></description>
			<content:encoded><![CDATA[<p>&lt;?<a href="http://www.5bay.cn/tag/php" class="st_tag internal_tag" rel="tag" title="标签 PHP 下的日志">php</a><br />
# $Id: js.<a href="http://www.5bay.cn/tag/class" class="st_tag internal_tag" rel="tag" title="标签 class 下的日志">class</a>.php,v 0.1 p $</p>
<p>// 禁止直接访问该页面<br />
if (basename($HTTP_SERVER_VARS['PHP_SELF']) == &quot;js.class.php&quot;) {<br />
&nbsp;&nbsp;&nbsp;&nbsp; header(&quot;HTTP/1.0 404 Not Found&quot;);<br />
}</p>
<p># Purpose 封装了一些常用的Javascript代码，以便在PHP中快速调用</p>
<p>class JS{<br />
&nbsp;&nbsp;&nbsp;&nbsp; function JS(){}</p>
<p>&nbsp;&nbsp;&nbsp;&nbsp; #返回上页<br />
&nbsp;&nbsp;&nbsp;&nbsp; # @param $step 返回的层数 默认为1<br />
&nbsp;&nbsp;&nbsp;&nbsp; function Back($step = -1){<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; $msg = &quot;history.go(&quot;.$step.&quot;);&quot;;<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; JS::_Write($msg);<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; JS::FreeResource();<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; exit;<br />
&nbsp;&nbsp;&nbsp;&nbsp; }</p>
<p>&nbsp;&nbsp;&nbsp; # 弹出警告的窗口<br />
&nbsp;&nbsp;&nbsp; # @param $msg 警告信息<br />
&nbsp;&nbsp;&nbsp;&nbsp; function Alert($msg){<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; $msg = &quot;alert(\&quot;&quot;.$msg.&quot;\&quot;);&quot;;<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; JS::_Write($msg);<br />
&nbsp;&nbsp;&nbsp;&nbsp; }</p>
<p>&nbsp;&nbsp;&nbsp; # 写js<br />
&nbsp;&nbsp;&nbsp; # @param $msg<br />
&nbsp;&nbsp;&nbsp;&nbsp; function _Write($msg) {<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; echo &quot;&lt;script language=\&quot;<a href="http://www.5bay.cn/tag/javascript" class="st_tag internal_tag" rel="tag" title="标签 javascript 下的日志">javascript</a>\&quot;&gt;\n&quot;;<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; echo $msg;<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; echo &quot;\n&lt;/SCRIPT&gt;&quot;;<br />
&nbsp;&nbsp;&nbsp;&nbsp; }</p>
<p>&nbsp;&nbsp;&nbsp;&nbsp; # 刷新当前页<br />
&nbsp;&nbsp;&nbsp;&nbsp; function Reload(){<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; $msg = &quot;location.reload();&quot;;<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; JS::FreeResource();<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; JS::_Write($msg);<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; exit;<br />
&nbsp;&nbsp;&nbsp;&nbsp; }</p>
<p>&nbsp;&nbsp;&nbsp;&nbsp; #刷新弹出父页<br />
&nbsp;&nbsp;&nbsp;&nbsp; function ReloadOpener(){<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; $msg = &quot;if (opener)&nbsp;&nbsp;&nbsp;&nbsp; opener.location.reload();&quot;;<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; JS::_Write($msg);<br />
&nbsp;&nbsp;&nbsp;&nbsp; }</p>
<p>&nbsp;&nbsp;&nbsp;&nbsp; #跳转到url<br />
&nbsp;&nbsp;&nbsp;&nbsp; <a href="mailto:#@param">#@param</a> $<a href="http://www.5bay.cn/tag/url" class="st_tag internal_tag" rel="tag" title="标签 url 下的日志">url</a> 目标页<br />
&nbsp;&nbsp;&nbsp;&nbsp; function Goto($url){<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; $msg = &quot;location.href = &#8216;$url&#8217;;&quot;;<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; JS::FreeResource();<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; JS::_Write($msg);<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; exit;<br />
&nbsp;&nbsp;&nbsp;&nbsp; }</p>
<p>&nbsp;&nbsp;&nbsp;&nbsp; #关闭窗口<br />
&nbsp;&nbsp;&nbsp;&nbsp; function Close(){<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; $msg = &quot;window.close()&quot;;<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; JS::FreeResource();<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; JS::_Write($msg);<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; exit;<br />
&nbsp;&nbsp;&nbsp;&nbsp; }</p>
<p>&nbsp;&nbsp;&nbsp;&nbsp; #<a href="http://www.5bay.cn/tag/%E6%8F%90%E4%BA%A4%E8%A1%A8%E5%8D%95" class="st_tag internal_tag" rel="tag" title="标签 提交表单 下的日志">提交表单</a><br />
&nbsp;&nbsp;&nbsp;&nbsp; <a href="mailto:#@param">#@param</a> $frm 表单名<br />
&nbsp;&nbsp;&nbsp;&nbsp; function Submit($frm){<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; $msg = $frm.&quot;.submit();&quot;;<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; JS::_Write($msg);<br />
&nbsp;&nbsp;&nbsp;&nbsp; }</p>
<p>&nbsp;&nbsp;&nbsp; #关闭数据库连接<br />
&nbsp;&nbsp;&nbsp; function FreeResource(){<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; // 数据库连接标志<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; global $conn;<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if (is_resource($conn))<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; @mysql_close($conn);<br />
&nbsp;&nbsp;&nbsp;&nbsp; }<br />
}<br />
?&gt;</p>
<h2  class="related_post_title">相关博文</h2><ul class="related_post"><li>2010年05月23日 -- <a href="http://www.5bay.cn/server-building/mysqlyouhuajiquanwensousuo.html" title="mysql优化及全文搜索">mysql优化及全文搜索</a> (0)</li><li>2010年07月26日 -- <a href="http://www.5bay.cn/network-programming/phpeefangeredoc.html" title="php的文档句法(heredoc)<<<和PHP字符串操作">php的文档句法(heredoc)<<<和PHP字符串操作</a> (0)</li><li>2010年07月28日 -- <a href="http://www.5bay.cn/server-building/aspeaojie.html" title="ASP防注入新方式，希望对大家是有用的">ASP防注入新方式，希望对大家是有用的</a> (0)</li><li>2010年07月26日 -- <a href="http://www.5bay.cn/network-programming/eeeeeeee.html" title="最令PHP初学者头痛的十四个问题">最令PHP初学者头痛的十四个问题</a> (0)</li><li>2010年07月26日 -- <a href="http://www.5bay.cn/network-programming/phpeeeeeeeehuai.html" title="PHP对文本数据库的基本操作方法">PHP对文本数据库的基本操作方法</a> (0)</li><li>2010年07月26日 -- <a href="http://www.5bay.cn/network-programming/phpeecketee.html" title="PHP和Socket简介">PHP和Socket简介</a> (0)</li><li>2010年07月26日 -- <a href="http://www.5bay.cn/network-programming/ajaxeeee.html" title="Ajax的工作原理">Ajax的工作原理</a> (1)</li><li>2010年07月26日 -- <a href="http://www.5bay.cn/network-programming/eejaxeeeeee.html" title="使用Ajax时的十个常犯的错误">使用Ajax时的十个常犯的错误</a> (0)</li><li>2010年07月26日 -- <a href="http://www.5bay.cn/network-programming/eesoneeajaxeehuai.html" title="基于JSON的高级AJAX开发技术">基于JSON的高级AJAX开发技术</a> (0)</li><li>2010年05月23日 -- <a href="http://www.5bay.cn/server-building/eacceleratoryumemcachedequbieyuyongtu.html" title="eAccelerator与memcache的区别与用途">eAccelerator与memcache的区别与用途</a> (2)</li><li>2010年05月23日 -- <a href="http://www.5bay.cn/network-programming/phpzhongdememcachehanshukumemcachefunctions.html" title="PHP中的Memcache函数库（Memcache Functions）">PHP中的Memcache函数库（Memcache Functions）</a> (0)</li><li>2010年07月26日 -- <a href="http://www.5bay.cn/network-programming/ajax.html" title="AJAX的各种控件和类库">AJAX的各种控件和类库</a> (0)</li><li>2010年07月26日 -- <a href="http://www.5bay.cn/network-programming/xmlhttpe.html" title="XMLHTTP对象封装技术">XMLHTTP对象封装技术</a> (0)</li><li>2010年07月26日 -- <a href="http://www.5bay.cn/network-programming/phpeezhanchang.html" title="PHP安全之数据过滤">PHP安全之数据过滤</a> (0)</li><li>2010年05月23日 -- <a href="http://www.5bay.cn/server-building/rsyncxiangjie.html" title="Rsync详解">Rsync详解</a> (0)</li></ul>
	标签Tags：<a href="http://www.5bay.cn/tag/class" title="class" rel="tag">class</a>, <a href="http://www.5bay.cn/tag/javascript" title="javascript" rel="tag">javascript</a>, <a href="http://www.5bay.cn/category/network-programming/javascript-ajax" title="JavaScript&amp;Ajax" rel="tag">JavaScript&amp;Ajax</a>, <a href="http://www.5bay.cn/tag/js" title="js" rel="tag">js</a>, <a href="http://www.5bay.cn/tag/mysql" title="mysql" rel="tag">mysql</a>, <a href="http://www.5bay.cn/category/network-programming/php" title="PHP" rel="tag">PHP</a>, <a href="http://www.5bay.cn/tag/php" title="PHP" rel="tag">PHP</a>, <a href="http://www.5bay.cn/tag/server" title="server" rel="tag">server</a>, <a href="http://www.5bay.cn/tag/sql" title="sql" rel="tag">sql</a>, <a href="http://www.5bay.cn/tag/url" title="url" rel="tag">url</a>, <a href="http://www.5bay.cn/tag/%E4%BB%A3%E7%A0%81" title="代码" rel="tag">代码</a>, <a href="http://www.5bay.cn/tag/%E5%B8%B8%E7%94%A8" title="常用" rel="tag">常用</a>, <a href="http://www.5bay.cn/tag/%E6%8F%90%E4%BA%A4%E8%A1%A8%E5%8D%95" title="提交表单" rel="tag">提交表单</a>, <a href="http://www.5bay.cn/tag/%E6%95%B0%E6%8D%AE" title="数据" rel="tag">数据</a>, <a href="http://www.5bay.cn/tag/%E6%95%B0%E6%8D%AE%E5%BA%93" title="数据库" rel="tag">数据库</a>, <a href="http://www.5bay.cn/tag/%E7%B1%BB" title="类" rel="tag">类</a>, <a href="http://www.5bay.cn/category/network-programming" title="网络编程" rel="tag">网络编程</a>, <a href="http://www.5bay.cn/tag/%E8%A1%A8" title="表" rel="tag">表</a>, <a href="http://www.5bay.cn/tag/%E8%A1%A8%E5%8D%95" title="表单" rel="tag">表单</a>, <a href="http://www.5bay.cn/tag/%E8%BF%9E%E6%8E%A5" title="连接" rel="tag">连接</a>, <a href="http://www.5bay.cn/tag/%E9%A1%B5%E9%9D%A2" title="页面" rel="tag">页面</a><br />
]]></content:encoded>
			<wfw:commentRss>http://www.5bay.cn/network-programming/phpfengzhuangchangyongjavascriptweijsleiyibiankuaisudiaoyong.html/feed</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>JS实现全景图效果360度旋转</title>
		<link>http://www.5bay.cn/network-programming/jsshixianquanjingtuxiaoguo360duxuanzhuan.html</link>
		<comments>http://www.5bay.cn/network-programming/jsshixianquanjingtuxiaoguo360duxuanzhuan.html#comments</comments>
		<pubDate>Sat, 22 May 2010 21:20:17 +0000</pubDate>
		<dc:creator>江小邪</dc:creator>
				<category><![CDATA[JavaScript&Ajax]]></category>
		<category><![CDATA[网络编程]]></category>
		<category><![CDATA[div]]></category>
		<category><![CDATA[ie]]></category>
		<category><![CDATA[js]]></category>
		<category><![CDATA[seo]]></category>

		<guid isPermaLink="false">http://www.5bay.cn/?p=364</guid>
		<description><![CDATA[<a href="http://www.5bay.cn/network-programming/jsshixianquanjingtuxiaoguo360duxuanzhuan.html"><img align="left" hspace="5" width="150" height="150" src="http://www.5bay.cn/wp-content/plugins/thumbnail-for-excerpts/tfe_no_thumb.png" class="alignleft wp-post-image tfe" alt="" title="" /></a>&#60;div style=&#34;border-bottom: red 1px solid; position: absolute; border-left: red 1px solid; width: 500px; height: 190px; overflow: hidden; border-top: red 1px solid; cursor: hand; border-right: red 1px solid&#34; id=&#34;div1&#34; onmouseout=&#34;change(1);&#34; onmousemove=&#34;getpos()&#34; onmouseover=&#34;clearTimeout(scrl);&#34;&#62;&#60;img onload=&#34;change(1);&#34; alt=&#34;&#34; src=&#34;http://www.jb51.net/upload/out500b.jpg&#34; /&#62;&#60;/div&#62; &#60;script&#62; var scrl,direction=&#34;right&#34;; var x,xold,xdiff, i=1; function change(start){ if(direction == &#34;right&#34;){ &#160;&#160;&#160; if(div1.scrollTop+190 &#60; div1.scrollHeight){ &#160;&#160;&#160;&#160;&#160;&#160;&#160; div1.scrollTop += 190; &#160;&#160;&#160; [...]]]></description>
			<content:encoded><![CDATA[<p>&lt;<a href="http://www.5bay.cn/tag/div" class="st_tag internal_tag" rel="tag" title="标签 div 下的日志">div</a> style=&quot;border-bottom: red 1px solid; position: absolute; border-left: red 1px solid; width: 500px; height: 190px; overflow: hidden; border-top: red 1px solid; cursor: hand; border-right: red 1px solid&quot; id=&quot;<a href="http://www.5bay.cn/tag/div" class="st_tag internal_tag" rel="tag" title="标签 div 下的日志">div</a>1&quot; onmouseout=&quot;change(1);&quot; onmousemove=&quot;getpos()&quot; onmouseover=&quot;clearTimeout(scrl);&quot;&gt;&lt;img onload=&quot;change(1);&quot; alt=&quot;&quot; src=&quot;<a href="http://www.jb51.net/upload/out500b.jpg">http://www.jb51.net/upload/out500b.jpg</a>&quot; /&gt;&lt;/div&gt;<br />
&lt;script&gt;<br />
var scrl,direction=&quot;right&quot;;<br />
var x,xold,xdiff, i=1;</p>
<p>function change(start){<br />
if(direction == &quot;right&quot;){<br />
&nbsp;&nbsp;&nbsp; if(div1.scrollTop+190 &lt; div1.scrollHeight){<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; div1.scrollTop += 190;<br />
&nbsp;&nbsp;&nbsp; }<br />
&nbsp;&nbsp;&nbsp; else{<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; div1.scrollTop = 0;<br />
&nbsp;&nbsp;&nbsp; }<br />
}<br />
else{<br />
&nbsp;&nbsp;&nbsp; if(div1.scrollTop-190 &gt; 0){<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; div1.scrollTop -= 190;<br />
&nbsp;&nbsp;&nbsp; }<br />
&nbsp;&nbsp;&nbsp; else{<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; div1.scrollTop = div1.scrollHeight;<br />
&nbsp;&nbsp;&nbsp; }<br />
}<br />
if(start) scrl = setTimeout(&quot;change(1)&quot;,100);<br />
else clearTimeout(scrl);<br />
}</p>
<p>function getpos(){<br />
x = event.clientX;<br />
xdiff = x &#8211; xold;<br />
xold = x;<br />
if(xdiff&gt;0) direction = &quot;right&quot;;<br />
if(xdiff&lt;0) direction = &quot;left&quot;;<br />
change(0);<br />
}<br />
&lt;/script&gt;</p>
<h2  class="related_post_title">相关博文</h2><ul class="related_post"><li>2010年07月26日 -- <a href="http://www.5bay.cn/network-programming/innerhtmleenertexteeterhtmlqia.html" title="innerHTML、innerText和outerHTML的用法">innerHTML、innerText和outerHTML的用法</a> (0)</li><li>2010年05月23日 -- <a href="http://www.5bay.cn/network-programming/tupianlunhuanleiie7opffchromeceshitongguo.html" title="图片轮换类，IE7、OP、FF、Chrome测试通过">图片轮换类，IE7、OP、FF、Chrome测试通过</a> (2)</li><li>2010年05月23日 -- <a href="http://www.5bay.cn/server-building/nginxderewriteguize.html" title="nginx的rewrite规则">nginx的rewrite规则</a> (1)</li><li>2011年06月29日 -- <a href="http://www.5bay.cn/me/kaiyuanruanjiandeyinglimoshi.html" title="开源软件的盈利模式">开源软件的盈利模式</a> (0)</li><li>2011年06月29日 -- <a href="http://www.5bay.cn/android%e7%ac%94%e8%ae%b0/zaiandroidzhongchuangjianqidongjiemian.html" title="在Android中创建启动界面">在Android中创建启动界面</a> (0)</li><li>2010年07月28日 -- <a href="http://www.5bay.cn/server-building/webshelleechueeee.html" title="Webshell下破解计算机管理员密码">Webshell下破解计算机管理员密码</a> (0)</li><li>2010年07月26日 -- <a href="http://www.5bay.cn/network-programming/ajax.html" title="AJAX的各种控件和类库">AJAX的各种控件和类库</a> (0)</li><li>2010年07月26日 -- <a href="http://www.5bay.cn/network-programming/xmlhttpe.html" title="XMLHTTP对象封装技术">XMLHTTP对象封装技术</a> (0)</li><li>2010年07月26日 -- <a href="http://www.5bay.cn/network-programming/ajaxeeeeseeao.html" title="ajax基础知识:js事件触发大全">ajax基础知识:js事件触发大全</a> (0)</li><li>2010年07月26日 -- <a href="http://www.5bay.cn/network-programming/ajaxxuan.html" title="ajax的缺点">ajax的缺点</a> (0)</li><li>2010年07月26日 -- <a href="http://www.5bay.cn/network-programming/eesoneeajaxeehuai.html" title="基于JSON的高级AJAX开发技术">基于JSON的高级AJAX开发技术</a> (0)</li><li>2010年05月23日 -- <a href="http://www.5bay.cn/server-building/mysqlyouhuajiquanwensousuo.html" title="mysql优化及全文搜索">mysql优化及全文搜索</a> (0)</li><li>2010年05月23日 -- <a href="http://www.5bay.cn/network-programming/phpzhongdememcachehanshukumemcachefunctions.html" title="PHP中的Memcache函数库（Memcache Functions）">PHP中的Memcache函数库（Memcache Functions）</a> (0)</li><li>2011年06月29日 -- <a href="http://www.5bay.cn/android%e7%ac%94%e8%ae%b0/androidzaixiankaifagongjuappinventor.html" title="Android在线开发工具 App Inventor">Android在线开发工具 App Inventor</a> (0)</li><li>2011年06月29日 -- <a href="http://www.5bay.cn/server-building/chedimingbaiipdizhieeeejisuanxiangguandizhi.html" title="彻底明白IP地址——计算相关地址">彻底明白IP地址——计算相关地址</a> (0)</li></ul>
	标签Tags：<a href="http://www.5bay.cn/tag/div" title="div" rel="tag">div</a>, <a href="http://www.5bay.cn/tag/ie" title="ie" rel="tag">ie</a>, <a href="http://www.5bay.cn/category/network-programming/javascript-ajax" title="JavaScript&amp;Ajax" rel="tag">JavaScript&amp;Ajax</a>, <a href="http://www.5bay.cn/tag/js" title="js" rel="tag">js</a>, <a href="http://www.5bay.cn/tag/seo" title="seo" rel="tag">seo</a>, <a href="http://www.5bay.cn/category/network-programming" title="网络编程" rel="tag">网络编程</a><br />
]]></content:encoded>
			<wfw:commentRss>http://www.5bay.cn/network-programming/jsshixianquanjingtuxiaoguo360duxuanzhuan.html/feed</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>nginx的rewrite规则</title>
		<link>http://www.5bay.cn/server-building/nginxderewriteguize.html</link>
		<comments>http://www.5bay.cn/server-building/nginxderewriteguize.html#comments</comments>
		<pubDate>Sat, 22 May 2010 21:17:23 +0000</pubDate>
		<dc:creator>江小邪</dc:creator>
				<category><![CDATA[服务器构建&安全]]></category>
		<category><![CDATA[301]]></category>
		<category><![CDATA[access]]></category>
		<category><![CDATA[cookie]]></category>
		<category><![CDATA[css]]></category>
		<category><![CDATA[domain]]></category>
		<category><![CDATA[html]]></category>
		<category><![CDATA[ie]]></category>
		<category><![CDATA[include]]></category>
		<category><![CDATA[js]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[seo]]></category>
		<category><![CDATA[server]]></category>
		<category><![CDATA[sql]]></category>
		<category><![CDATA[swf]]></category>
		<category><![CDATA[web]]></category>
		<category><![CDATA[判断]]></category>
		<category><![CDATA[图片]]></category>
		<category><![CDATA[密码]]></category>
		<category><![CDATA[正则表达式]]></category>
		<category><![CDATA[浏览器]]></category>
		<category><![CDATA[网站]]></category>
		<category><![CDATA[自定义]]></category>
		<category><![CDATA[表]]></category>
		<category><![CDATA[重定向]]></category>
		<category><![CDATA[链接]]></category>
		<category><![CDATA[错误]]></category>
		<category><![CDATA[页面]]></category>

		<guid isPermaLink="false">http://www.5bay.cn/?p=359</guid>
		<description><![CDATA[<a href="http://www.5bay.cn/server-building/nginxderewriteguize.html"><img align="left" hspace="5" width="150" height="150" src="http://www.5bay.cn/wp-content/plugins/thumbnail-for-excerpts/tfe_no_thumb.png" class="alignleft wp-post-image tfe" alt="" title="" /></a>正则表达式匹配，其中： * ~ 为区分大小写匹配 * ~* 为不区分大小写匹配 * !~和!~*分别为区分大小写不匹配及不区分大小写不匹配 文件及目录匹配，其中： * -f和!-f用来判断是否存在文件 * -d和!-d用来判断是否存在目录 * -e和!-e用来判断是否存在文件或目录 * -x和!-x用来判断文件是否可执行 flag标记有： * last 相当于Apache里的[L]标记，表示完成rewrite * break 终止匹配, 不再匹配后面的规则 * redirect 返回302临时重定向 地址栏会显示跳转后的地址 * permanent 返回301永久重定向 地址栏会显示跳转后的地址 一些可用的全局变量有，可以用做条件判断(待补全) $args $content_length $content_type $document_root $document_uri $host $http_user_agent $http_cookie $limit_rate $request_body_file $request_method $remote_addr $remote_port $remote_user $request_filename $request_uri $query_string $scheme $server_protocol $server_addr [...]]]></description>
			<content:encoded><![CDATA[<p>正则表达式匹配，其中：</p>
<p>* ~ 为区分大小写匹配<br />
* ~* 为不区分大小写匹配<br />
* !~和!~*分别为区分大小写不匹配及不区分大小写不匹配<br />
文件及目录匹配，其中：</p>
<p>* -f和!-f用来判断是否存在文件<br />
* -d和!-d用来判断是否存在目录<br />
* -e和!-e用来判断是否存在文件或目录<br />
* -x和!-x用来判断文件是否可执行<br />
flag标记有：</p>
<p>* last 相当于Apache里的[L]标记，表示完成rewrite<br />
* break 终止匹配, 不再匹配后面的规则<br />
* redirect 返回302临时重定向 地址栏会显示跳转后的地址<br />
* permanent 返回301永久重定向 地址栏会显示跳转后的地址<br />
一些可用的全局变量有，可以用做条件判断(待补全)<span id="more-359"></span></p>
<p>$args<br />
$content_length<br />
$content_type<br />
$document_root<br />
$document_uri<br />
$host<br />
$http_user_agent<br />
$http_<a href="http://www.5bay.cn/tag/cookie" class="st_tag internal_tag" rel="tag" title="标签 cookie 下的日志">cookie</a><br />
$limit_rate<br />
$request_body_file<br />
$request_method<br />
$remote_addr<br />
$remote_port<br />
$remote_user<br />
$request_filename<br />
$request_uri<br />
$query_string<br />
$scheme<br />
$<a href="http://www.5bay.cn/tag/server" class="st_tag internal_tag" rel="tag" title="标签 server 下的日志">server</a>_protocol<br />
$server_addr<br />
$server_name<br />
$server_port<br />
$uri<br />
结合QeePHP的例子</p>
<p>if (!-d $request_filename) {<br />
rewrite ^/([a-z-A-Z]+)/([a-z-A-Z]+)/?(.*)$ /index.php?namespace=user&amp;controller=$1&amp;action=$2&amp;$3 last;<br />
rewrite ^/([a-z-A-Z]+)/?$ /index.php?namespace=user&amp;controller=$1 last;<br />
break;<br />
多目录转成参数<br />
abc.domian.com/sort/2 =&gt; abc.domian.com/index.php?act=sort&amp;name=abc&amp;id=2<br />
}</p>
<p>if ($host ~* (.*)\.domain\.com) {<br />
set $sub_name $1;<br />
rewrite ^/sort\/(\d+)\/?$ /index.php?act=sort&amp;cid=$sub_name&amp;id=$1 last;<br />
}<br />
目录对换<br />
/123456/xxxx -&gt; /xxxx?id=123456</p>
<p>rewrite ^/(\d+)/(.+)/ /$2?id=$1 last;<br />
例如下面设定nginx在用户使用ie的使用重定向到/nginx-ie目录下：</p>
<p>if ($http_user_agent ~ MSIE) {<br />
rewrite ^(.*)$ /nginx-<a href="http://www.5bay.cn/tag/ie" class="st_tag internal_tag" rel="tag" title="标签 ie 下的日志">ie</a>/$1 break;<br />
}<br />
目录自动加“/”</p>
<p>if (-d $request_filename){<br />
rewrite ^/(.*)([^/])$ http://$host/$1$2/ permanent;<br />
}<br />
禁止htaccess</p>
<p>location ~/\.ht {<br />
deny all;<br />
}<br />
禁止多个目录</p>
<p>location ~ ^/(cron|templates)/ {<br />
deny all;<br />
break;<br />
}<br />
禁止以/data开头的文件<br />
可以禁止/data/下多级目录下.log.txt等请求;</p>
<p>location ~ ^/data {<br />
deny all;<br />
}<br />
禁止单个目录<br />
不能禁止.log.txt能请求</p>
<p>location /searchword/cron/ {<br />
deny all;<br />
}<br />
禁止单个文件</p>
<p>location ~ /data/sql/data.sql {<br />
deny all;<br />
}<br />
给favicon.ico和robots.txt设置过期时间;<br />
这里为favicon.ico为99天,robots.txt为7天并不记录404错误日志</p>
<p>location ~(favicon.ico) {<br />
log_not_found off;<br />
expires 99d;<br />
break;<br />
}</p>
<p>location ~(robots.txt) {<br />
log_not_found off;<br />
expires 7d;<br />
break;<br />
}<br />
设定某个文件的过期时间;这里为600秒，并不记录访问日志</p>
<p>location ^~ /html/scripts/loadhead_1.<a href="http://www.5bay.cn/tag/js" class="st_tag internal_tag" rel="tag" title="标签 js 下的日志">js</a> {<br />
access_log off;<br />
root /opt/lampp/htdocs/web;<br />
expires 600;<br />
break;<br />
}<br />
文件反盗链并设置过期时间<br />
这里的return 412 为自定义的http状态码，默认为403，方便找出正确的盗链的请求<br />
“rewrite ^/ http://leech.xxx.com/leech.gif;”显示一张防盗链图片<br />
“access_log off;”不记录访问日志，减轻压力<br />
“expires 3d”所有文件3天的浏览器缓存</p>
<p>location ~* ^.+\.(jpg|jpeg|gif|png|<a href="http://www.5bay.cn/tag/swf" class="st_tag internal_tag" rel="tag" title="标签 swf 下的日志">swf</a>|rar|zip|<a href="http://www.5bay.cn/tag/css" class="st_tag internal_tag" rel="tag" title="标签 css 下的日志">css</a>|js)$ {<br />
valid_referers none blocked *.xxx.com *.xxx.net localhost 208.97.167.194;<br />
if ($invalid_referer) {<br />
rewrite ^/ http://leech.xxx.com/leech.gif;<br />
return 412;<br />
break;<br />
}<br />
access_log off;<br />
root /opt/lampp/htdocs/web;<br />
expires 3d;<br />
break;<br />
}<br />
只充许固定ip访问网站，并加上密码</p>
<p>root /opt/htdocs/www;<br />
allow 208.97.167.194;<br />
allow 222.33.1.2;<br />
allow 231.152.49.4;<br />
deny all;<br />
auth_basic “C1G_ADMIN”;<br />
auth_basic_user_file htpasswd;<br />
将多级目录下的文件转成一个文件，增强seo效果<br />
/job-123-456-789.html 指向/job/123/456/789.html</p>
<p>rewrite ^/job-([0-9]+)-([0-9]+)-([0-9]+)\.html$ /job/$1/$2/jobshow_$3.html last;<br />
将根目录下某个文件夹指向2级目录<br />
如/shanghaijob/</p>
<p>指向 /area/shanghai/<br />
如果你将last改成permanent，那么浏览器地址栏显是/location/shanghai/</p>
<p>rewrite ^/([0-9a-z]+)job/(.*)$ /area/$1/$2 last;<br />
上面例子有个问题是访问/shanghai 时将不会匹配</p>
<p>rewrite ^/([0-9a-z]+)job$ /area/$1/ last;<br />
rewrite ^/([0-9a-z]+)job/(.*)$ /area/$1/$2 last;<br />
这样/shanghai 也可以访问了，但页面中的相对链接无法使用，<br />
如./list_1.html真实地址是/area/shanghia/list_1.html会变成/list_1.html,导至无法访问。</p>
<p>那我加上自动跳转也是不行咯<br />
(-d $request_filename)它有个条件是必需为真实目录，而我的rewrite不是的，所以没有效果</p>
<p>if (-d $request_filename){<br />
rewrite ^/(.*)([^/])$ http://$host/$1$2/ permanent;<br />
}<br />
知道原因后就好办了，让我手动跳转吧</p>
<p>rewrite ^/([0-9a-z]+)job$ /$1job/ permanent;<br />
rewrite ^/([0-9a-z]+)job/(.*)$ /area/$1/$2 last;<br />
文件和目录不存在的时候重定向：</p>
<p>if (!-e $request_filename) {<br />
proxy_pass http://127.0.0.1;<br />
}<br />
域名跳转</p>
<p>server<br />
{<br />
listen 80;<br />
server_name jump.xxx.com;<br />
index index.html index.htm index.php;<br />
root /opt/lampp/htdocs/www;<br />
rewrite ^/ http://www.xxx.com/;<br />
access_log off;<br />
}<br />
多域名转向</p>
<p>server_name www.xxx.com;<br />
index index.html index.htm index.php;<br />
root /opt/lampp/htdocs;<br />
if ($host ~ “xxx\.net”) {<br />
rewrite ^(.*) http://www.xxx.com$1 permanent;<br />
}<br />
三级域名跳转</p>
<p>if ($http_host ~* “^(.*)\.i\.xxx\.com$”) {<br />
rewrite ^(.*) http://top.xxx.com$1;<br />
break;<br />
}<br />
域名镜向</p>
<p>server<br />
{<br />
listen 80;<br />
server_name mirror.xxx.com;<br />
index index.html index.htm index.php;<br />
root /opt/lampp/htdocs/www;<br />
rewrite ^/(.*) http://www.xxx.com/$1 last;<br />
access_log off;<br />
}<br />
某个子目录作镜向</p>
<p>location ^~ /zhaopinhui {<br />
rewrite ^.+ http://zph.xxx.com/ last;<br />
break;<br />
}<br />
discuz ucenter home (uchome) rewrite</p>
<p>rewrite ^/(space|network)-(.+)\.html$ /$1.php?rewrite=$2 last;<br />
rewrite ^/(space|network)\.html$ /$1.php last;<br />
rewrite ^/([0-9]+)$ /space.php?uid=$1 last;<br />
discuz 7 rewrite</p>
<p>rewrite ^(.*)/archiver/((fid|tid)-[\w\-]+\.html)$ $1/archiver/index.php?$2 last;<br />
rewrite ^(.*)/forum-([0-9]+)-([0-9]+)\.html$ $1/forumdisplay.php?fid=$2&amp;page=$3 last;<br />
rewrite ^(.*)/thread-([0-9]+)-([0-9]+)-([0-9]+)\.html$ $1/viewthread.php?tid=$2&amp;extra=page\%3D$4&amp;page=$3 last;<br />
rewrite ^(.*)/profile-(username|uid)-(.+)\.html$ $1/viewpro.php?$2=$3 last;<br />
rewrite ^(.*)/space-(username|uid)-(.+)\.html$ $1/space.php?$2=$3 last;<br />
rewrite ^(.*)/tag-(.+)\.html$ $1/tag.php?name=$2 last;<br />
给discuz某版块单独配置域名</p>
<p>server_name bbs.xxx.com;</p>
<p>location = / {<br />
if ($http_host ~ news\.xxx.com$)<br />
{<br />
rewrite ^.+ http://news.xxx.com/forum-831-1.html last;<br />
break;<br />
}<br />
}<br />
discuz ucenter 头像 rewrite 优化</p>
<p>location ^~ /ucenter {<br />
location ~ .*\.php?$<br />
{<br />
#fastcgi_pass unix:/tmp/php-cgi.sock;<br />
fastcgi_pass 127.0.0.1:9000;<br />
fastcgi_index index.php;<br />
include fcgi.conf;<br />
}</p>
<p>location /ucenter/data/avatar {<br />
log_not_found off;<br />
access_log off;<br />
location ~ /(.*)_big\.jpg$ {<br />
error_page 404 /ucenter/images/noavatar_big.gif;<br />
}<br />
location ~ /(.*)_middle\.jpg$ {<br />
error_page 404 /ucenter/images/noavatar_middle.gif;<br />
}<br />
location ~ /(.*)_small\.jpg$ {<br />
error_page 404 /ucenter/images/noavatar_small.gif;<br />
}<br />
expires 300;<br />
break;<br />
}<br />
}<br />
jspace rewrite</p>
<p>location ~ .*\.php?$<br />
{<br />
#fastcgi_pass unix:/tmp/php-cgi.sock;<br />
fastcgi_pass 127.0.0.1:9000;<br />
fastcgi_index index.php;<br />
include fcgi.conf;<br />
}</p>
<p>location ~* ^/index.php/<br />
{<br />
rewrite ^/index.php/(.*) /index.php?$1 break;<br />
fastcgi_pass 127.0.0.1:9000;<br />
fastcgi_index index.php;<br />
include fcgi.conf;<br />
}</p>
<h2  class="related_post_title">相关博文</h2><ul class="related_post"><li>2010年07月26日 -- <a href="http://www.5bay.cn/network-programming/eejaxeeeeee.html" title="使用Ajax时的十个常犯的错误">使用Ajax时的十个常犯的错误</a> (0)</li><li>2010年05月23日 -- <a href="http://www.5bay.cn/server-building/rsyncxiangjie.html" title="Rsync详解">Rsync详解</a> (0)</li><li>2010年05月23日 -- <a href="http://www.5bay.cn/server-building/gaoxingnengwangzhanjianshezhinandushubiji.html" title="《高性能网站建设指南》读书笔记">《高性能网站建设指南》读书笔记</a> (0)</li><li>2010年07月26日 -- <a href="http://www.5bay.cn/network-programming/eeeeeeee.html" title="最令PHP初学者头痛的十四个问题">最令PHP初学者头痛的十四个问题</a> (0)</li><li>2010年07月26日 -- <a href="http://www.5bay.cn/network-programming/ajaxxuan.html" title="ajax的缺点">ajax的缺点</a> (0)</li><li>2010年05月23日 -- <a href="http://www.5bay.cn/server-building/mysqlyouhuajiquanwensousuo.html" title="mysql优化及全文搜索">mysql优化及全文搜索</a> (0)</li><li>2010年07月26日 -- <a href="http://www.5bay.cn/network-programming/ajax.html" title="AJAX的各种控件和类库">AJAX的各种控件和类库</a> (0)</li><li>2010年07月26日 -- <a href="http://www.5bay.cn/network-programming/phpeezhanchang.html" title="PHP安全之数据过滤">PHP安全之数据过滤</a> (0)</li><li>2010年07月28日 -- <a href="http://www.5bay.cn/server-building/webshelleechueeee.html" title="Webshell下破解计算机管理员密码">Webshell下破解计算机管理员密码</a> (0)</li><li>2010年07月28日 -- <a href="http://www.5bay.cn/server-building/aoeempirebakeebshell.html" title="帝国备份王(Empirebak)拿webshell">帝国备份王(Empirebak)拿webshell</a> (0)</li><li>2010年07月26日 -- <a href="http://www.5bay.cn/network-programming/phpeecketee.html" title="PHP和Socket简介">PHP和Socket简介</a> (0)</li><li>2010年07月26日 -- <a href="http://www.5bay.cn/network-programming/eesoneeajaxeehuai.html" title="基于JSON的高级AJAX开发技术">基于JSON的高级AJAX开发技术</a> (0)</li><li>2010年07月22日 -- <a href="http://www.5bay.cn/me/csseeeeyao.html" title="CSS 中的太极拳口诀">CSS 中的太极拳口诀</a> (0)</li><li>2010年05月23日 -- <a href="http://www.5bay.cn/network-programming/phpfengzhuangchangyongjavascriptweijsleiyibiankuaisudiaoyong.html" title="PHP封装常用Javascript为JS类以便快速调用">PHP封装常用Javascript为JS类以便快速调用</a> (1)</li><li>2008年11月12日 -- <a href="http://www.5bay.cn/network-programming/javascript-ajax/documentbodyscrolltop%E4%B8%BA0.html" title="document.body.scrollTop为0">document.body.scrollTop为0</a> (0)</li></ul>
	标签Tags：<a href="http://www.5bay.cn/tag/301" title="301" rel="tag">301</a>, <a href="http://www.5bay.cn/tag/access" title="access" rel="tag">access</a>, <a href="http://www.5bay.cn/tag/cookie" title="cookie" rel="tag">cookie</a>, <a href="http://www.5bay.cn/tag/css" title="css" rel="tag">css</a>, <a href="http://www.5bay.cn/tag/domain" title="domain" rel="tag">domain</a>, <a href="http://www.5bay.cn/tag/html" title="html" rel="tag">html</a>, <a href="http://www.5bay.cn/tag/ie" title="ie" rel="tag">ie</a>, <a href="http://www.5bay.cn/tag/include" title="include" rel="tag">include</a>, <a href="http://www.5bay.cn/tag/js" title="js" rel="tag">js</a>, <a href="http://www.5bay.cn/tag/php" title="PHP" rel="tag">PHP</a>, <a href="http://www.5bay.cn/tag/seo" title="seo" rel="tag">seo</a>, <a href="http://www.5bay.cn/tag/server" title="server" rel="tag">server</a>, <a href="http://www.5bay.cn/tag/sql" title="sql" rel="tag">sql</a>, <a href="http://www.5bay.cn/tag/swf" title="swf" rel="tag">swf</a>, <a href="http://www.5bay.cn/tag/web" title="web" rel="tag">web</a>, <a href="http://www.5bay.cn/tag/%E5%88%A4%E6%96%AD" title="判断" rel="tag">判断</a>, <a href="http://www.5bay.cn/tag/%E5%9B%BE%E7%89%87" title="图片" rel="tag">图片</a>, <a href="http://www.5bay.cn/tag/%E5%AF%86%E7%A0%81" title="密码" rel="tag">密码</a>, <a href="http://www.5bay.cn/category/server-building" title="服务器构建&amp;安全" rel="tag">服务器构建&amp;安全</a>, <a href="http://www.5bay.cn/tag/%E6%AD%A3%E5%88%99%E8%A1%A8%E8%BE%BE%E5%BC%8F" title="正则表达式" rel="tag">正则表达式</a>, <a href="http://www.5bay.cn/tag/%E6%B5%8F%E8%A7%88%E5%99%A8" title="浏览器" rel="tag">浏览器</a>, <a href="http://www.5bay.cn/tag/%E7%BD%91%E7%AB%99" title="网站" rel="tag">网站</a>, <a href="http://www.5bay.cn/tag/%E8%87%AA%E5%AE%9A%E4%B9%89" title="自定义" rel="tag">自定义</a>, <a href="http://www.5bay.cn/tag/%E8%A1%A8" title="表" rel="tag">表</a>, <a href="http://www.5bay.cn/tag/%E9%87%8D%E5%AE%9A%E5%90%91" title="重定向" rel="tag">重定向</a>, <a href="http://www.5bay.cn/tag/%E9%93%BE%E6%8E%A5" title="链接" rel="tag">链接</a>, <a href="http://www.5bay.cn/tag/%E9%94%99%E8%AF%AF" title="错误" rel="tag">错误</a>, <a href="http://www.5bay.cn/tag/%E9%A1%B5%E9%9D%A2" title="页面" rel="tag">页面</a><br />
]]></content:encoded>
			<wfw:commentRss>http://www.5bay.cn/server-building/nginxderewriteguize.html/feed</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>《高性能网站建设指南》读书笔记</title>
		<link>http://www.5bay.cn/server-building/gaoxingnengwangzhanjianshezhinandushubiji.html</link>
		<comments>http://www.5bay.cn/server-building/gaoxingnengwangzhanjianshezhinandushubiji.html#comments</comments>
		<pubDate>Sat, 22 May 2010 21:06:26 +0000</pubDate>
		<dc:creator>江小邪</dc:creator>
				<category><![CDATA[服务器构建&安全]]></category>
		<category><![CDATA[ajax]]></category>
		<category><![CDATA[css]]></category>
		<category><![CDATA[flash]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[js]]></category>
		<category><![CDATA[server]]></category>
		<category><![CDATA[url]]></category>
		<category><![CDATA[web]]></category>
		<category><![CDATA[中国特色]]></category>
		<category><![CDATA[人]]></category>
		<category><![CDATA[图片]]></category>
		<category><![CDATA[方法]]></category>
		<category><![CDATA[更新]]></category>
		<category><![CDATA[浏览器]]></category>
		<category><![CDATA[组件]]></category>
		<category><![CDATA[网站]]></category>
		<category><![CDATA[表]]></category>
		<category><![CDATA[解决]]></category>
		<category><![CDATA[设计]]></category>
		<category><![CDATA[重定向]]></category>
		<category><![CDATA[页面]]></category>

		<guid isPermaLink="false">http://www.5bay.cn/?p=346</guid>
		<description><![CDATA[<a href="http://www.5bay.cn/server-building/gaoxingnengwangzhanjianshezhinandushubiji.html"><img align="left" hspace="5" width="150" height="150" src="http://www.5bay.cn/wp-content/plugins/thumbnail-for-excerpts/tfe_no_thumb.png" class="alignleft wp-post-image tfe" alt="" title="" /></a>规则1，减少HTTP请求 这是最重要的原则，如果14条规则里只能选一条，那就是它了。可以通过多种方法减少HTTP请求，例如合并图片，合并JS和CSS等等。这一点薄荷网有很多改进的余地，首先应该把现在的JS合并了。 规则2，使用内容发布网络 内容发布网络就是CDN了，但是CDN似乎挺贵的，目前还不适合薄荷网，不过可以考虑自己弄一个网通的静态资源服务器解决有中国特色的可恶的南北互通问题。 规则3，添加Expires头 这个没什么好说的，是个建网站的人都应该知道。目前薄荷网图片,css,js,flash过期时间设置了3年，可以说是永久了，：） Expires有个麻烦的地方是内容更新问题，Ruby on Rails这方面处理的非常棒，它是在文件名后面自动带了 资源文件的timestamp，完美解决。 规则4，压缩组件 这个也没什么好说的，配置一下web server的压缩功能，减少服务器带宽，加快响应，立杆见影。 规则5，将样式表放在顶部 这条有点新鲜，虽然平常都是这么做的，但是没有想过不这样做有什么麻烦。如果不这样，浏览器是不能做到边下载边显示，用户体验很糟糕。薄荷网现在有部分样式没放在顶部，回头检查测试一下看看。 规则6，将脚本放在底部 这条是第一次听说，有些震惊。原因在于浏览器下载执行脚本的时候，会阻塞其他资源的下载，这样导致整体响应时间变长。薄荷网的脚本几乎都是放在顶部的，回头测试比较下看看。 规则7，避免CSS表达式 CSS表达是简直像个Bug，可以弃用，寻求变通的解决方便，比如事件处理器等。 规则8，使用外部的JavaScript和CSS 相信大家大部分情形下都是使用外联的，但纯粹的处理而已，内联JS和CSS似乎更快，考虑到缓存和复用，大部分情况显然是外联更划算。因此，在一些情景，例如首页，还是可以使用内联的。 规则9，减少DNS查找 DNS耗费的时间是相当可观的，因此同一页面的域名数量最好控制在2~4之间。 规则10，精简JavaScript 精简JavaScript可以显著减少Js文件的大小，减少下载时间。 规则11，避免重定向 get的重定向可以通过web server的url rewrite很好解决。 规则12，移除重复脚本 重复的脚本既增加一次http请求，又要重复执行，当然坚决移除了。 规则13，配置ETag 目前web server的ETag实现不但起不到好的效果，通常还使性能变得更差，真是一个糟糕的设计。 所以静态资源尽量去除ETag配置。但是对于刷新频率不高的Rails动态页面，这个似乎是个不错的大幅 加快响应的方法，值得再深入好好研究一番。 规则14，使Ajax可缓存 就是使用之前的规则应用于Ajax请求，：） 相关博文2010年07月26日 -- 使用Ajax时的十个常犯的错误 (0)2010年05月23日 -- nginx的rewrite规则 (1)2010年07月26日 -- AJAX应用程序开发七宗罪 (0)2010年07月26日 -- AJAX的各种控件和类库 (0)2010年07月26日 -- ajax的缺点 (0)2010年07月26日 -- [...]]]></description>
			<content:encoded><![CDATA[<p><strong>规则1，减少HTTP请求</strong></p>
<p>这是最重要的原则，如果14条规则里只能选一条，那就是它了。可以通过多种方法减少HTTP请求，例如合并图片，合并JS和CSS等等。这一点薄荷网有很多改进的余地，首先应该把现在的JS合并了。</p>
<p><strong>规则2，使用内容发布网络</strong></p>
<p>内容发布网络就是CDN了，但是CDN似乎挺贵的，目前还不适合薄荷网，不过可以考虑自己弄一个网通的静态资源服务器解决有中国特色的可恶的南北互通问题。</p>
<p><strong>规则3，添加Expires头</strong></p>
<p>这个没什么好说的，是个建网站的人都应该知道。目前薄荷网图片,css,js,flash过期时间设置了3年，可以说是永久了，：） Expires有个麻烦的地方是内容更新问题，Ruby on Rails这方面处理的非常棒，它是在文件名后面自动带了</p>
<p>资源文件的timestamp，完美解决。<span id="more-346"></span></p>
<p><strong>规则4，压缩组件</strong></p>
<p>这个也没什么好说的，配置一下web server的压缩功能，减少服务器带宽，加快响应，立杆见影。</p>
<p><strong>规则5，将样式表放在顶部</strong></p>
<p>这条有点新鲜，虽然平常都是这么做的，但是没有想过不这样做有什么麻烦。如果不这样，浏览器是不能做到边下载边显示，用户体验很糟糕。薄荷网现在有部分样式没放在顶部，回头检查测试一下看看。</p>
<p><strong>规则6，将脚本放在底部</strong></p>
<p>这条是第一次听说，有些震惊。原因在于浏览器下载执行脚本的时候，会阻塞其他资源的下载，这样导致整体响应时间变长。薄荷网的脚本几乎都是放在顶部的，回头测试比较下看看。</p>
<p><strong>规则7，避免CSS表达式</strong></p>
<p>CSS表达是简直像个Bug，可以弃用，寻求变通的解决方便，比如事件处理器等。</p>
<p><strong>规则8，使用外部的JavaScript和CSS</strong></p>
<p>相信大家大部分情形下都是使用外联的，但纯粹的处理而已，内联JS和CSS似乎更快，考虑到缓存和复用，大部分情况显然是外联更划算。因此，在一些情景，例如首页，还是可以使用内联的。</p>
<p><strong>规则9，减少DNS查找</strong></p>
<p>DNS耗费的时间是相当可观的，因此同一页面的域名数量最好控制在2~4之间。</p>
<p><strong>规则10，精简JavaScript</strong></p>
<p>精简JavaScript可以显著减少Js文件的大小，减少下载时间。</p>
<p><strong>规则11，避免重定向</strong></p>
<p>get的重定向可以通过web server的url rewrite很好解决。</p>
<p><strong>规则12，移除重复脚本</strong></p>
<p>重复的脚本既增加一次http请求，又要重复执行，当然坚决移除了。</p>
<p><strong>规则13，配置ETag</strong></p>
<p>目前web server的ETag实现不但起不到好的效果，通常还使性能变得更差，真是一个糟糕的设计。</p>
<p>所以静态资源尽量去除ETag配置。但是对于刷新频率不高的Rails动态页面，这个似乎是个不错的大幅</p>
<p>加快响应的方法，值得再深入好好研究一番。</p>
<p><strong>规则14，使Ajax可缓存</strong></p>
<p>就是使用之前的规则应用于Ajax请求，：）</p>
<h2  class="related_post_title">相关博文</h2><ul class="related_post"><li>2010年07月26日 -- <a href="http://www.5bay.cn/network-programming/eejaxeeeeee.html" title="使用Ajax时的十个常犯的错误">使用Ajax时的十个常犯的错误</a> (0)</li><li>2010年05月23日 -- <a href="http://www.5bay.cn/server-building/nginxderewriteguize.html" title="nginx的rewrite规则">nginx的rewrite规则</a> (1)</li><li>2010年07月26日 -- <a href="http://www.5bay.cn/network-programming/ajaxeeaoe.html" title="AJAX应用程序开发七宗罪">AJAX应用程序开发七宗罪</a> (0)</li><li>2010年07月26日 -- <a href="http://www.5bay.cn/network-programming/ajax.html" title="AJAX的各种控件和类库">AJAX的各种控件和类库</a> (0)</li><li>2010年07月26日 -- <a href="http://www.5bay.cn/network-programming/ajaxxuan.html" title="ajax的缺点">ajax的缺点</a> (0)</li><li>2010年07月26日 -- <a href="http://www.5bay.cn/network-programming/eesoneeajaxeehuai.html" title="基于JSON的高级AJAX开发技术">基于JSON的高级AJAX开发技术</a> (0)</li><li>2010年07月26日 -- <a href="http://www.5bay.cn/network-programming/eeeeeeee.html" title="最令PHP初学者头痛的十四个问题">最令PHP初学者头痛的十四个问题</a> (0)</li><li>2010年07月26日 -- <a href="http://www.5bay.cn/network-programming/ajaxeeee.html" title="Ajax的工作原理">Ajax的工作原理</a> (1)</li><li>2010年07月26日 -- <a href="http://www.5bay.cn/network-programming/ajaxeeieeeeeting.html" title="AJAX初学:IE缓存页面的问题">AJAX初学:IE缓存页面的问题</a> (0)</li><li>2010年07月26日 -- <a href="http://www.5bay.cn/network-programming/xmlhttpe.html" title="XMLHTTP对象封装技术">XMLHTTP对象封装技术</a> (0)</li><li>2010年07月26日 -- <a href="http://www.5bay.cn/network-programming/phpeezhanchang.html" title="PHP安全之数据过滤">PHP安全之数据过滤</a> (0)</li><li>2010年05月23日 -- <a href="http://www.5bay.cn/server-building/rsyncxiangjie.html" title="Rsync详解">Rsync详解</a> (0)</li><li>2010年05月23日 -- <a href="http://www.5bay.cn/network-programming/phpfengzhuangchangyongjavascriptweijsleiyibiankuaisudiaoyong.html" title="PHP封装常用Javascript为JS类以便快速调用">PHP封装常用Javascript为JS类以便快速调用</a> (1)</li><li>2010年07月28日 -- <a href="http://www.5bay.cn/server-building/aspeaojie.html" title="ASP防注入新方式，希望对大家是有用的">ASP防注入新方式，希望对大家是有用的</a> (0)</li><li>2010年07月26日 -- <a href="http://www.5bay.cn/network-programming/phpeecketee.html" title="PHP和Socket简介">PHP和Socket简介</a> (0)</li></ul>
	标签Tags：<a href="http://www.5bay.cn/tag/ajax" title="ajax" rel="tag">ajax</a>, <a href="http://www.5bay.cn/tag/css" title="css" rel="tag">css</a>, <a href="http://www.5bay.cn/tag/flash" title="flash" rel="tag">flash</a>, <a href="http://www.5bay.cn/tag/javascript" title="javascript" rel="tag">javascript</a>, <a href="http://www.5bay.cn/tag/js" title="js" rel="tag">js</a>, <a href="http://www.5bay.cn/tag/server" title="server" rel="tag">server</a>, <a href="http://www.5bay.cn/tag/url" title="url" rel="tag">url</a>, <a href="http://www.5bay.cn/tag/web" title="web" rel="tag">web</a>, <a href="http://www.5bay.cn/tag/%E4%B8%AD%E5%9B%BD%E7%89%B9%E8%89%B2" title="中国特色" rel="tag">中国特色</a>, <a href="http://www.5bay.cn/tag/%E4%BA%BA" title="人" rel="tag">人</a>, <a href="http://www.5bay.cn/tag/%E5%9B%BE%E7%89%87" title="图片" rel="tag">图片</a>, <a href="http://www.5bay.cn/tag/%E6%96%B9%E6%B3%95" title="方法" rel="tag">方法</a>, <a href="http://www.5bay.cn/tag/%E6%9B%B4%E6%96%B0" title="更新" rel="tag">更新</a>, <a href="http://www.5bay.cn/category/server-building" title="服务器构建&amp;安全" rel="tag">服务器构建&amp;安全</a>, <a href="http://www.5bay.cn/tag/%E6%B5%8F%E8%A7%88%E5%99%A8" title="浏览器" rel="tag">浏览器</a>, <a href="http://www.5bay.cn/tag/%E7%BB%84%E4%BB%B6" title="组件" rel="tag">组件</a>, <a href="http://www.5bay.cn/tag/%E7%BD%91%E7%AB%99" title="网站" rel="tag">网站</a>, <a href="http://www.5bay.cn/tag/%E8%A1%A8" title="表" rel="tag">表</a>, <a href="http://www.5bay.cn/tag/%E8%A7%A3%E5%86%B3" title="解决" rel="tag">解决</a>, <a href="http://www.5bay.cn/tag/%E8%AE%BE%E8%AE%A1" title="设计" rel="tag">设计</a>, <a href="http://www.5bay.cn/tag/%E9%87%8D%E5%AE%9A%E5%90%91" title="重定向" rel="tag">重定向</a>, <a href="http://www.5bay.cn/tag/%E9%A1%B5%E9%9D%A2" title="页面" rel="tag">页面</a><br />
]]></content:encoded>
			<wfw:commentRss>http://www.5bay.cn/server-building/gaoxingnengwangzhanjianshezhinandushubiji.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>js表单输入判断</title>
		<link>http://www.5bay.cn/network-programming/javascript-ajax/js%E8%A1%A8%E5%8D%95%E8%BE%93%E5%85%A5%E5%88%A4%E6%96%AD.html</link>
		<comments>http://www.5bay.cn/network-programming/javascript-ajax/js%E8%A1%A8%E5%8D%95%E8%BE%93%E5%85%A5%E5%88%A4%E6%96%AD.html#comments</comments>
		<pubDate>Wed, 02 Jan 2008 20:01:43 +0000</pubDate>
		<dc:creator>江小邪</dc:creator>
				<category><![CDATA[JavaScript&Ajax]]></category>
		<category><![CDATA[js]]></category>
		<category><![CDATA[判断]]></category>
		<category><![CDATA[表单]]></category>

		<guid isPermaLink="false">?p=277</guid>
		<description><![CDATA[<a href="http://www.5bay.cn/network-programming/javascript-ajax/js%E8%A1%A8%E5%8D%95%E8%BE%93%E5%85%A5%E5%88%A4%E6%96%AD.html"><img align="left" hspace="5" width="150" height="150" src="http://www.5bay.cn/wp-content/plugins/thumbnail-for-excerpts/tfe_no_thumb.png" class="alignleft wp-post-image tfe" alt="" title="" /></a>//函数名：chksafe//功能介绍：检查是否含有&#34;&#039;&#34;,&#039;&#92;&#92;&#039;,&#34;/&#34;//参数说明：要检查的字符串//返回值：0：是 1：不是function chksafe(a){ return 1;/* fibdn = new Array (&#34;&#039;&#34; ,&#34;&#92;&#92;&#34;, &#34;、&#34;, &#34;,&#34;, &#34;;&#34;, &#34;/&#34;);i=fibdn.length;j=a.length;for (ii=0;ii&#60;i;ii++){ for (jj=0;jj&#60;j;jj++){ temp1=a.charAt(jj);temp2=fibdn[ii];if (temp1==temp2){ return 0; }}}return 1;*/ } //函数名：chkspc//功能介绍：检查是否含有空格//参数说明：要检查的字符串//返回值：0：是 1：不是function chkspc(a){var i=a.length;var j = 0;var k = 0;while (k&#60;i){if (a.charAt(k) != &#34; &#34;)j = j+1;k = k+1;}if (j==0){return 0;}if (i!=j){ return 2; }else{return 1;}}//函数名：chkemail//功能介绍：检查是否为Email Address//参数说明：要检查的字符串//返回值：0：不是 1：是 function chkemail(a){ [...]]]></description>
			<content:encoded><![CDATA[<p><span id="more-277"></span><br/>//函数名：chksafe<br/>//功能介绍：检查是否含有&quot;&#039;&quot;,&#039;&#92;&#92;&#039;,&quot;/&quot;<br/>//参数说明：要检查的字符串<br/>//返回值：0：是 1：不是<br/><br/>function chksafe(a)<br/>{ <br/>return 1;<br/>/* fibdn = new Array (&quot;&#039;&quot; ,&quot;&#92;&#92;&quot;, &quot;、&quot;, &quot;,&quot;, &quot;;&quot;, &quot;/&quot;);<br/>i=fibdn.length;<br/>j=a.length;<br/>for (ii=0;ii&lt;i;ii++)<br/>{ for (jj=0;jj&lt;j;jj++)<br/>{ temp1=a.charAt(jj);<br/>temp2=fibdn[ii];<br/>if (temp1==temp2)<br/>{ return 0; }<br/>}<br/>}<br/>return 1;<br/>*/ <br/>} <br/><br/>//函数名：chkspc<br/>//功能介绍：检查是否含有空格<br/>//参数说明：要检查的字符串<br/>//返回值：0：是 1：不是<br/><br/>function chkspc(a)<br/>{<br/>var i=a.length;<br/>var j = 0;<br/>var k = 0;<br/>while (k&lt;i)<br/>{<br/>if (a.charAt(k) != &quot; &quot;)<br/>j = j+1;<br/>k = k+1;<br/>}<br/>if (j==0)<br/>{<br/>return 0;<br/>}<br/><br/>if (i!=j)<br/>{ return 2; }<br/>else<br/>{<br/>return 1;<br/>}<br/>}<br/><br/>//函数名：chkemail<br/>//功能介绍：检查是否为Email Address<br/>//参数说明：要检查的字符串<br/>//返回值：0：不是 1：是 <br/><br/>function chkemail(a)<br/>{ var i=a.length;<br/>var temp = a.indexOf(&#039;@&#039;);<br/>var tempd = a.indexOf(&#039;.&#039;);<br/>if (temp &gt; 1) {<br/>if ((i-temp) &gt; 3){<br/><br/>if ((i-tempd)&gt;0){<br/>return 1;<br/>}<br/><br/>}<br/>}<br/>return 0;<br/>}//opt1 小数 opt2 负数<br/>//当opt2为1时检查num是否是负数<br/>//当opt1为1时检查num是否是小数<br/>//返回1是正确的，0是错误的<br/>function chknbr(num,opt1,opt2)<br/>{<br/>var i=num.length;<br/>var staus;<br/>//staus用于记录.的个数<br/>status=0;<br/>if ((opt2!=1) &amp;&amp; (num.charAt(0)==&#039;-&#039;))<br/>{<br/>//alert(&quot;You have enter a invalid number.&quot;);<br/>return 0;<br/><br/>}<br/>//当最后一位为.时出错<br/>if (num.charAt(i-1)==&#039;.&#039;)<br/>{<br/>//alert(&quot;You have enter a invalid number.&quot;);<br/>return 0;<br/>}<br/><br/>for (j=0;j&lt;i;j++)<br/>{<br/>if (num.charAt(j)==&#039;.&#039;)<br/>{<br/>status++;<br/>}<br/>if (status&gt;1) <br/>{<br/>//alert(&quot;You have enter a invalid number.&quot;);<br/>return 0; <br/>}<br/>if (num.charAt(j)&lt;&#039;0&#039; &#124;&#124; num.charAt(j)&gt;&#039;9&#039; )<br/>{<br/>if (((opt1==0) &#124;&#124; (num.charAt(j)!=&#039;.&#039;)) &amp;&amp; (j!=0)) <br/>{<br/>//alert(&quot;You have enter a invalid number.&quot;);<br/>return 0;<br/>}<br/>}<br/>}<br/>return 1;<br/>}<br/>//函数名：chkdate<br/>//功能介绍：检查是否为日期<br/>//参数说明：要检查的字符串<br/>//返回值：0：不是日期 1：是日期<br/><br/>function chkdate(datestr)<br/>{<br/>var lthdatestr<br/>if (datestr != &quot;&quot;)<br/>lthdatestr= datestr.length ;<br/>else<br/>lthdatestr=0;<br/><br/>var tmpy=&quot;&quot;;<br/>var tmpm=&quot;&quot;;<br/>var tmpd=&quot;&quot;;<br/>//var datestr;<br/>var status;<br/>status=0;<br/>if ( lthdatestr== 0)<br/>return 0<br/><br/>for (i=0;i&lt;lthdatestr;i++)<br/>{ if (datestr.charAt(i)== &#039;-&#039;)<br/>{<br/>status++;<br/>}<br/>if (status&gt;2)<br/>{<br/>//alert(&quot;Invalid format of date!&quot;);<br/>return 0;<br/>}<br/>if ((status==0) &amp;&amp; (datestr.charAt(i)!=&#039;-&#039;))<br/>{<br/>tmpy=tmpy+datestr.charAt(i)<br/>}<br/>if ((status==1) &amp;&amp; (datestr.charAt(i)!=&#039;-&#039;))<br/>{<br/>tmpm=tmpm+datestr.charAt(i)<br/>}<br/>if ((status==2) &amp;&amp; (datestr.charAt(i)!=&#039;-&#039;))<br/>{<br/>tmpd=tmpd+datestr.charAt(i)<br/>}<br/><br/>}<br/>year=new String (tmpy);<br/>month=new String (tmpm);<br/>day=new String (tmpd)<br/>//tempdate= new String (year+month+day);<br/>//alert(tempdate);<br/>if ((tmpy.length!=4) &#124;&#124; (tmpm.length&gt;2) &#124;&#124; (tmpd.length&gt;2))<br/>{<br/>//alert(&quot;Invalid format of date!&quot;);<br/>return 0;<br/>}<br/>if (!((1&lt;=month) &amp;&amp; (12&gt;=month) &amp;&amp; (31&gt;=day) &amp;&amp; (1&lt;=day)) )<br/>{<br/>//alert (&quot;Invalid month or day!&quot;);<br/>return 0;<br/>}<br/>if (!((year % 4)==0) &amp;&amp; (month==2) &amp;&amp; (day==29))<br/>{<br/>//alert (&quot;This is not a leap year!&quot;);<br/>return 0;<br/>}<br/>if ((month&lt;=7) &amp;&amp; ((month % 2)==0) &amp;&amp; (day&gt;=31))<br/>{<br/>//alert (&quot;This month is a small month!&quot;);<br/>return 0;<br/><br/>}<br/>if ((month&gt;=8) &amp;&amp; ((month % 2)==1) &amp;&amp; (day&gt;=31))<br/>{<br/>//alert (&quot;This month is a small month!&quot;);<br/>return 0;<br/>}<br/>if ((month==2) &amp;&amp; (day==30))<br/>{<br/>//alert(&quot;The Febryary never has this day!&quot;);<br/>return 0;<br/>}<br/><br/>return 1;<br/>}<br/>//函数名：fucPWDchk<br/>//功能介绍：检查是否含有非数字或字母<br/>//参数说明：要检查的字符串<br/>//返回值：0：含有 1：全部为数字或字母 <br/><br/>function fucPWDchk(str)<br/>{<br/>var strSource =&quot;0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ&quot;;<br/>var ch;<br/>var i;<br/>var temp;<br/><br/>for (i=0;i&lt;=(str.length-1);i++)<br/>{<br/><br/>ch = str.charAt(i);<br/>temp = strSource.indexOf(ch);<br/>if (temp==-1) <br/>{<br/>return 0;<br/>}<br/>}<br/>if (strSource.indexOf(ch)==-1)<br/>{<br/>return 0;<br/>}<br/>else<br/>{<br/>return 1;<br/>} <br/>}<br/><br/>function jtrim(str)<br/>{ while (str.charAt(0)==&quot; &quot;)<br/>{str=str.substr(1);} <br/>while (str.charAt(str.length-1)==&quot; &quot;)<br/>{str=str.substr(0,str.length-1);}<br/>return(str);<br/>}<br/><br/>//函数名：fucCheckNUM<br/>//功能介绍：检查是否为数字<br/>//参数说明：要检查的数字<br/>//返回值：1为是数字，0为不是数字<br/><br/>function fucCheckNUM(NUM)<br/>{<br/>var i,j,strTemp;<br/>strTemp=&quot;0123456789&quot;;<br/>if ( NUM.length== 0)<br/>return 0<br/>for (i=0;i&lt;NUM.length;i++)<br/>{<br/>j=strTemp.indexOf(NUM.charAt(i)); <br/>if (j==-1)<br/>{<br/>//说明有字符不是数字<br/>return 0;<br/>}<br/>}<br/>//说明是数字<br/>return 1;<br/>}<br/>//函数名：fucCheckTEL<br/>//功能介绍：检查是否为电话号码<br/>//参数说明：要检查的字符串<br/>//返回值：1为是合法，0为不合法<br/><br/>function fucCheckTEL(TEL)<br/>{<br/>var i,j,strTemp;<br/>strTemp=&quot;0123456789-()# &quot;;<br/>for (i=0;i&lt;TEL.length;i++)<br/>{<br/>j=strTemp.indexOf(TEL.charAt(i)); <br/>if (j==-1)<br/>{<br/>//说明有字符不合法<br/>return 0;<br/>}<br/>}<br/>//说明合法<br/>return 1;<br/>}<br/>//函数名：fucCheckLength<br/>//功能介绍：检查字符串的长度<br/>//参数说明：要检查的字符串<br/>//返回值：长度值<br/><br/>function fucCheckLength(strTemp)<br/>{<br/>var i,sum;<br/>sum=0;<br/>for(i=0;i&lt;strTemp.length;i++)<br/>{<br/>if ((strTemp.charCodeAt(i)&gt;=0) &amp;&amp; (strTemp.charCodeAt(i)&lt;=255))<br/>sum=sum+1;<br/>else<br/>sum=sum+2;<br/>}<br/>return sum;<br/>}</p>
<h2  class="related_post_title">相关博文</h2><ul class="related_post"><li>2010年07月26日 -- <a href="http://www.5bay.cn/network-programming/phpeeeeeeeehuai.html" title="PHP对文本数据库的基本操作方法">PHP对文本数据库的基本操作方法</a> (0)</li><li>2010年07月26日 -- <a href="http://www.5bay.cn/network-programming/xmlhttpe.html" title="XMLHTTP对象封装技术">XMLHTTP对象封装技术</a> (0)</li><li>2010年07月26日 -- <a href="http://www.5bay.cn/network-programming/phpeezhanchang.html" title="PHP安全之数据过滤">PHP安全之数据过滤</a> (0)</li><li>2010年05月23日 -- <a href="http://www.5bay.cn/network-programming/phpfengzhuangchangyongjavascriptweijsleiyibiankuaisudiaoyong.html" title="PHP封装常用Javascript为JS类以便快速调用">PHP封装常用Javascript为JS类以便快速调用</a> (1)</li><li>2010年05月23日 -- <a href="http://www.5bay.cn/server-building/nginxderewriteguize.html" title="nginx的rewrite规则">nginx的rewrite规则</a> (1)</li><li>2010年07月28日 -- <a href="http://www.5bay.cn/server-building/aspeaojie.html" title="ASP防注入新方式，希望对大家是有用的">ASP防注入新方式，希望对大家是有用的</a> (0)</li><li>2010年07月26日 -- <a href="http://www.5bay.cn/network-programming/ajax.html" title="AJAX的各种控件和类库">AJAX的各种控件和类库</a> (0)</li><li>2010年07月26日 -- <a href="http://www.5bay.cn/network-programming/innerhtmleenertexteeterhtmlqia.html" title="innerHTML、innerText和outerHTML的用法">innerHTML、innerText和outerHTML的用法</a> (0)</li><li>2010年07月26日 -- <a href="http://www.5bay.cn/network-programming/ajaxeeeeseeao.html" title="ajax基础知识:js事件触发大全">ajax基础知识:js事件触发大全</a> (0)</li><li>2010年07月26日 -- <a href="http://www.5bay.cn/network-programming/ajaxxuan.html" title="ajax的缺点">ajax的缺点</a> (0)</li><li>2010年07月26日 -- <a href="http://www.5bay.cn/network-programming/eesoneeajaxeehuai.html" title="基于JSON的高级AJAX开发技术">基于JSON的高级AJAX开发技术</a> (0)</li><li>2010年05月23日 -- <a href="http://www.5bay.cn/server-building/rsyncxiangjie.html" title="Rsync详解">Rsync详解</a> (0)</li><li>2010年05月23日 -- <a href="http://www.5bay.cn/network-programming/jsshixianquanjingtuxiaoguo360duxuanzhuan.html" title="JS实现全景图效果360度旋转">JS实现全景图效果360度旋转</a> (1)</li><li>2010年05月23日 -- <a href="http://www.5bay.cn/website/nginxtongguouser-agentpanduanshoujizhongduan.html" title="nginx 通过user-agent判断手机终端">nginx 通过user-agent判断手机终端</a> (0)</li><li>2010年05月23日 -- <a href="http://www.5bay.cn/server-building/gaoxingnengwangzhanjianshezhinandushubiji.html" title="《高性能网站建设指南》读书笔记">《高性能网站建设指南》读书笔记</a> (0)</li></ul>
	标签Tags：<a href="http://www.5bay.cn/category/network-programming/javascript-ajax" title="JavaScript&amp;Ajax" rel="tag">JavaScript&amp;Ajax</a>, <a href="http://www.5bay.cn/tag/js" title="js" rel="tag">js</a>, <a href="http://www.5bay.cn/tag/%E5%88%A4%E6%96%AD" title="判断" rel="tag">判断</a>, <a href="http://www.5bay.cn/tag/%E8%A1%A8%E5%8D%95" title="表单" rel="tag">表单</a><br />
]]></content:encoded>
			<wfw:commentRss>http://www.5bay.cn/network-programming/javascript-ajax/js%E8%A1%A8%E5%8D%95%E8%BE%93%E5%85%A5%E5%88%A4%E6%96%AD.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>JS扩展函数集合</title>
		<link>http://www.5bay.cn/network-programming/javascript-ajax/js%E6%89%A9%E5%B1%95%E5%87%BD%E6%95%B0%E9%9B%86%E5%90%88.html</link>
		<comments>http://www.5bay.cn/network-programming/javascript-ajax/js%E6%89%A9%E5%B1%95%E5%87%BD%E6%95%B0%E9%9B%86%E5%90%88.html#comments</comments>
		<pubDate>Fri, 17 Aug 2007 02:52:41 +0000</pubDate>
		<dc:creator>江小邪</dc:creator>
				<category><![CDATA[JavaScript&Ajax]]></category>
		<category><![CDATA[js]]></category>
		<category><![CDATA[扩展函数]]></category>
		<category><![CDATA[集合]]></category>

		<guid isPermaLink="false">?p=265</guid>
		<description><![CDATA[<a href="http://www.5bay.cn/network-programming/javascript-ajax/js%E6%89%A9%E5%B1%95%E5%87%BD%E6%95%B0%E9%9B%86%E5%90%88.html"><img align="left" hspace="5" width="150" height="150" src="http://www.5bay.cn/wp-content/plugins/thumbnail-for-excerpts/tfe_no_thumb.png" class="alignleft wp-post-image tfe" alt="" title="" /></a>&#91;runcode&#93; 相关博文2010年07月28日 -- ASP防注入新方式，希望对大家是有用的 (0)2010年07月26日 -- 深入探讨PHP中的内存管理问题 (0)2010年07月26日 -- AJAX的各种控件和类库 (0)2010年07月26日 -- innerHTML、innerText和outerHTML的用法 (0)2010年07月26日 -- XMLHTTP对象封装技术 (0)2010年07月26日 -- ajax基础知识:js事件触发大全 (0)2010年07月26日 -- ajax的缺点 (0)2010年07月26日 -- 基于JSON的高级AJAX开发技术 (0)2010年05月23日 -- PHP封装常用Javascript为JS类以便快速调用 (1)2010年05月23日 -- JS实现全景图效果360度旋转 (1)2010年05月23日 -- nginx的rewrite规则 (1)2010年05月23日 -- 《高性能网站建设指南》读书笔记 (0)2008年01月2日 -- js表单输入判断 (0)2007年08月17日 -- js取得网页中的选中文字 (0)2007年08月16日 -- google个性主页的拖拽效果的js的完整注释 (0) 标签Tags：JavaScript&#38;Ajax, js, 扩展函数, 集合]]></description>
			<content:encoded><![CDATA[<p><span id="more-265"></span><br/><coolcode>&#91;runcode&#93;<script language="javascript"></p>
<p>// 合并多个空白为一个空白<br />String.prototype.resetBlank = function()<br />{<br />var regEx = /&#92;s+/g;<br />return this.replace(regEx,&#039; &#039;); <br />}</p>
<p>// 除去左边空白<br />String.prototype.Ltrim = function()<br />{<br />var regEx = /^&#92;s+/g;<br />return this.replace(regEx,&#039;&#039;); <br />} </p>
<p>// 除去右边空白<br />String.prototype.Rtrim = function()<br />{<br />var regEx = /&#92;s+$/g;<br />return this.replace(regEx,&#039;&#039;); <br />}</p>
<p>// 除去两边空白<br />String.prototype.Trim = function()<br />{<br />var regEx = /(^&#92;s+)&#124;(&#92;s+$)/g;<br />return this.replace(regEx,&#039;&#039;); <br />}</p>
<p>// 除去所有空白<br />String.prototype.Trim = function()<br />{<br />var regEx = /&#92;s*/g;<br />return this.replace(regEx,&#039;&#039;); <br />} </p>
<p>// 保留数字<br />String.prototype.GetNum = function()<br />{<br />var regEx = /&#91;^&#92;d&#93;/g;<br />return this.replace(regEx,&#039;&#039;); <br />}</p>
<p>// 保留字母<br />String.prototype.GetEn = function()<br />{<br />var regEx = /&#91;^A-Za-z&#93;/g;<br />return this.replace(regEx,&#039;&#039;); <br />}</p>
<p>// 保留大写字母<br />String.prototype.GetUcase = function()<br />{<br />var regEx = /&#91;^A-Z&#93;/g;<br />return this.replace(regEx,&#039;&#039;); <br />}</p>
<p>// 保留小写字母<br />String.prototype.GetLcase = function()<br />{<br />var regEx = /&#91;^a-z&#93;/g;<br />return this.replace(regEx,&#039;&#039;); <br />}</p>
<p>// 保留中文<br />String.prototype.GetCn = function()<br />{<br />var regEx = /&#91;^&#92;u4e00-&#92;u9fa5&#92;uf900-&#92;ufa2d&#93;/g;<br />return this.replace(regEx,&#039;&#039;); <br />}</p>
<p>// 得到子节长度<br />String.prototype.GetRealLength = function()<br />{ <br />var regEx = /^&#91;&#92;u4e00-&#92;u9fa5&#92;uf900-&#92;ufa2d&#93;+$/;<br />if (regEx.test(this))<br />{ <br />return this.length * 2;<br />} else {<br />var oMatches = this.match(/&#91;&#92;x00-&#92;xff&#93;/g);<br />var oLength = this.length * 2 - oMatches.length;<br />return oLength;<br />} <br />}</p>
<p>// 左边截取字符串<br />String.prototype.Left = function(oLength)<br />{<br />return this.slice(0,oLength); <br />}</p>
<p>// 右边截取字符串<br />String.prototype.Right = function(oLength)<br />{<br />if (this.length<oLength)<br />{<br />return this;<br />} else {<br />return this.slice(this.length-oLength);<br />} <br />}</p>
<p>// 获取文件全名<br />String.prototype.GetFileName = function() <br />{<br />var regEx = /^.*&#92;/(&#91;^&#92;/&#92;?&#93;*).*$/;<br />return this.replace(regEx,&#039;$1&#039;);<br />}</p>
<p>// 获取文件扩展名<br />String.prototype.GetExtensionName = function() <br />{<br />var regEx = /^.*&#92;/&#91;^&#92;/&#93;*(&#92;.&#91;^&#92;.&#92;?&#93;*).*$/;<br />return this.replace(regEx,&#039;$1&#039;);<br />} </p>
<p>// 获取文本内容<br />String.prototype.GetInnerText = function() <br />{<br />var regEx = /<&#92;/?&#91;^>&#93;*>/g;<br />return this.replace(regEx,&#039;&#039;);<br />}</p>
<p>// 监测是否为空 <br />String.prototype.isEmail = function()<br />{<br />return (this==&#039;&#039;); <br />}</p>
<p>// 监测是否相等 <br />String.prototype.isEquals = function(oString)<br />{<br />return (this==oString); <br />}</p>
<p>// 监测邮箱格式 <br />String.prototype.isEmail = function()<br />{<br />var regEx = </p>
<p>/^&#92;w+((-&#92;w+)&#124;(&#92;.&#92;w+))*&#92;@&#91;A-Za-z0-9&#93;+((&#92;.&#124;-)&#91;A-Za-z0-9&#93;+)*&#92;.&#91;A-Za-z0-9&#93;+$/;<br />return regEx.test(this); <br />}</p>
<p>// String转化为Number<br />String.prototype.Int = function()<br />{<br />return isNaN(parseInt(this)) ? this.toString() : parseInt(this);<br />}</p>
<p>// HTML编码<br />String.prototype.HTMLEncode = function()<br />{<br />var objThis = this;<br />var oRegExp = new Array(/&#92;x26/g,/&#92;x3c/g,/&#92;x3e/g,/&#92;x3e/g,/&#92;x27/g);<br />var oTarget = new Array(&#039;&#038;&#039;,&#039;<&#039;,&#039;>&#039;,&#039;"&#039;,&#039;&#039;&#039;);<br />for (var i=0; i<5; i++)<br />{<br />objThis = objThis.replace(oRegExp&#91;i&#93;, oTarget&#91;i&#93;);<br />}<br />return objThis;<br />}</p>
<p>// 字符串格式化<br />String.prototype.encodeStr = function()<br />{<br />var objThis = this;<br />objThis = objThis.HTMLEncode();<br />objThis = objThis.replace(/&#92;n/g, &#039;<br />&#039;);<br />objThis = objThis.replace(/&#92;t/g, &#039; &#039;);<br />objThis = objThis.replace(/&#92;s/g, &#039; &#039;);<br />return objThis; <br />}</p>
<p>// Unicode转化<br />String.prototype.AscW = function()<br />{<br />var strText = &#039;&#039;;<br />for (var i=0; i
<this.length; i++)<br />{<br />strText += &#039;&#&#039; + this.charCodeAt(i);<br />}<br />return strText;<br />}</p>
<p>// 数字补零<br />Number.prototype.LengthWithZero = function(oCount)<br />{ <br />var strText = this.toString();<br />while (strText.length<oCount)<br />{<br />strText = &#039;0&#039; + strText; <br />}<br />return strText;<br />}</p>
<p>// Unicode还原<br />Number.prototype.ChrW = function()<br />{<br />return String.fromCharCode(this); <br />}</p>
<p>// 数字数组由小到大排序<br />Array.prototype.Min2Max = function()<br />{ <br />var oValue;<br />for (var i=0; i
<this.length; i++)<br />{<br />for (var j=0; j<=i; j++)<br />{<br />if (this&#91;i&#93;
<this&#91;j&#93;)<br />{<br />oValue = this&#91;i&#93;;<br />this&#91;i&#93; = this&#91;j&#93;;<br />this&#91;j&#93; = oValue;<br />}<br />} <br />}<br />return this;<br />}</p>
<p>// 数字数组由大到小排序<br />Array.prototype.Max2Min = function()<br />{<br />var oValue;<br />for (var i=0; i
<this.length; i++)<br />{<br />for (var j=0; j<=i; j++)<br />{<br />if (this&#91;i&#93;>this&#91;j&#93;)<br />{<br />oValue = this&#91;i&#93;;<br />this&#91;i&#93; = this&#91;j&#93;;<br />this&#91;j&#93; = oValue;<br />}<br />} <br />}<br />return this;<br />}</p>
<p>// 获得数组值<br />Array.prototype.Item = function(oIndex)<br />{<br />return this&#91;oIndex&#93;; <br />}</p>
<p>// 删除数组指定项<br />Array.prototype.removeItem = function(oIndex)<br />{<br />this.splice(oIndex,1); <br />}</p>
<p>// 正向查找<br />Array.prototype.InStr = function(oTarget)<br />{<br />for (var i=0; i
<this.length; i++)<br />{<br />if (this&#91;i&#93;=oTarget &#038;&#038; typeof(this&#91;i&#93;)==typeof(oTarget))<br />{<br />return i;<br />}<br />}<br />return -1; <br />}</p>
<p>// 反向查找<br />Array.prototype.LastInStr = function(oTarget)<br />{<br />for (var i=this.length-1; i>=0; i--)<br />{<br />if (this&#91;i&#93;=oTarget &#038;&#038; typeof(this&#91;i&#93;)==typeof(oTarget))<br />{<br />return i;<br />}<br />}<br />return -1;<br />}</p>
<p>// 判断是否存在<br />Array.prototype.InStrBolean = function(oTarget)<br />{<br />for (var i=0; i
<this.length; i++)<br />{<br />if (this&#91;i&#93;.oTarget &#038;&#038; typeof(this&#91;i&#93;)==typeof(oTarget))<br />{<br />return true;<br />}<br />}<br />return false;<br />}</p>
<p>// 获得数字数组中最大项<br />Array.prototype.GetMax = function()<br />{<br />var oValue = 0;<br />for(var i=0; i
<this.length; i++)<br />{<br />if (this&#91;i&#93;>oValue)<br />{<br />oValue = this&#91;i&#93;;<br />} <br />}<br />return oValue;<br />}</p>
<p>// 获得数字数组中最小项<br />Array.prototype.GetMin = function()<br />{<br />var oValue = 0;<br />for(var i=0; i
<this.length; i++)<br />{<br />if (this&#91;i&#93;<oValue)<br />{<br />oValue = this&#91;i&#93;;<br />} <br />}<br />return oValue;<br />}</p>
<p>// 获取当前时间的GB形式<br />Date.prototype.GetCNDate = function()<br />{<br />var oDateText = &#039;&#039;;<br />oDateText += this.getFullYear().LengthWithZero(4) + new Number(24180).ChrW();<br />oDateText += this.getMonth().LengthWithZero(2) + new Number(26376).ChrW();<br />oDateText += this.getDate().LengthWithZero(2) + new Number(26085).ChrW();<br />oDateText += this.getHours().LengthWithZero(2) + new Number(26102).ChrW();<br />oDateText += this.getMinutes().LengthWithZero(2) + new Number(20998).ChrW();<br />oDateText += this.getSeconds().LengthWithZero(2) + new Number(31186).ChrW();<br />oDateText += new Number(32).ChrW() + new Number(32).ChrW() + new Number(26143).ChrW() </p>
<p>+ new Number(26399).ChrW() + new </p>
<p>String(&#039;26085199682010819977222352011620845&#039;).substr(this.getDay()*5,5).Int().ChrW();<br />return oDateText; <br />}</p>
<p>// 得到对象的绝对坐标<br />function GetPosition(obj)<br />{<br />var objThis = obj;<br />var oBody = document.body;<br />var oLeft = oTop = 0;<br />while (objThis!=oBody)<br />{<br />oLeft += objThis.offsetLeft;<br />oTop += objThis.offsetTop;<br />objThis = objThis.offsetParent;<br />}<br />return { left: oLeft, top: oTop }; <br />}</p>
<p>// 取一定范围的随机数<br />function GetRndNum(lLimit, uLimit)<br />{<br />var oRndNum = Math.floor((uLimit-lLimit+1)*Math.random()+lLimit);<br />return oRndNum;<br />}</p>
<p>// 获取指定位数的随机密码<br />function GetRndPwd(oLength)<br />{<br />var oRndPwd = &#039;&#039;;<br />var oTempNum;<br />var oArray = new </p>
<p>Array(&#039;0&#039;,&#039;1&#039;,&#039;2&#039;,&#039;3&#039;,&#039;4&#039;,&#039;5&#039;,&#039;6&#039;,&#039;7&#039;,&#039;8&#039;,&#039;9&#039;,&#039;a&#039;,&#039;b&#039;,&#039;c&#039;,&#039;d&#039;,&#039;e&#039;,&#039;f&#039;,&#039;g&#039;,&#039;h&#039;,&#039;i&#039;,&#039;j&#039;,&#039;k&#039;,&#039;l</p>
<p>&#039;,&#039;m&#039;,&#039;n&#039;,&#039;o&#039;,&#039;p&#039;,&#039;q&#039;,&#039;r&#039;,&#039;s&#039;,&#039;t&#039;,&#039;u&#039;,&#039;v&#039;,&#039;w&#039;,&#039;x&#039;,&#039;y&#039;,&#039;z&#039;,&#039;A&#039;,&#039;B&#039;,&#039;C&#039;,&#039;D&#039;,&#039;E&#039;,&#039;F&#039;,&#039;G&#039;,&#039;H&#039;,&#039;I</p>
<p>&#039;,&#039;J&#039;,&#039;K&#039;,&#039;L&#039;,&#039;M&#039;,&#039;N&#039;,&#039;O&#039;,&#039;P&#039;,&#039;Q&#039;,&#039;R&#039;,&#039;S&#039;,&#039;T&#039;,&#039;U&#039;,&#039;V&#039;,&#039;W&#039;,&#039;X&#039;,&#039;Y&#039;,&#039;Z&#039;);<br />while (oRndPwd.length<oLength)<br />{<br />oTempNum = GetRndNum(0,61);<br />oRndPwd += oArray&#91;oTempNum&#93;.toString();<br />} <br />return oRndPwd; <br />}</p>
<p>// 定义圆类<br />function Circle(xPoint, yPoint, oRadius)<br />{<br />this.X = xPoint;<br />this.Y = yPoint;<br />this.R = oRadius;<br />this.PI = Math.PI; <br />this.circleArea = function()<br />{<br />return this.PI * this.R * this.R;<br />} <br />this.circleLength = function()<br />{<br />return 2 * this.PI * this.R;<br />}<br />}</p>
<p></script></coolcode></p>
<h2  class="related_post_title">相关博文</h2><ul class="related_post"><li>2010年07月28日 -- <a href="http://www.5bay.cn/server-building/aspeaojie.html" title="ASP防注入新方式，希望对大家是有用的">ASP防注入新方式，希望对大家是有用的</a> (0)</li><li>2010年07月26日 -- <a href="http://www.5bay.cn/network-programming/peeeeee.html" title="深入探讨PHP中的内存管理问题">深入探讨PHP中的内存管理问题</a> (0)</li><li>2010年07月26日 -- <a href="http://www.5bay.cn/network-programming/ajax.html" title="AJAX的各种控件和类库">AJAX的各种控件和类库</a> (0)</li><li>2010年07月26日 -- <a href="http://www.5bay.cn/network-programming/innerhtmleenertexteeterhtmlqia.html" title="innerHTML、innerText和outerHTML的用法">innerHTML、innerText和outerHTML的用法</a> (0)</li><li>2010年07月26日 -- <a href="http://www.5bay.cn/network-programming/xmlhttpe.html" title="XMLHTTP对象封装技术">XMLHTTP对象封装技术</a> (0)</li><li>2010年07月26日 -- <a href="http://www.5bay.cn/network-programming/ajaxeeeeseeao.html" title="ajax基础知识:js事件触发大全">ajax基础知识:js事件触发大全</a> (0)</li><li>2010年07月26日 -- <a href="http://www.5bay.cn/network-programming/ajaxxuan.html" title="ajax的缺点">ajax的缺点</a> (0)</li><li>2010年07月26日 -- <a href="http://www.5bay.cn/network-programming/eesoneeajaxeehuai.html" title="基于JSON的高级AJAX开发技术">基于JSON的高级AJAX开发技术</a> (0)</li><li>2010年05月23日 -- <a href="http://www.5bay.cn/network-programming/phpfengzhuangchangyongjavascriptweijsleiyibiankuaisudiaoyong.html" title="PHP封装常用Javascript为JS类以便快速调用">PHP封装常用Javascript为JS类以便快速调用</a> (1)</li><li>2010年05月23日 -- <a href="http://www.5bay.cn/network-programming/jsshixianquanjingtuxiaoguo360duxuanzhuan.html" title="JS实现全景图效果360度旋转">JS实现全景图效果360度旋转</a> (1)</li><li>2010年05月23日 -- <a href="http://www.5bay.cn/server-building/nginxderewriteguize.html" title="nginx的rewrite规则">nginx的rewrite规则</a> (1)</li><li>2010年05月23日 -- <a href="http://www.5bay.cn/server-building/gaoxingnengwangzhanjianshezhinandushubiji.html" title="《高性能网站建设指南》读书笔记">《高性能网站建设指南》读书笔记</a> (0)</li><li>2008年01月2日 -- <a href="http://www.5bay.cn/network-programming/javascript-ajax/js%E8%A1%A8%E5%8D%95%E8%BE%93%E5%85%A5%E5%88%A4%E6%96%AD.html" title="js表单输入判断">js表单输入判断</a> (0)</li><li>2007年08月17日 -- <a href="http://www.5bay.cn/network-programming/javascript-ajax/js%E5%8F%96%E5%BE%97%E7%BD%91%E9%A1%B5%E4%B8%AD%E7%9A%84%E9%80%89%E4%B8%AD%E6%96%87%E5%AD%97.html" title="js取得网页中的选中文字">js取得网页中的选中文字</a> (0)</li><li>2007年08月16日 -- <a href="http://www.5bay.cn/network-programming/javascript-ajax/google%E4%B8%AA%E6%80%A7%E4%B8%BB%E9%A1%B5%E7%9A%84%E6%8B%96%E6%8B%BD%E6%95%88%E6%9E%9C%E7%9A%84js%E7%9A%84%E5%AE%8C%E6%95%B4%E6%B3%A8%E9%87%8A.html" title="google个性主页的拖拽效果的js的完整注释">google个性主页的拖拽效果的js的完整注释</a> (0)</li></ul>
	标签Tags：<a href="http://www.5bay.cn/category/network-programming/javascript-ajax" title="JavaScript&amp;Ajax" rel="tag">JavaScript&amp;Ajax</a>, <a href="http://www.5bay.cn/tag/js" title="js" rel="tag">js</a>, <a href="http://www.5bay.cn/tag/%E6%89%A9%E5%B1%95%E5%87%BD%E6%95%B0" title="扩展函数" rel="tag">扩展函数</a>, <a href="http://www.5bay.cn/tag/%E9%9B%86%E5%90%88" title="集合" rel="tag">集合</a><br />
]]></content:encoded>
			<wfw:commentRss>http://www.5bay.cn/network-programming/javascript-ajax/js%E6%89%A9%E5%B1%95%E5%87%BD%E6%95%B0%E9%9B%86%E5%90%88.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>js取得网页中的选中文字</title>
		<link>http://www.5bay.cn/network-programming/javascript-ajax/js%E5%8F%96%E5%BE%97%E7%BD%91%E9%A1%B5%E4%B8%AD%E7%9A%84%E9%80%89%E4%B8%AD%E6%96%87%E5%AD%97.html</link>
		<comments>http://www.5bay.cn/network-programming/javascript-ajax/js%E5%8F%96%E5%BE%97%E7%BD%91%E9%A1%B5%E4%B8%AD%E7%9A%84%E9%80%89%E4%B8%AD%E6%96%87%E5%AD%97.html#comments</comments>
		<pubDate>Fri, 17 Aug 2007 02:31:41 +0000</pubDate>
		<dc:creator>江小邪</dc:creator>
				<category><![CDATA[JavaScript&Ajax]]></category>
		<category><![CDATA[js]]></category>
		<category><![CDATA[选中文字]]></category>

		<guid isPermaLink="false">?p=263</guid>
		<description><![CDATA[<a href="http://www.5bay.cn/network-programming/javascript-ajax/js%E5%8F%96%E5%BE%97%E7%BD%91%E9%A1%B5%E4%B8%AD%E7%9A%84%E9%80%89%E4%B8%AD%E6%96%87%E5%AD%97.html"><img align="left" hspace="5" width="150" height="150" src="http://www.5bay.cn/wp-content/plugins/thumbnail-for-excerpts/tfe_no_thumb.png" class="alignleft wp-post-image tfe" alt="" title="" /></a>New Document sadkfasldjfksahufksdahkjfdshakjfhsjkl 这种方法在FireFox和IE下全有效的 相关博文2010年07月28日 -- ASP防注入新方式，希望对大家是有用的 (0)2010年07月26日 -- AJAX的各种控件和类库 (0)2010年07月26日 -- innerHTML、innerText和outerHTML的用法 (0)2010年07月26日 -- XMLHTTP对象封装技术 (0)2010年07月26日 -- ajax基础知识:js事件触发大全 (0)2010年07月26日 -- ajax的缺点 (0)2010年07月26日 -- 基于JSON的高级AJAX开发技术 (0)2010年05月23日 -- PHP封装常用Javascript为JS类以便快速调用 (1)2010年05月23日 -- JS实现全景图效果360度旋转 (1)2010年05月23日 -- nginx的rewrite规则 (1)2010年05月23日 -- 《高性能网站建设指南》读书笔记 (0)2008年01月2日 -- js表单输入判断 (0)2007年08月17日 -- JS扩展函数集合 (0)2007年08月16日 -- google个性主页的拖拽效果的js的完整注释 (0)2007年08月16日 -- 得到对象以及鼠标在页面的绝对位置 (0) 标签Tags：JavaScript&#38;Ajax, js, 选中文字]]></description>
			<content:encoded><![CDATA[<p><span id="more-263"></span><br/><coolcode><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"><br /><HTML><br /><HEAD><br /><TITLE> New Document </TITLE><br /><META NAME="Generator" CONTENT="EditPlus"><br /><META NAME="Author" CONTENT=""><br /><META NAME="Keywords" CONTENT=""><br /><META NAME="Description" CONTENT=""><br /><SCRIPT LANGUAGE="JavaScript"><br /><!--<br />function Test()<br />{<br />    try{<br />        var selecter=window.getSelection();<br />        alert(selecter);<br />    }catch(err){<br />        var selecter=document.selection.createRange()<br />        alert(selecter.text)<br />    }<br />}<br />//&#8211;><br /></SCRIPT><br /></HEAD></p>
<p><BODY><br />sadkfasldjfksahufksdahkjfdshakjfhsjkl<br /><INPUT TYPE="button" NAME="button" value="alertSelect" onclick="Test()"><br /></form>
<p></BODY><br /></HTML></p>
<p>这种方法在FireFox和IE下全有效的</coolcode></p>
<h2  class="related_post_title">相关博文</h2><ul class="related_post"><li>2010年07月28日 -- <a href="http://www.5bay.cn/server-building/aspeaojie.html" title="ASP防注入新方式，希望对大家是有用的">ASP防注入新方式，希望对大家是有用的</a> (0)</li><li>2010年07月26日 -- <a href="http://www.5bay.cn/network-programming/ajax.html" title="AJAX的各种控件和类库">AJAX的各种控件和类库</a> (0)</li><li>2010年07月26日 -- <a href="http://www.5bay.cn/network-programming/innerhtmleenertexteeterhtmlqia.html" title="innerHTML、innerText和outerHTML的用法">innerHTML、innerText和outerHTML的用法</a> (0)</li><li>2010年07月26日 -- <a href="http://www.5bay.cn/network-programming/xmlhttpe.html" title="XMLHTTP对象封装技术">XMLHTTP对象封装技术</a> (0)</li><li>2010年07月26日 -- <a href="http://www.5bay.cn/network-programming/ajaxeeeeseeao.html" title="ajax基础知识:js事件触发大全">ajax基础知识:js事件触发大全</a> (0)</li><li>2010年07月26日 -- <a href="http://www.5bay.cn/network-programming/ajaxxuan.html" title="ajax的缺点">ajax的缺点</a> (0)</li><li>2010年07月26日 -- <a href="http://www.5bay.cn/network-programming/eesoneeajaxeehuai.html" title="基于JSON的高级AJAX开发技术">基于JSON的高级AJAX开发技术</a> (0)</li><li>2010年05月23日 -- <a href="http://www.5bay.cn/network-programming/phpfengzhuangchangyongjavascriptweijsleiyibiankuaisudiaoyong.html" title="PHP封装常用Javascript为JS类以便快速调用">PHP封装常用Javascript为JS类以便快速调用</a> (1)</li><li>2010年05月23日 -- <a href="http://www.5bay.cn/network-programming/jsshixianquanjingtuxiaoguo360duxuanzhuan.html" title="JS实现全景图效果360度旋转">JS实现全景图效果360度旋转</a> (1)</li><li>2010年05月23日 -- <a href="http://www.5bay.cn/server-building/nginxderewriteguize.html" title="nginx的rewrite规则">nginx的rewrite规则</a> (1)</li><li>2010年05月23日 -- <a href="http://www.5bay.cn/server-building/gaoxingnengwangzhanjianshezhinandushubiji.html" title="《高性能网站建设指南》读书笔记">《高性能网站建设指南》读书笔记</a> (0)</li><li>2008年01月2日 -- <a href="http://www.5bay.cn/network-programming/javascript-ajax/js%E8%A1%A8%E5%8D%95%E8%BE%93%E5%85%A5%E5%88%A4%E6%96%AD.html" title="js表单输入判断">js表单输入判断</a> (0)</li><li>2007年08月17日 -- <a href="http://www.5bay.cn/network-programming/javascript-ajax/js%E6%89%A9%E5%B1%95%E5%87%BD%E6%95%B0%E9%9B%86%E5%90%88.html" title="JS扩展函数集合">JS扩展函数集合</a> (0)</li><li>2007年08月16日 -- <a href="http://www.5bay.cn/network-programming/javascript-ajax/google%E4%B8%AA%E6%80%A7%E4%B8%BB%E9%A1%B5%E7%9A%84%E6%8B%96%E6%8B%BD%E6%95%88%E6%9E%9C%E7%9A%84js%E7%9A%84%E5%AE%8C%E6%95%B4%E6%B3%A8%E9%87%8A.html" title="google个性主页的拖拽效果的js的完整注释">google个性主页的拖拽效果的js的完整注释</a> (0)</li><li>2007年08月16日 -- <a href="http://www.5bay.cn/network-programming/javascript-ajax/%E5%BE%97%E5%88%B0%E5%AF%B9%E8%B1%A1%E4%BB%A5%E5%8F%8A%E9%BC%A0%E6%A0%87%E5%9C%A8%E9%A1%B5%E9%9D%A2%E7%9A%84%E7%BB%9D%E5%AF%B9%E4%BD%8D%E7%BD%AE.html" title="得到对象以及鼠标在页面的绝对位置">得到对象以及鼠标在页面的绝对位置</a> (0)</li></ul>
	标签Tags：<a href="http://www.5bay.cn/category/network-programming/javascript-ajax" title="JavaScript&amp;Ajax" rel="tag">JavaScript&amp;Ajax</a>, <a href="http://www.5bay.cn/tag/js" title="js" rel="tag">js</a>, <a href="http://www.5bay.cn/tag/%E9%80%89%E4%B8%AD%E6%96%87%E5%AD%97" title="选中文字" rel="tag">选中文字</a><br />
]]></content:encoded>
			<wfw:commentRss>http://www.5bay.cn/network-programming/javascript-ajax/js%E5%8F%96%E5%BE%97%E7%BD%91%E9%A1%B5%E4%B8%AD%E7%9A%84%E9%80%89%E4%B8%AD%E6%96%87%E5%AD%97.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>google个性主页的拖拽效果的js的完整注释</title>
		<link>http://www.5bay.cn/network-programming/javascript-ajax/google%E4%B8%AA%E6%80%A7%E4%B8%BB%E9%A1%B5%E7%9A%84%E6%8B%96%E6%8B%BD%E6%95%88%E6%9E%9C%E7%9A%84js%E7%9A%84%E5%AE%8C%E6%95%B4%E6%B3%A8%E9%87%8A.html</link>
		<comments>http://www.5bay.cn/network-programming/javascript-ajax/google%E4%B8%AA%E6%80%A7%E4%B8%BB%E9%A1%B5%E7%9A%84%E6%8B%96%E6%8B%BD%E6%95%88%E6%9E%9C%E7%9A%84js%E7%9A%84%E5%AE%8C%E6%95%B4%E6%B3%A8%E9%87%8A.html#comments</comments>
		<pubDate>Thu, 16 Aug 2007 21:39:40 +0000</pubDate>
		<dc:creator>江小邪</dc:creator>
				<category><![CDATA[JavaScript&Ajax]]></category>
		<category><![CDATA[google]]></category>
		<category><![CDATA[js]]></category>
		<category><![CDATA[个性主页]]></category>
		<category><![CDATA[拖拽效果]]></category>
		<category><![CDATA[注释]]></category>

		<guid isPermaLink="false">?p=262</guid>
		<description><![CDATA[<a href="http://www.5bay.cn/network-programming/javascript-ajax/google%E4%B8%AA%E6%80%A7%E4%B8%BB%E9%A1%B5%E7%9A%84%E6%8B%96%E6%8B%BD%E6%95%88%E6%9E%9C%E7%9A%84js%E7%9A%84%E5%AE%8C%E6%95%B4%E6%B3%A8%E9%87%8A.html"><img align="left" hspace="5" width="150" height="150" src="http://www.5bay.cn/wp-content/plugins/thumbnail-for-excerpts/tfe_no_thumb.png" class="alignleft wp-post-image tfe" alt="" title="" /></a>可以这里下载例子：[file]attachment/200708/google_drag.rar[/file]// 工具类，使用Util的命名空间，方便管理 var Util = new Object();// 获取http header里面的UserAgent，浏览器信息 Util.getUserAgent = navigator.userAgent;// 是否是Gecko核心的Browser，比如Mozila、Firefox Util.isGecko = Util.getUserAgent.indexOf( &#34; Gecko &#34; ) != - 1 ;// 是否是Opera Util.isOpera = Util.getUserAgent.indexOf( &#34; Opera &#34; ) != - 1 ;// 获取一个element的offset信息，其实就是相对于Body的padding以内的绝对坐标 // 后面一个参数如果是true则获取offsetLeft，false则是offsetTop // 关于offset、style、client等坐标的定义参考dindin的这个帖子：http://www.jroller.com/page/dindin/?anchor=pro_javascript_12 Util.getOffset = function (el, isLeft) { &#160; &#160;var retValue = 0 ; &#160; &#160;while [...]]]></description>
			<content:encoded><![CDATA[<p><br/>可以这里下载例子：<br/>[file]attachment/200708/<a href="http://www.5bay.cn/tag/google" class="st_tag internal_tag" rel="tag" title="标签 google 下的日志">google</a>_drag.rar[/file]<br/><span id="more-262"></span><br/><br/>// 工具类，使用Util的命名空间，方便管理 <br/>var Util = <br/>new Object();<br/>// 获取http header里面的UserAgent，浏览器信息 <br/>Util.getUserAgent = navigator.userAgent;<br/>// 是否是Gecko核心的Browser，比如Mozila、Firefox <br/>Util.isGecko = Util.getUserAgent.indexOf( &quot; Gecko &quot; ) != <br/>- 1 ;<br/>// 是否是Opera <br/>Util.isOpera = Util.getUserAgent.indexOf( &quot; Opera &quot; ) != <br/>- 1 ;<br/>// 获取一个element的offset信息，其实就是相对于Body的padding以内的绝对坐标 <br/>// 后面一个参数如果是true则获取offsetLeft，false则是offsetTop <br/>// 关于offset、style、client等坐标的定义参考dindin的这个帖子：http://www.jroller.com/page/dindin/?anchor=pro_javascript_12 <br/>Util.getOffset = <br/>function (el, isLeft) {<br/> &nbsp; &nbsp;var retValue = <br/>0 ;<br/> &nbsp; &nbsp;while (el != <br/>null ) {<br/> &nbsp; &nbsp; &nbsp; &nbsp;retValue += el[ &quot; offset &quot; <br/>+ (isLeft ? <br/>&quot; Left &quot; : &quot; Top &quot; )];<br/> &nbsp; &nbsp; &nbsp; &nbsp;el = el.offsetParent;<br/> &nbsp; &nbsp;}<br/> &nbsp; &nbsp;return retValue;<br/>};<br/>// 将一个function（参数中的funcName是这个fuction的名字）绑定到一个element上，并且以这个element的上下文运行，其实是一种继承，这个可以google些文章看看 <br/>Util.bindFunction = <br/>function (el, fucName) {<br/> &nbsp; &nbsp;return <br/>function () {<br/> &nbsp; &nbsp; &nbsp; &nbsp; return el[fucName].apply(el, arguments);<br/> &nbsp; &nbsp;};<br/>};<br/>// 重新计算所有的可以拖拽的element的坐标，对同一个column下面的可拖拽图层重新计算它们的高度而得出新的坐标，防止遮叠 <br/>// 计算出来的坐标记录在pagePosLeft和pagePosTop两个属性里面 <br/>Util.re_calcOff = <br/>function (el) {<br/> &nbsp; &nbsp;for ( var i = <br/>0 ; i &lt; Util.dragArray.length; i ++ ) {<br/> &nbsp; &nbsp; &nbsp; &nbsp; var ele = Util.dragArray;<br/> &nbsp; &nbsp; &nbsp; &nbsp;ele.elm.pagePosLeft = Util.getOffset(ele.elm, true );<br/> &nbsp; &nbsp; &nbsp; &nbsp;ele.elm.pagePosTop = Util.getOffset(ele.elm, false );<br/> &nbsp; &nbsp;}<br/> &nbsp; &nbsp;var nextSib = el.elm.nextSibling;<br/> &nbsp; &nbsp;while (nextSib) {<br/> &nbsp; &nbsp; &nbsp; &nbsp;nextSib.pagePosTop -= el.elm.offsetHeight;<br/> &nbsp; &nbsp; &nbsp; &nbsp;nextSib = nextSib.nextSibling;<br/> &nbsp; &nbsp;}<br/>};<br/><br/>// 隐藏Google Ig中间那个table，也就是拖拽的容器，配合show一般就是刷新用，解决一些浏览器的怪癖 <br/>Util.hide = <br/>function () {<br/> &nbsp; &nbsp;Util.rootElement.style.display = <br/>&quot; none &quot; ;<br/>};<br/>// 显示Google Ig中间那个table，解释同上 <br/>Util.show = <br/>function () {<br/> &nbsp; &nbsp;Util.rootElement.style.display = <br/>&quot;&quot; ;<br/>};<br/><br/>// 移动时显示的占位虚线框 <br/>ghostElement = <br/>null ;<br/>// 获取这个虚线框，通过dom动态生成 <br/>getGhostElement = <br/>function () {<br/> &nbsp; &nbsp;if ( ! ghostElement) {<br/> &nbsp; &nbsp; &nbsp; &nbsp;ghostElement = document.createElement( &quot; <a href="http://www.5bay.cn/tag/div" class="st_tag internal_tag" rel="tag" title="标签 div 下的日志">DIV</a> &quot; );<br/> &nbsp; &nbsp; &nbsp; &nbsp;ghostElement.className = <br/>&quot; modbox &quot; ;<br/> &nbsp; &nbsp; &nbsp; &nbsp;ghostElement.backgroundColor = <br/>&quot;&quot; ;<br/> &nbsp; &nbsp; &nbsp; &nbsp;ghostElement.style.border = <br/>&quot; 2px dashed #aaa &quot; ;<br/> &nbsp; &nbsp; &nbsp; &nbsp;ghostElement.innerHTML = <br/>&quot; &quot; ;<br/> &nbsp; &nbsp;}<br/> &nbsp; &nbsp;return ghostElement;<br/>};<br/><br/>// 初始化可以拖拽的Element的函数，与拖拽无关的我去掉了 <br/>function draggable(el) {<br/> &nbsp; &nbsp;// 公用的开始拖拽的函数 <br/><br/>this ._dragStart = start_Drag;<br/> &nbsp; &nbsp;// 公用的正在拖拽的函数 <br/><br/>this ._drag = when_Drag;<br/> &nbsp; &nbsp;// 公用的拖拽结束的函数 <br/><br/>this ._dragEnd = end_Drag;<br/> &nbsp; &nbsp;// 这个函数主要用来进行拖拽结束后的dom处理 <br/><br/>this ._afterDrag = after_Drag;<br/> &nbsp; &nbsp;// 是否正在被拖动，一开始当然没有被拖动 <br/><br/>this .isDragging = <br/>false ;<br/> &nbsp; &nbsp;// 将这个Element的this指针注册在elm这个变量里面，方便在自己的上下文以外调用自己的函数等，很常用的方法 <br/><br/>this .elm = el;<br/> &nbsp; &nbsp;// 触发拖拽的Element，在这里就是这个div上显示标题的那个div <br/><br/>this .header = document.getElementById(el.id + <br/>&quot; _h &quot; );<br/> &nbsp; &nbsp;// 对于有iframe的element拖拽不同，这里检测一下并记录 <br/><br/>this .hasIFrame = <br/>this .elm.getElementsByTagName( &quot; IFRAME &quot; ).length &gt; <br/>0 ;<br/> &nbsp; &nbsp;// 如果找到了header就绑定drag相关的event <br/><br/>if ( this .header) {<br/> &nbsp; &nbsp; &nbsp; &nbsp; // 拖拽时的叉子鼠标指针 <br/><br/>this .header.style.cursor = <br/>&quot; move &quot; ;<br/> &nbsp; &nbsp; &nbsp; &nbsp; // 将函数绑定到header和element的this上，参照那个函数的说明 <br/> &nbsp; &nbsp; &nbsp; &nbsp;Drag.init( this .header, this .elm);<br/> &nbsp; &nbsp; &nbsp; &nbsp; // 下面三个语句将写好的三个函数绑定给这个elemnt的三个函数钩子上，也就实现了element从draggable继承可拖拽的函数 <br/><br/>this .elm.onDragStart = Util.bindFunction( this , &quot; _dragStart &quot; );<br/> &nbsp; &nbsp; &nbsp; &nbsp; this .elm.onDrag = Util.bindFunction( this , &quot; _drag &quot; );<br/> &nbsp; &nbsp; &nbsp; &nbsp; this .elm.onDragEnd = Util.bindFunction( this , &quot; _dragEnd &quot; );<br/> &nbsp; &nbsp;}<br/>};<br/><br/>// 下面就是draggable里面用到的那4个function <br/>// 公用的开始拖拽的函数 <br/>function start_Drag() {<br/> &nbsp; &nbsp;// 重置坐标，实现拖拽以后自己的位置马上会被填充的效果 <br/> &nbsp; &nbsp;Util.re_calcOff( this );<br/> &nbsp; &nbsp;// 记录原先的邻居节点，用来对比是否被移动到新的位置 <br/><br/>this .origNextSibling = <br/>this .elm.nextSibling;<br/> &nbsp; &nbsp;// 获取移动的时候那个灰色的虚线框 <br/><br/>var _ghostElement = getGhostElement();<br/> &nbsp; &nbsp;// 获取正在移动的这个对象的高度 <br/><br/>var offH = <br/>this .elm.offsetHeight;<br/> &nbsp; &nbsp;if (Util.isGecko) {<br/> &nbsp; &nbsp; &nbsp; &nbsp; // 修正gecko引擎的怪癖吧 <br/> &nbsp; &nbsp; &nbsp; &nbsp;offH -= parseInt(_ghostElement.style.borderTopWidth) * <br/>2 ;<br/> &nbsp; &nbsp;}<br/> &nbsp; &nbsp;// 获取正在移动的这个对象的宽度 <br/><br/>var offW = <br/>this .elm.offsetWidth;<br/> &nbsp; &nbsp;// 获取left和top的坐标 <br/><br/>var offLeft = Util.getOffset( this .elm, true );<br/> &nbsp; &nbsp;var offTop = Util.getOffset( this .elm, false );<br/> &nbsp; &nbsp;// 防止闪烁，现隐藏 <br/> &nbsp; &nbsp;Util.hide();<br/> &nbsp; &nbsp;// 将自己的宽度记录在style属性里面 <br/><br/>this .elm.style.width = offW + <br/>&quot; px &quot; ;<br/> &nbsp; &nbsp;// 将那个灰框设定得与正在拖动的对象一样高，比较形象 <br/> &nbsp; &nbsp;_ghostElement.style.height = offH + <br/>&quot; px &quot; ;<br/> &nbsp; &nbsp;// 把灰框放到这个对象原先的位置上 <br/><br/>this .elm.parentNode.insertBefore(_ghostElement, this .elm.nextSibling);<br/> &nbsp; &nbsp;// 由于要拖动必须将被拖动的对象从原先的盒子模型里面抽出来，所以设定position为absolute，这个可以参考一下css布局方面的知识 <br/><br/>this .elm.style.position = <br/>&quot; absolute &quot; ;<br/> &nbsp; &nbsp;// 设置zIndex，让它处在最前面一层，当然其实zIndex=100是让它很靠前，如果页面里有zIndex&gt;100的，那…… <br/><br/>this .elm.style.zIndex = <br/>100 ;<br/> &nbsp; &nbsp;// 由于position=absolute了，所以left和top实现绝对坐标定位，这就是先前计算坐标的作用，不让这个模型乱跑，要从开始拖动的地方开始移动 <br/><br/>this .elm.style.left = offLeft + <br/>&quot; px &quot; ;<br/> &nbsp; &nbsp;this .elm.style.top = offTop + <br/>&quot; px &quot; ;<br/> &nbsp; &nbsp;// 坐标设定完毕，可以显示了，这样就不会闪烁了 <br/> &nbsp; &nbsp;Util.show();<br/> &nbsp; &nbsp;// 这里本来有个ig_d.G，没搞明白干什么用的，不过没有也可以用，谁知道麻烦告诉我一声，不好意思 <br/><br/>// 还没有开始拖拽，这里做个记号 <br/><br/>this .isDragging = <br/>false ;<br/> &nbsp; &nbsp;return <br/>false ;<br/>};<br/>// 在拖拽时的相应函数，由于绑定到鼠标的move这个event上，所以会传入鼠标的坐标clientX, clientY <br/>function when_Drag(clientX, clientY) {<br/> &nbsp; &nbsp;// 刚开始拖拽的时候将图层变透明，并标记为正在被拖拽 <br/><br/>if ( ! this .isDragging) {<br/> &nbsp; &nbsp; &nbsp; &nbsp; this .elm.style.filter = <br/>&quot; alpha(opacity=70) &quot; ;<br/> &nbsp; &nbsp; &nbsp; &nbsp; this .elm.style.opacity = <br/>0.7 ;<br/> &nbsp; &nbsp; &nbsp; &nbsp; this .isDragging = <br/>true ;<br/> &nbsp; &nbsp;}<br/> &nbsp; &nbsp;// 被拖拽到的新的column（当然也可以是原来那个） <br/><br/>var found = <br/>null ;<br/> &nbsp; &nbsp;// 最大的距离，可能是防止溢出或者什么bug <br/><br/>var max_distance = <br/>100000000 ;<br/> &nbsp; &nbsp;// 遍历所有的可拖拽的element，寻找离当前鼠标坐标最近的那个可拖拽元素，以便后面插入 <br/><br/>for ( var i = <br/>0 ; i &lt; Util.dragArray.length; i ++ ) {<br/> &nbsp; &nbsp; &nbsp; &nbsp; var ele = Util.dragArray;<br/> &nbsp; &nbsp; &nbsp; &nbsp; // 利用勾股定理计算鼠标到遍历到的这个元素的距离 <br/><br/>var distance = Math.sqrt(Math.pow(clientX &#8211; ele.elm.pagePosLeft, 2 ) + Math.pow(clientY &#8211; ele.elm.pagePosTop, 2 ));<br/> &nbsp; &nbsp; &nbsp; &nbsp; // 自己已经浮动了，所以不计算自己的 <br/><br/>if (ele == <br/>this ) {<br/> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; continue ;<br/> &nbsp; &nbsp; &nbsp; &nbsp;}<br/> &nbsp; &nbsp; &nbsp; &nbsp; // 如果计算失败继续循环 <br/><br/>if (isNaN(distance)) {<br/> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; continue ;<br/> &nbsp; &nbsp; &nbsp; &nbsp;}<br/> &nbsp; &nbsp; &nbsp; &nbsp; // 如果更小，记录下这个距离，并将它作为found <br/><br/>if (distance &lt; max_distance) {<br/> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;max_distance = distance;<br/> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;found = ele;<br/> &nbsp; &nbsp; &nbsp; &nbsp;}<br/> &nbsp; &nbsp;}<br/> &nbsp; &nbsp;// 准备让灰框落脚 <br/><br/>var _ghostElement = getGhostElement();<br/> &nbsp; &nbsp;// 如果找到了另外的落脚点 <br/><br/>if (found != <br/>null <br/>&amp;&amp; _ghostElement.nextSibling != found.elm) {<br/> &nbsp; &nbsp; &nbsp; &nbsp; // 找到落脚点就先把灰框插进去，这就是我们看到的那个灰框停靠的特效，有点像吸附的感觉，哈哈 <br/> &nbsp; &nbsp; &nbsp; &nbsp;found.elm.parentNode.insertBefore(_ghostElement, found.elm);<br/> &nbsp; &nbsp; &nbsp; &nbsp; if (Util.isOpera) {<br/> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; // Opera的现实问题，要隐藏/显示后才能刷新出变化 <br/> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;document.body.style.display = <br/>&quot; none &quot; ;<br/> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;document.body.style.display = <br/>&quot;&quot; ;<br/> &nbsp; &nbsp; &nbsp; &nbsp;}<br/> &nbsp; &nbsp;}<br/>};<br/>// 拖拽完毕 <br/>function end_Drag() {<br/> &nbsp; &nbsp;// 拖拽完毕后执行后面的钩子，执行after_Drag()，如果布局发生了变动了就记录到远程服务器，保存你拖拽后新的布局顺序 <br/><br/>if ( this ._afterDrag()) {<br/> &nbsp; &nbsp; &nbsp; &nbsp; // remote call to save the change <br/> &nbsp; &nbsp;}<br/> &nbsp; &nbsp;return <br/>true ;<br/>};<br/>// 拖拽后的执行钩子 <br/>function after_Drag() {<br/> &nbsp; &nbsp;var returnValue = <br/>false ;<br/> &nbsp; &nbsp;// 防止闪烁 <br/> &nbsp; &nbsp;Util.hide();<br/> &nbsp; &nbsp;// 把拖拽时的position=absolute和相关的那些style都消除 <br/><br/>this .elm.style.position = <br/>&quot;&quot; ;<br/> &nbsp; &nbsp;this .elm.style.width = <br/>&quot;&quot; ;<br/> &nbsp; &nbsp;this .elm.style.zIndex = <br/>&quot;&quot; ;<br/> &nbsp; &nbsp;this .elm.style.filter = <br/>&quot;&quot; ;<br/> &nbsp; &nbsp;this .elm.style.opacity = <br/>&quot;&quot; ;<br/> &nbsp; &nbsp;// 获取灰框 <br/><br/>var ele = getGhostElement();<br/> &nbsp; &nbsp;// 如果现在的邻居不是原来的邻居了 <br/><br/>if (ele.nextSibling != <br/>this .origNextSibling) {<br/> &nbsp; &nbsp; &nbsp; &nbsp; // 把被拖拽的这个节点插到灰框的前面 <br/> &nbsp; &nbsp; &nbsp; &nbsp;ele.parentNode.insertBefore( this .elm, ele.nextSibling);<br/> &nbsp; &nbsp; &nbsp; &nbsp; // 标明被拖拽了新的地方 <br/> &nbsp; &nbsp; &nbsp; &nbsp;returnValue = <br/>true ;<br/> &nbsp; &nbsp;}<br/> &nbsp; &nbsp;// 移除灰框，这是这个灰框的生命周期应该就结束了 <br/> &nbsp; &nbsp;ele.parentNode.removeChild(ele);<br/> &nbsp; &nbsp;// 修改完毕，显示 <br/> &nbsp; &nbsp;Util.show();<br/> &nbsp; &nbsp;if (Util.isOpera) {<br/> &nbsp; &nbsp; &nbsp; &nbsp; // Opera的现实问题，要隐藏/显示后才能刷新出变化 <br/> &nbsp; &nbsp; &nbsp; &nbsp;document.body.style.display = <br/>&quot; none &quot; ;<br/> &nbsp; &nbsp; &nbsp; &nbsp;document.body.style.display = <br/>&quot;&quot; ;<br/> &nbsp; &nbsp;}<br/> &nbsp; &nbsp;return returnValue;<br/>};<br/>// 可拖拽Element的原形，用来将event绑定到各个钩子，这部分市比较通用的，netvibes也是基本完全相同的实现 <br/>// 这部分推荐看dindin的这个，也会帮助理解，http://www.jroller.com/page/dindin/?anchor=pro_javascript_12 <br/>var Drag = {<br/> &nbsp; &nbsp;// 对这个element的引用，一次只能拖拽一个Element <br/> &nbsp; &nbsp;obj: null , <br/> &nbsp; &nbsp;// element是被拖拽的对象的引用，elementHeader就是鼠标可以拖拽的区域 <br/> &nbsp; &nbsp;init: function (elementHeader, element) {<br/> &nbsp; &nbsp; &nbsp; &nbsp; // 将start绑定到onmousedown事件，按下鼠标触发start <br/> &nbsp; &nbsp; &nbsp; &nbsp;elementHeader.onmousedown = Drag.start;<br/> &nbsp; &nbsp; &nbsp; &nbsp; // 将element存到header的obj里面，方便header拖拽的时候引用 <br/> &nbsp; &nbsp; &nbsp; &nbsp;elementHeader.obj = element;<br/> &nbsp; &nbsp; &nbsp; &nbsp; // 初始化绝对的坐标，因为不是position=absolute所以不会起什么作用，但是防止后面onDrag的时候parse出错了 <br/><br/>if (isNaN(parseInt(element.style.left))) {<br/> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;element.style.left = <br/>&quot; 0px &quot; ;<br/> &nbsp; &nbsp; &nbsp; &nbsp;}<br/> &nbsp; &nbsp; &nbsp; &nbsp; if (isNaN(parseInt(element.style.top))) {<br/> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;element.style.top = <br/>&quot; 0px &quot; ;<br/> &nbsp; &nbsp; &nbsp; &nbsp;}<br/> &nbsp; &nbsp; &nbsp; &nbsp; // 挂上空Function，初始化这几个成员，在Drag.init被调用后才帮定到实际的函数，可以参照draggable里面的内容 <br/> &nbsp; &nbsp; &nbsp; &nbsp;element.onDragStart = <br/>new Function();<br/> &nbsp; &nbsp; &nbsp; &nbsp;element.onDragEnd = <br/>new Function();<br/> &nbsp; &nbsp; &nbsp; &nbsp;element.onDrag = <br/>new Function();<br/> &nbsp; &nbsp;},<br/> &nbsp; &nbsp;// 开始拖拽的绑定，绑定到鼠标的移动的event上 <br/> &nbsp; &nbsp;start: function (event) {<br/> &nbsp; &nbsp; &nbsp; &nbsp; var element = Drag.obj = <br/>this .obj;<br/> &nbsp; &nbsp; &nbsp; &nbsp; // 解决不同浏览器的event模型不同的问题 <br/> &nbsp; &nbsp; &nbsp; &nbsp;event = Drag.fixE(event);<br/> &nbsp; &nbsp; &nbsp; &nbsp; // 看看是不是左键点击 <br/><br/>if (event.which != <br/>1 ) {<br/> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; // 除了左键都不起作用 <br/><br/>return <br/>true ;<br/> &nbsp; &nbsp; &nbsp; &nbsp;}<br/> &nbsp; &nbsp; &nbsp; &nbsp; // 参照这个函数的解释，挂上开始拖拽的钩子 <br/> &nbsp; &nbsp; &nbsp; &nbsp;element.onDragStart();<br/> &nbsp; &nbsp; &nbsp; &nbsp; // 记录鼠标坐标 <br/> &nbsp; &nbsp; &nbsp; &nbsp;element.lastMouseX = event.clientX;<br/> &nbsp; &nbsp; &nbsp; &nbsp;element.lastMouseY = event.clientY;<br/> &nbsp; &nbsp; &nbsp; &nbsp; // 将Global的event绑定到被拖动的element上面来 <br/> &nbsp; &nbsp; &nbsp; &nbsp;document.onmouseup = Drag.end;<br/> &nbsp; &nbsp; &nbsp; &nbsp;document.onmousemove = Drag.drag;<br/> &nbsp; &nbsp; &nbsp; &nbsp; return <br/>false ;<br/> &nbsp; &nbsp;}, <br/> &nbsp; &nbsp;// Element正在被拖动的函数 <br/> &nbsp; &nbsp;drag: function (event) {<br/> &nbsp; &nbsp; &nbsp; &nbsp; // 解决不同浏览器的event模型不同的问题 <br/> &nbsp; &nbsp; &nbsp; &nbsp;event = Drag.fixE(event);<br/> &nbsp; &nbsp; &nbsp; &nbsp; // 看看是不是左键点击 <br/><br/>if (event.which == <br/>0 ) {<br/> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; // 除了左键都不起作用 <br/><br/>return Drag.end();<br/> &nbsp; &nbsp; &nbsp; &nbsp;}<br/> &nbsp; &nbsp; &nbsp; &nbsp; // 正在被拖动的Element <br/><br/>var element = Drag.obj;<br/> &nbsp; &nbsp; &nbsp; &nbsp; // 鼠标坐标 <br/><br/>var _clientX = event.clientY;<br/> &nbsp; &nbsp; &nbsp; &nbsp; var _clientY = event.clientX;<br/> &nbsp; &nbsp; &nbsp; &nbsp; // 如果鼠标没动就什么都不作 <br/><br/>if (element.lastMouseX == _clientY &amp;&amp; element.lastMouseY == _clientX) {<br/> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; return <br/>false ;<br/> &nbsp; &nbsp; &nbsp; &nbsp;}<br/> &nbsp; &nbsp; &nbsp; &nbsp; // 刚才Element的坐标 <br/><br/>var _lastX = parseInt(element.style.top);<br/> &nbsp; &nbsp; &nbsp; &nbsp; var _lastY = parseInt(element.style.left);<br/> &nbsp; &nbsp; &nbsp; &nbsp; // 新的坐标 <br/><br/>var newX, newY;<br/> &nbsp; &nbsp; &nbsp; &nbsp; // 计算新的坐标：原先的坐标+鼠标移动的值差 <br/> &nbsp; &nbsp; &nbsp; &nbsp;newX = _lastY + _clientY &#8211; element.lastMouseX;<br/> &nbsp; &nbsp; &nbsp; &nbsp;newY = _lastX + _clientX &#8211; element.lastMouseY;<br/> &nbsp; &nbsp; &nbsp; &nbsp; // 修改element的显示坐标 <br/> &nbsp; &nbsp; &nbsp; &nbsp;element.style.left = newX + <br/>&quot; px &quot; ;<br/> &nbsp; &nbsp; &nbsp; &nbsp;element.style.top = newY + <br/>&quot; px &quot; ;<br/> &nbsp; &nbsp; &nbsp; &nbsp; // 记录element现在的坐标供下一次移动使用 <br/> &nbsp; &nbsp; &nbsp; &nbsp;element.lastMouseX = _clientY;<br/> &nbsp; &nbsp; &nbsp; &nbsp;element.lastMouseY = _clientX;<br/> &nbsp; &nbsp; &nbsp; &nbsp; // 参照这个函数的解释，挂接上Drag时的钩子 <br/> &nbsp; &nbsp; &nbsp; &nbsp;element.onDrag(newX, newY);<br/> &nbsp; &nbsp; &nbsp; &nbsp; return <br/>false ;<br/> &nbsp; &nbsp;},<br/> &nbsp; &nbsp;// Element正在被释放的函数，停止拖拽 <br/> &nbsp; &nbsp;end: function (event) {<br/> &nbsp; &nbsp; &nbsp; &nbsp; // 解决不同浏览器的event模型不同的问题 <br/> &nbsp; &nbsp; &nbsp; &nbsp;event = Drag.fixE(event);<br/> &nbsp; &nbsp; &nbsp; &nbsp; // 解除对Global的event的绑定 <br/> &nbsp; &nbsp; &nbsp; &nbsp;document.onmousemove = <br/>null ;<br/> &nbsp; &nbsp; &nbsp; &nbsp;document.onmouseup = <br/>null ;<br/> &nbsp; &nbsp; &nbsp; &nbsp; // 先记录下onDragEnd的钩子，好移除obj <br/><br/>var _onDragEndFuc = Drag.obj.onDragEnd();<br/> &nbsp; &nbsp; &nbsp; &nbsp; // 拖拽完毕，obj清空 <br/> &nbsp; &nbsp; &nbsp; &nbsp;Drag.obj = <br/>null ;<br/> &nbsp; &nbsp; &nbsp; &nbsp; return _onDragEndFuc;<br/> &nbsp; &nbsp;}, <br/> &nbsp; &nbsp;// 解决不同浏览器的event模型不同的问题 <br/> &nbsp; &nbsp;fixE: function (ig_) {<br/> &nbsp; &nbsp; &nbsp; &nbsp; if ( typeof ig_ == <br/>&quot; undefined &quot; ) {<br/> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;ig_ = window.event;<br/> &nbsp; &nbsp; &nbsp; &nbsp;}<br/> &nbsp; &nbsp; &nbsp; &nbsp; if ( typeof ig_.layerX == <br/>&quot; undefined &quot; ) {<br/> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;ig_.layerX = ig_.offsetX;<br/> &nbsp; &nbsp; &nbsp; &nbsp;}<br/> &nbsp; &nbsp; &nbsp; &nbsp; if ( typeof ig_.layerY == <br/>&quot; undefined &quot; ) {<br/> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;ig_.layerY = ig_.offsetY;<br/> &nbsp; &nbsp; &nbsp; &nbsp;}<br/> &nbsp; &nbsp; &nbsp; &nbsp; if ( typeof ig_.which == <br/>&quot; undefined &quot; ) {<br/> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;ig_.which = ig_.button;<br/> &nbsp; &nbsp; &nbsp; &nbsp;}<br/> &nbsp; &nbsp; &nbsp; &nbsp; return ig_;<br/> &nbsp; &nbsp;}<br/>};<br/><br/><br/><br/>// 下面是初始化的函数了，看看上面这些东西怎么被调用 <br/>var _IG_initDrag = <br/>function (el) {<br/> &nbsp; &nbsp;// column那个容器，在google里面就是那个table布局的tbody，netvibes用的&lt;div&gt; <br/> &nbsp; &nbsp;Util.rootElement = el;<br/> &nbsp; &nbsp;// 这个tbody的行 <br/> &nbsp; &nbsp;Util._rows = Util.rootElement.tBodies[ 0 ].rows[ 0 ];<br/> &nbsp; &nbsp;// 列，google是3列，其实也可以更多 <br/> &nbsp; &nbsp;Util.column = Util._rows.cells;<br/> &nbsp; &nbsp;// 用来存取可拖拽的对象 <br/> &nbsp; &nbsp;Util.dragArray = <br/>new Array();<br/> &nbsp; &nbsp;var counter = <br/>0 ;<br/> &nbsp; &nbsp;for ( var i = <br/>0 ; i &lt; Util.column.length; i ++ ) {<br/> &nbsp; &nbsp; &nbsp; &nbsp; // 搜索所有的column <br/><br/>var ele = Util.column;<br/> &nbsp; &nbsp; &nbsp; &nbsp; for ( var j = <br/>0 ; j &lt; ele.childNodes.length; j ++ ) {<br/> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; // 搜索每一column里面的所有element <br/><br/>var ele1 = ele.childNodes[j];<br/> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; // 如果是div就把它初始化为一个draggable对象 <br/><br/>if (ele1.tagName == <br/>&quot; DIV &quot; ) {<br/> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;Util.dragArray[counter] = <br/>new draggable(ele1);<br/> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;counter ++ ;<br/> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;}<br/> &nbsp; &nbsp; &nbsp; &nbsp;}<br/> &nbsp; &nbsp;}<br/>};<br/><br/>// google的页面里可以拖动的部分的id是&quot;t_1&quot; <br/>// 挂载到onload，载入完毕执行。不过实际上google没有用onload。 <br/>// 而是写在页面最下面，异曲同工吧，也许直接写在页面是种怪癖，或者也有可能是兼容性考虑。 <br/><br/>// 请将下面两条被注释掉的代码加，到你自己下载的一个google ig页面里面，把里面的所有其余script删除，挂上这个js也可以拖拽了，哈哈 <br/>// _table=document.getElementById(&quot;t_1&quot;); <br/>// window.onload = _IG_initDrag(_table); <br/><br/>// 其实看懂这些代码对学习javascript很有益，希望对大家能有帮助 <br/></p>
<h2  class="related_post_title">相关博文</h2><ul class="related_post"><li>2010年07月26日 -- <a href="http://www.5bay.cn/network-programming/ajaxxuan.html" title="ajax的缺点">ajax的缺点</a> (0)</li><li>2011年06月29日 -- <a href="http://www.5bay.cn/android%e7%ac%94%e8%ae%b0/androidzaixiankaifagongjuappinventor.html" title="Android在线开发工具 App Inventor">Android在线开发工具 App Inventor</a> (0)</li><li>2011年06月29日 -- <a href="http://www.5bay.cn/android%e7%ac%94%e8%ae%b0/odexxiangguanzhishi.html" title="odex相关知识">odex相关知识</a> (0)</li><li>2010年07月28日 -- <a href="http://www.5bay.cn/server-building/aspeaojie.html" title="ASP防注入新方式，希望对大家是有用的">ASP防注入新方式，希望对大家是有用的</a> (0)</li><li>2010年07月26日 -- <a href="http://www.5bay.cn/network-programming/phpeecketee.html" title="PHP和Socket简介">PHP和Socket简介</a> (0)</li><li>2010年07月26日 -- <a href="http://www.5bay.cn/network-programming/ajaxeeaoe.html" title="AJAX应用程序开发七宗罪">AJAX应用程序开发七宗罪</a> (0)</li><li>2010年07月26日 -- <a href="http://www.5bay.cn/network-programming/ajax.html" title="AJAX的各种控件和类库">AJAX的各种控件和类库</a> (0)</li><li>2010年07月26日 -- <a href="http://www.5bay.cn/network-programming/innerhtmleenertexteeterhtmlqia.html" title="innerHTML、innerText和outerHTML的用法">innerHTML、innerText和outerHTML的用法</a> (0)</li><li>2010年07月26日 -- <a href="http://www.5bay.cn/network-programming/xmlhttpe.html" title="XMLHTTP对象封装技术">XMLHTTP对象封装技术</a> (0)</li><li>2010年07月26日 -- <a href="http://www.5bay.cn/network-programming/ajaxeeeeseeao.html" title="ajax基础知识:js事件触发大全">ajax基础知识:js事件触发大全</a> (0)</li><li>2010年07月26日 -- <a href="http://www.5bay.cn/network-programming/eesoneeajaxeehuai.html" title="基于JSON的高级AJAX开发技术">基于JSON的高级AJAX开发技术</a> (0)</li><li>2010年05月23日 -- <a href="http://www.5bay.cn/network-programming/phpfengzhuangchangyongjavascriptweijsleiyibiankuaisudiaoyong.html" title="PHP封装常用Javascript为JS类以便快速调用">PHP封装常用Javascript为JS类以便快速调用</a> (1)</li><li>2010年05月23日 -- <a href="http://www.5bay.cn/network-programming/tupianlunhuanleiie7opffchromeceshitongguo.html" title="图片轮换类，IE7、OP、FF、Chrome测试通过">图片轮换类，IE7、OP、FF、Chrome测试通过</a> (2)</li><li>2010年05月23日 -- <a href="http://www.5bay.cn/network-programming/jsshixianquanjingtuxiaoguo360duxuanzhuan.html" title="JS实现全景图效果360度旋转">JS实现全景图效果360度旋转</a> (1)</li><li>2010年05月23日 -- <a href="http://www.5bay.cn/server-building/nginxderewriteguize.html" title="nginx的rewrite规则">nginx的rewrite规则</a> (1)</li></ul>
	标签Tags：<a href="http://www.5bay.cn/tag/google" title="google" rel="tag">google</a>, <a href="http://www.5bay.cn/category/network-programming/javascript-ajax" title="JavaScript&amp;Ajax" rel="tag">JavaScript&amp;Ajax</a>, <a href="http://www.5bay.cn/tag/js" title="js" rel="tag">js</a>, <a href="http://www.5bay.cn/tag/%E4%B8%AA%E6%80%A7%E4%B8%BB%E9%A1%B5" title="个性主页" rel="tag">个性主页</a>, <a href="http://www.5bay.cn/tag/%E6%8B%96%E6%8B%BD%E6%95%88%E6%9E%9C" title="拖拽效果" rel="tag">拖拽效果</a>, <a href="http://www.5bay.cn/tag/%E6%B3%A8%E9%87%8A" title="注释" rel="tag">注释</a><br />
]]></content:encoded>
			<wfw:commentRss>http://www.5bay.cn/network-programming/javascript-ajax/google%E4%B8%AA%E6%80%A7%E4%B8%BB%E9%A1%B5%E7%9A%84%E6%8B%96%E6%8B%BD%E6%95%88%E6%9E%9C%E7%9A%84js%E7%9A%84%E5%AE%8C%E6%95%B4%E6%B3%A8%E9%87%8A.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>得到对象以及鼠标在页面的绝对位置</title>
		<link>http://www.5bay.cn/network-programming/javascript-ajax/%E5%BE%97%E5%88%B0%E5%AF%B9%E8%B1%A1%E4%BB%A5%E5%8F%8A%E9%BC%A0%E6%A0%87%E5%9C%A8%E9%A1%B5%E9%9D%A2%E7%9A%84%E7%BB%9D%E5%AF%B9%E4%BD%8D%E7%BD%AE.html</link>
		<comments>http://www.5bay.cn/network-programming/javascript-ajax/%E5%BE%97%E5%88%B0%E5%AF%B9%E8%B1%A1%E4%BB%A5%E5%8F%8A%E9%BC%A0%E6%A0%87%E5%9C%A8%E9%A1%B5%E9%9D%A2%E7%9A%84%E7%BB%9D%E5%AF%B9%E4%BD%8D%E7%BD%AE.html#comments</comments>
		<pubDate>Thu, 16 Aug 2007 20:18:34 +0000</pubDate>
		<dc:creator>江小邪</dc:creator>
				<category><![CDATA[JavaScript&Ajax]]></category>
		<category><![CDATA[js]]></category>
		<category><![CDATA[对象]]></category>
		<category><![CDATA[绝对位置]]></category>
		<category><![CDATA[页面]]></category>
		<category><![CDATA[鼠标]]></category>

		<guid isPermaLink="false">?p=254</guid>
		<description><![CDATA[<a href="http://www.5bay.cn/network-programming/javascript-ajax/%E5%BE%97%E5%88%B0%E5%AF%B9%E8%B1%A1%E4%BB%A5%E5%8F%8A%E9%BC%A0%E6%A0%87%E5%9C%A8%E9%A1%B5%E9%9D%A2%E7%9A%84%E7%BB%9D%E5%AF%B9%E4%BD%8D%E7%BD%AE.html"><img align="left" hspace="5" width="150" height="150" src="http://www.5bay.cn/wp-content/plugins/thumbnail-for-excerpts/tfe_no_thumb.png" class="alignleft wp-post-image tfe" alt="" title="" /></a>获取页面元素的位置对我们很重要，如何获得元素位于页面的绝对位置呢？通过offsetLeft,offsetTop可以获得对象的左边距和上边距，但是不同浏览器因为对象处于的地位而会有些不同的解析，例如有些时候计算边距时没有把parent的边距计算进去，下面的函数将可以获得对象绝对的位置。如下：// get absolute Left position//建立者:jiarry@hotmail.com//返回对象位于窗口的绝对左边距离function getAbsoluteLeft( ob ){if(!ob){return null;} &#160; var obj = ob; &#160; var objLeft = obj .offsetLeft; &#160; while( obj != null &#38;&#38; obj .offsetParent != null &#38;&#38; obj .offsetParent.tagName != &#34;BODY&#34; ){ &#160; &#160; objLeft += obj .offsetParent.offsetLeft; &#160; &#160; obj = obj .offsetParent; &#160; }return objLeft ;}// get absolute TOP [...]]]></description>
			<content:encoded><![CDATA[<p>获取页面元素的位置对我们很重要，如何获得元素位于页面的绝对位置呢？通过offsetLeft,offsetTop可以获得对象的左边距和上边距，但是不同浏览器因为对象处于的地位而会有些不同的解析，例如有些时候计算边距时没有把parent的边距计算进去，下面的函数将可以获得对象绝对的位置。<br/><br/>如下：<br/>// get absolute Left position<br/>//建立者:jiarry@hotmail.com<br/>//返回对象位于窗口的绝对左边距离<br/>function getAbsoluteLeft( ob ){<br/>if(!ob){return null;}<br/> &nbsp; var obj = ob;<br/> &nbsp; var objLeft = obj .offsetLeft;<br/> &nbsp; while( obj != null &amp;&amp; obj .offsetParent != null &amp;&amp; obj .offsetParent.tagName != &quot;BODY&quot; ){<br/> &nbsp; &nbsp; objLeft += obj .offsetParent.offsetLeft;<br/> &nbsp; &nbsp; obj = obj .offsetParent;<br/> &nbsp; }<br/>return objLeft ;<br/>}<br/><br/>// get absolute TOP position<br/>//建立者:jiarry@hotmail.com<br/>//返回对象位于窗口的绝对上边距离<br/>function getAbsoluteTop( ob ){<br/>if(!ob){return null;}<br/>var obj = ob;<br/>var objTop = obj .offsetTop;<br/>while( obj != null &amp;&amp; obj .offsetParent != null &amp;&amp; obj .offsetParent.tagName != &quot;BODY&quot; ){<br/> &nbsp; objTop += obj .offsetParent.offsetTop;<br/> &nbsp; obj = obj .offsetParent;<br/>}<br/>return objTop ;<br/>}<br/><br/>获得页面的的宽高，左右边距有这些：<br/>window.screen.width;<br/>window.screen.height;<br/>window.document.body.offsetWidth;<br/>window.document.body.offsetHeight;<br/>window.screen.availWidth;<br/>window.screen.availHeight;<br/>window.document.body.offsetWidth;<br/>window.document.body.offsetHeight;<br/>window.screen.availWidth;<br/>window.screen.availHeight;<br/>window.document.body.scrollWidth;<br/>window.document.body.scrollHeight;<br/>window.document.body.clientHeight;<br/>window.document.body.clientWidth;<br/><br/>通过事件来获得鼠标位置主要有这些:<br/>e.layerX;<br/>e.layerY;<br/>e.pageX;<br/>e.pageY;<br/>e.screenX;<br/>e.screenY;<br/>e.offsetX;<br/>e.offsetY;<br/>e.clientX;<br/>e.clientY;<br/><br/>//获得对象相对于父级的位置<br/>obj .offsetLeft;<br/>obj .offsetTop;<br/>obj .offsetWidth;<br/>obj .offsetHeight;<br/><br/><br/><span id="more-254"></span><br/><br/>&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;<br/><br/><br/>下面是各浏览器关于页面位置的全部属性,包括获得鼠标位于该位置的实时x,y坐标：getPosition.<a href="http://www.5bay.cn/tag/html" class="st_tag internal_tag" rel="tag" title="标签 html 下的日志">html</a><br/>&lt;body&gt;<br/>&lt;<a href="http://www.5bay.cn/tag/div" class="st_tag internal_tag" rel="tag" title="标签 div 下的日志">div</a> id=&quot;object&quot; style=&quot;background-color:green;color:white&quot; onmousemove=&quot;getPosition(this,event);&quot; &gt;object,请在此处移动鼠标&lt;/<a href="http://www.5bay.cn/tag/div" class="st_tag internal_tag" rel="tag" title="标签 div 下的日志">div</a>&gt;<br/>&lt;div id=&quot;showinfo&quot;&gt;&lt;/div&gt;<br/>&lt;script&gt;<br/><br/>// get absolute Left position<br/>//建立者:jiarry@hotmail.com<br/>//返回对象位于窗口的绝对左边距离<br/>function getAbsoluteLeft( ob ){<br/>if(!ob){return null;}<br/> &nbsp; var obj = ob;<br/> &nbsp; var objLeft = obj .offsetLeft;<br/> &nbsp; while( obj != null &amp;&amp; obj .offsetParent != null &amp;&amp; obj .offsetParent.tagName != &quot;BODY&quot; ){<br/> &nbsp; &nbsp; objLeft += obj .offsetParent.offsetLeft;<br/> &nbsp; &nbsp; obj = obj .offsetParent;<br/> &nbsp; }<br/>return objLeft ;<br/>}<br/><br/>// get absolute TOP position<br/>//建立者:jiarry@hotmail.com<br/>//返回对象位于窗口的绝对上边距离<br/>function getAbsoluteTop( ob ){<br/>if(!ob){return null;}<br/>var obj = ob;<br/>var objTop = obj .offsetTop;<br/>while( obj != null &amp;&amp; obj .offsetParent != null &amp;&amp; obj .offsetParent.tagName != &quot;BODY&quot; ){<br/> &nbsp; objTop += obj .offsetParent.offsetTop;<br/> &nbsp; obj = obj .offsetParent;<br/>}<br/>return objTop ;<br/>}<br/><br/>var str=&quot;&quot;;<br/>str+=&quot;&lt;br&gt;&lt;font color=gray&gt;window.screen.width&lt;/font&gt; &quot;+window.screen.width;<br/>str+=&quot;&lt;br&gt;&lt;font color=gray&gt;window.screen.height&lt;/font&gt; &quot;+window.screen.height;<br/>str+=&quot;&lt;br&gt;&lt;font color=gray&gt;window.document.body.offsetWidth&lt;/font&gt; &quot;+window.document.body.offsetWidth;<br/>str+=&quot;&lt;br&gt;&lt;font color=gray&gt;window.document.body.offsetHeight&lt;/font&gt; &quot;+window.document.body.offsetHeight;<br/>str+=&quot;&lt;br&gt;&lt;font color=gray&gt;window.screen.availWidth&lt;/font&gt; &quot;+window.screen.availWidth;<br/>str+=&quot;&lt;br&gt;&lt;font color=gray&gt;window.screen.availHeight&lt;/font&gt; &quot;+window.screen.availHeight;<br/>str+=&quot;&lt;br&gt;&lt;font color=gray&gt;window.document.body.offsetWidth&lt;/font&gt; &quot;+window.document.body.offsetWidth;<br/>str+=&quot;&lt;br&gt;&lt;font color=gray&gt;window.document.body.offsetHeight&lt;/font&gt; &quot;+window.document.body.offsetHeight;<br/>str+=&quot;&lt;br&gt;&lt;font color=gray&gt;window.screen.availWidth&lt;/font&gt; &quot;+window.screen.availWidth;<br/>str+=&quot;&lt;br&gt;&lt;font color=gray&gt;window.screen.availHeight&lt;/font&gt; &quot;+window.screen.availHeight;<br/>str+=&quot;&lt;br&gt;&lt;font color=gray&gt;window.document.body.scrollWidth&lt;/font&gt; &quot;+window.document.body.scrollWidth;<br/>str+=&quot;&lt;br&gt;&lt;font color=gray&gt;window.document.body.scrollHeight&lt;/font&gt; &quot;+window.document.body.scrollHeight;<br/>str+=&quot;&lt;br&gt;&lt;font color=gray&gt;window.document.body.clientHeight&lt;/font&gt; &quot;+window.document.body.clientHeight;<br/>str+=&quot;&lt;br&gt;&lt;font color=gray&gt;window.document.body.clientWidth&lt;/font&gt; &quot;+window.document.body.clientWidth;<br/><br/>var str1=&quot;&quot;;<br/>function getPosition(obj,e){<br/>str1=&quot;&quot;;<br/>//str1 += str;<br/>str1+=&quot;&lt;br&gt;&lt;font color=gray&gt;e.layerX&lt;/font&gt; &quot;+e.layerX;<br/>str1+=&quot;&lt;br&gt;&lt;font color=gray&gt;e.layerY&lt;/font&gt; &quot;+e.layerY;<br/>str1+=&quot;&lt;br&gt;&lt;font color=gray&gt;e.pageX&lt;/font&gt; &quot;+e.pageX;<br/>str1+=&quot;&lt;br&gt;&lt;font color=gray&gt;e.pageY&lt;/font&gt; &quot;+e.pageY;<br/>str1+=&quot;&lt;br&gt;&lt;font color=gray&gt;e.screenX&lt;/font&gt; &quot;+e.screenX;<br/>str1+=&quot;&lt;br&gt;&lt;font color=gray&gt;e.screenY&lt;/font&gt; &quot;+e.screenY;<br/>str1+=&quot;&lt;br&gt;&lt;font color=gray&gt;e.offsetX&lt;/font&gt; &quot;+e.offsetX;<br/>str1+=&quot;&lt;br&gt;&lt;font color=gray&gt;e.offsetY&lt;/font&gt; &quot;+e.offsetY;<br/>str1+=&quot;&lt;br&gt;&lt;font color=gray&gt;e.clientX&lt;/font&gt; &quot;+e.clientX;<br/>str1+=&quot;&lt;br&gt;&lt;font color=gray&gt;e.clientY&lt;/font&gt; &quot;+e.clientY;<br/>//<br/>str1+=&quot;&lt;br&gt;&lt;font color=gray&gt;obj.offsetLeft&lt;/font&gt; &quot;+ obj .offsetLeft;<br/>str1+=&quot;&lt;br&gt;&lt;font color=gray&gt;obj.offsetTop&lt;/font&gt; &quot;+ obj .offsetTop;<br/>str1+=&quot;&lt;br&gt;&lt;font color=gray&gt;obj.offsetWidth&lt;/font&gt; &quot;+ obj .offsetWidth;<br/>str1+=&quot;&lt;br&gt;&lt;font color=gray&gt;obj.offsetHeight&lt;/font&gt; &quot;+ obj .offsetHeight;<br/><br/>str1+=&quot;&lt;hr&gt; 绝对左边距&quot;+ getAbsoluteLeft(obj);<br/>str1+=&quot;&lt;hr&gt; 绝对上边距&quot;+ getAbsoluteTop(obj);<br/>document.getElementById(&quot;showinfo&quot;).innerHTML = str1;<br/><br/>}<br/><br/>document.write( str );<br/>//alert(str)<br/>&lt;/script&gt;</p>
<h2  class="related_post_title">相关博文</h2><ul class="related_post"><li>2010年07月26日 -- <a href="http://www.5bay.cn/network-programming/ajaxeeeeseeao.html" title="ajax基础知识:js事件触发大全">ajax基础知识:js事件触发大全</a> (0)</li><li>2010年07月26日 -- <a href="http://www.5bay.cn/network-programming/ajax.html" title="AJAX的各种控件和类库">AJAX的各种控件和类库</a> (0)</li><li>2010年07月26日 -- <a href="http://www.5bay.cn/network-programming/xmlhttpe.html" title="XMLHTTP对象封装技术">XMLHTTP对象封装技术</a> (0)</li><li>2011年06月29日 -- <a href="http://www.5bay.cn/game-development/zishenshejishitonyventricejiexishoujiyouxikaifadesigecengci.html" title="资深设计师Tony Ventrice解析手机游戏开发的四个层次">资深设计师Tony Ventrice解析手机游戏开发的四个层次</a> (0)</li><li>2010年07月26日 -- <a href="http://www.5bay.cn/network-programming/ajaxeeee.html" title="Ajax的工作原理">Ajax的工作原理</a> (1)</li><li>2010年07月26日 -- <a href="http://www.5bay.cn/network-programming/innerhtmleenertexteeterhtmlqia.html" title="innerHTML、innerText和outerHTML的用法">innerHTML、innerText和outerHTML的用法</a> (0)</li><li>2010年07月26日 -- <a href="http://www.5bay.cn/network-programming/ajaxxuan.html" title="ajax的缺点">ajax的缺点</a> (0)</li><li>2010年07月26日 -- <a href="http://www.5bay.cn/network-programming/eesoneeajaxeehuai.html" title="基于JSON的高级AJAX开发技术">基于JSON的高级AJAX开发技术</a> (0)</li><li>2010年05月23日 -- <a href="http://www.5bay.cn/network-programming/phpfengzhuangchangyongjavascriptweijsleiyibiankuaisudiaoyong.html" title="PHP封装常用Javascript为JS类以便快速调用">PHP封装常用Javascript为JS类以便快速调用</a> (1)</li><li>2010年05月23日 -- <a href="http://www.5bay.cn/server-building/nginxderewriteguize.html" title="nginx的rewrite规则">nginx的rewrite规则</a> (1)</li><li>2010年05月23日 -- <a href="http://www.5bay.cn/server-building/gaoxingnengwangzhanjianshezhinandushubiji.html" title="《高性能网站建设指南》读书笔记">《高性能网站建设指南》读书笔记</a> (0)</li><li>2008年10月17日 -- <a href="http://www.5bay.cn/game-development/%E6%B8%B8%E6%88%8F%E7%9A%84%E5%B8%A7%E7%8E%87%E6%8E%A7%E5%88%B6.html" title="游戏的帧率控制">游戏的帧率控制</a> (0)</li><li>2011年06月29日 -- <a href="http://www.5bay.cn/android%e7%ac%94%e8%ae%b0/androidzaixiankaifagongjuappinventor.html" title="Android在线开发工具 App Inventor">Android在线开发工具 App Inventor</a> (0)</li><li>2010年07月28日 -- <a href="http://www.5bay.cn/server-building/aspeaojie.html" title="ASP防注入新方式，希望对大家是有用的">ASP防注入新方式，希望对大家是有用的</a> (0)</li><li>2010年07月26日 -- <a href="http://www.5bay.cn/network-programming/eeeeeeee.html" title="最令PHP初学者头痛的十四个问题">最令PHP初学者头痛的十四个问题</a> (0)</li></ul>
	标签Tags：<a href="http://www.5bay.cn/category/network-programming/javascript-ajax" title="JavaScript&amp;Ajax" rel="tag">JavaScript&amp;Ajax</a>, <a href="http://www.5bay.cn/tag/js" title="js" rel="tag">js</a>, <a href="http://www.5bay.cn/tag/%E5%AF%B9%E8%B1%A1" title="对象" rel="tag">对象</a>, <a href="http://www.5bay.cn/tag/%E7%BB%9D%E5%AF%B9%E4%BD%8D%E7%BD%AE" title="绝对位置" rel="tag">绝对位置</a>, <a href="http://www.5bay.cn/tag/%E9%A1%B5%E9%9D%A2" title="页面" rel="tag">页面</a>, <a href="http://www.5bay.cn/tag/%E9%BC%A0%E6%A0%87" title="鼠标" rel="tag">鼠标</a><br />
]]></content:encoded>
			<wfw:commentRss>http://www.5bay.cn/network-programming/javascript-ajax/%E5%BE%97%E5%88%B0%E5%AF%B9%E8%B1%A1%E4%BB%A5%E5%8F%8A%E9%BC%A0%E6%A0%87%E5%9C%A8%E9%A1%B5%E9%9D%A2%E7%9A%84%E7%BB%9D%E5%AF%B9%E4%BD%8D%E7%BD%AE.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>禁止刷新，回退的JS</title>
		<link>http://www.5bay.cn/network-programming/javascript-ajax/%E7%A6%81%E6%AD%A2%E5%88%B7%E6%96%B0%EF%BC%8C%E5%9B%9E%E9%80%80%E7%9A%84js.html</link>
		<comments>http://www.5bay.cn/network-programming/javascript-ajax/%E7%A6%81%E6%AD%A2%E5%88%B7%E6%96%B0%EF%BC%8C%E5%9B%9E%E9%80%80%E7%9A%84js.html#comments</comments>
		<pubDate>Wed, 27 Dec 2006 23:37:54 +0000</pubDate>
		<dc:creator>江小邪</dc:creator>
				<category><![CDATA[JavaScript&Ajax]]></category>
		<category><![CDATA[js]]></category>
		<category><![CDATA[回退]]></category>
		<category><![CDATA[禁止刷新]]></category>

		<guid isPermaLink="false">?p=182</guid>
		<description><![CDATA[<a href="http://www.5bay.cn/network-programming/javascript-ajax/%E7%A6%81%E6%AD%A2%E5%88%B7%E6%96%B0%EF%BC%8C%E5%9B%9E%E9%80%80%E7%9A%84js.html"><img align="left" hspace="5" width="150" height="150" src="http://www.5bay.cn/wp-content/plugins/thumbnail-for-excerpts/tfe_no_thumb.png" class="alignleft wp-post-image tfe" alt="" title="" /></a>&#60;script language=&#34;JavaScript&#34;&#62; //禁止刷新，回退 function onKeyDown() { if ( (event.altKey) &#124;&#124; ((event.keyCode == &#38;&#38; (event.srcElement.type != &#34;text&#34; &#38;&#38; event.srcElement.type != &#34;textarea&#34; &#38;&#38; event.srcElement.type != &#34;password&#34;)) &#124;&#124; ((event.ctrlKey) &#38;&#38; ((event.keyCode == 78) &#124;&#124; (event.keyCode == 82)) ) &#124;&#124; (event.keyCode == 116) ) { &#160;event.keyCode = 0; &#160;event.returnValue = false; &#160;} } document.onkeydown = onKeyDown; function stop(){ &#160; [...]]]></description>
			<content:encoded><![CDATA[<p>&lt;script language=&quot;<a href="http://www.5bay.cn/tag/javascript" class="st_tag internal_tag" rel="tag" title="标签 javascript 下的日志">JavaScript</a>&quot;&gt; <br/>//<a href="http://www.5bay.cn/tag/%E7%A6%81%E6%AD%A2%E5%88%B7%E6%96%B0" class="st_tag internal_tag" rel="tag" title="标签 禁止刷新 下的日志">禁止刷新</a>，<a href="http://www.5bay.cn/tag/%E5%9B%9E%E9%80%80" class="st_tag internal_tag" rel="tag" title="标签 回退 下的日志">回退</a> <br/>function onKeyDown() <br/>{ <br/>if ( (event.altKey) &#124;&#124; ((event.keyCode == <img src='http://www.5bay.cn/wp-includes/images/smilies/icon_cool.gif' alt='8)' class='wp-smiley' /> &amp;&amp; <br/>(event.srcElement.type != &quot;text&quot; &amp;&amp; <br/>event.srcElement.type != &quot;textarea&quot; &amp;&amp; <br/>event.srcElement.type != &quot;password&quot;)) &#124;&#124; <br/>((event.ctrlKey) &amp;&amp; ((event.keyCode == 78) &#124;&#124; (event.keyCode == 82)) ) &#124;&#124; <br/>(event.keyCode == 116) ) { <br/> &nbsp;event.keyCode = 0; <br/> &nbsp;event.returnValue = false; <br/> &nbsp;} <br/> } <br/> document.onkeydown = onKeyDown; <br/> function stop(){ &nbsp; //这个是禁用鼠标右键 <br/>return false; <br/>} <br/>document.oncontextmenu=stop; <br/>&lt;/script&gt; </p>
<h2  class="related_post_title">相关博文</h2><ul class="related_post"><li>2010年07月28日 -- <a href="http://www.5bay.cn/server-building/aspeaojie.html" title="ASP防注入新方式，希望对大家是有用的">ASP防注入新方式，希望对大家是有用的</a> (0)</li><li>2010年07月26日 -- <a href="http://www.5bay.cn/network-programming/ajax.html" title="AJAX的各种控件和类库">AJAX的各种控件和类库</a> (0)</li><li>2010年07月26日 -- <a href="http://www.5bay.cn/network-programming/innerhtmleenertexteeterhtmlqia.html" title="innerHTML、innerText和outerHTML的用法">innerHTML、innerText和outerHTML的用法</a> (0)</li><li>2010年07月26日 -- <a href="http://www.5bay.cn/network-programming/xmlhttpe.html" title="XMLHTTP对象封装技术">XMLHTTP对象封装技术</a> (0)</li><li>2010年07月26日 -- <a href="http://www.5bay.cn/network-programming/ajaxeeeeseeao.html" title="ajax基础知识:js事件触发大全">ajax基础知识:js事件触发大全</a> (0)</li><li>2010年07月26日 -- <a href="http://www.5bay.cn/network-programming/ajaxxuan.html" title="ajax的缺点">ajax的缺点</a> (0)</li><li>2010年07月26日 -- <a href="http://www.5bay.cn/network-programming/eesoneeajaxeehuai.html" title="基于JSON的高级AJAX开发技术">基于JSON的高级AJAX开发技术</a> (0)</li><li>2010年05月23日 -- <a href="http://www.5bay.cn/network-programming/phpfengzhuangchangyongjavascriptweijsleiyibiankuaisudiaoyong.html" title="PHP封装常用Javascript为JS类以便快速调用">PHP封装常用Javascript为JS类以便快速调用</a> (1)</li><li>2010年05月23日 -- <a href="http://www.5bay.cn/network-programming/jsshixianquanjingtuxiaoguo360duxuanzhuan.html" title="JS实现全景图效果360度旋转">JS实现全景图效果360度旋转</a> (1)</li><li>2010年05月23日 -- <a href="http://www.5bay.cn/server-building/nginxderewriteguize.html" title="nginx的rewrite规则">nginx的rewrite规则</a> (1)</li><li>2010年05月23日 -- <a href="http://www.5bay.cn/server-building/gaoxingnengwangzhanjianshezhinandushubiji.html" title="《高性能网站建设指南》读书笔记">《高性能网站建设指南》读书笔记</a> (0)</li><li>2008年01月2日 -- <a href="http://www.5bay.cn/network-programming/javascript-ajax/js%E8%A1%A8%E5%8D%95%E8%BE%93%E5%85%A5%E5%88%A4%E6%96%AD.html" title="js表单输入判断">js表单输入判断</a> (0)</li><li>2007年08月17日 -- <a href="http://www.5bay.cn/network-programming/javascript-ajax/js%E6%89%A9%E5%B1%95%E5%87%BD%E6%95%B0%E9%9B%86%E5%90%88.html" title="JS扩展函数集合">JS扩展函数集合</a> (0)</li><li>2007年08月17日 -- <a href="http://www.5bay.cn/network-programming/javascript-ajax/js%E5%8F%96%E5%BE%97%E7%BD%91%E9%A1%B5%E4%B8%AD%E7%9A%84%E9%80%89%E4%B8%AD%E6%96%87%E5%AD%97.html" title="js取得网页中的选中文字">js取得网页中的选中文字</a> (0)</li><li>2007年08月16日 -- <a href="http://www.5bay.cn/network-programming/javascript-ajax/google%E4%B8%AA%E6%80%A7%E4%B8%BB%E9%A1%B5%E7%9A%84%E6%8B%96%E6%8B%BD%E6%95%88%E6%9E%9C%E7%9A%84js%E7%9A%84%E5%AE%8C%E6%95%B4%E6%B3%A8%E9%87%8A.html" title="google个性主页的拖拽效果的js的完整注释">google个性主页的拖拽效果的js的完整注释</a> (0)</li></ul>
	标签Tags：<a href="http://www.5bay.cn/category/network-programming/javascript-ajax" title="JavaScript&amp;Ajax" rel="tag">JavaScript&amp;Ajax</a>, <a href="http://www.5bay.cn/tag/js" title="js" rel="tag">js</a>, <a href="http://www.5bay.cn/tag/%E5%9B%9E%E9%80%80" title="回退" rel="tag">回退</a>, <a href="http://www.5bay.cn/tag/%E7%A6%81%E6%AD%A2%E5%88%B7%E6%96%B0" title="禁止刷新" rel="tag">禁止刷新</a><br />
]]></content:encoded>
			<wfw:commentRss>http://www.5bay.cn/network-programming/javascript-ajax/%E7%A6%81%E6%AD%A2%E5%88%B7%E6%96%B0%EF%BC%8C%E5%9B%9E%E9%80%80%E7%9A%84js.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Js的MessageBox</title>
		<link>http://www.5bay.cn/network-programming/javascript-ajax/js%E7%9A%84messagebox.html</link>
		<comments>http://www.5bay.cn/network-programming/javascript-ajax/js%E7%9A%84messagebox.html#comments</comments>
		<pubDate>Wed, 27 Dec 2006 23:03:16 +0000</pubDate>
		<dc:creator>江小邪</dc:creator>
				<category><![CDATA[JavaScript&Ajax]]></category>
		<category><![CDATA[js]]></category>
		<category><![CDATA[messagebox]]></category>

		<guid isPermaLink="false">?p=175</guid>
		<description><![CDATA[<a href="http://www.5bay.cn/network-programming/javascript-ajax/js%E7%9A%84messagebox.html"><img align="left" hspace="5" width="150" height="150" src="http://www.5bay.cn/wp-content/plugins/thumbnail-for-excerpts/tfe_no_thumb.png" class="alignleft wp-post-image tfe" alt="" title="" /></a>&#160; 看到论坛上有人模仿alert　自己也写了一个。本来想模仿winapi里的MessageBox &#160;，但可惜js 不支持　阻塞模式　 ，返回值只能用异步了。 支持　FF ie opera ，DOCTYPE 可以申明　也可以不申明 &#160; 存在问题：在opera 里图层不能透明　 ，对于页面内有iframe的也无法使用 ，在ie里无法遮住select。CODE:&#60;!DOCTYPE html PUBLIC &#34;-//W3C//DTD XHTML 1.0 Transitional//EN&#34; &#34;http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd&#34;&#62; &#60;html xmlns=&#34;http://www.w3.org/1999/xhtml&#34;&#62; &#60;head&#62; &#60;meta http-equiv=&#34;Content-Type&#34; content=&#34;text/html; charset=gb2312&#34; /&#62; &#60;title&#62;MessageBox演示&#60;/title&#62; &#60;script language=&#34;javascript&#34;&#62; /******************************************************************************************* &#160; &#160; * http://2lin.net * Email:caoailin@gmail.com &#160; * QQ:38062022 &#160; * Creation date: 2006-11-27 &#160; * 下面的内容可以拷贝到一个JS文件里面 *********************************************************************************************/ // 控制按钮常量 var [...]]]></description>
			<content:encoded><![CDATA[<p> &nbsp; 看到论坛上有人模仿alert　自己也写了一个。本来想模仿winapi里的MessageBox &nbsp;，但可惜js 不支持　阻塞模式　 ，返回值只能用异步了。 支持　FF <a href="http://www.5bay.cn/tag/ie" class="st_tag internal_tag" rel="tag" title="标签 ie 下的日志">ie</a> opera ，DOCTYPE 可以申明　也可以不申明 <br/><br/> &nbsp; 存在问题：在opera 里图层不能透明　 ，对于页面内有iframe的也无法使用 ，在ie里无法遮住select。<span id="more-175"></span><br/><br/>CODE:<br/>&lt;!DOCTYPE <a href="http://www.5bay.cn/tag/html" class="st_tag internal_tag" rel="tag" title="标签 html 下的日志">html</a> PUBLIC &quot;-//W3C//DTD XHTML 1.0 Transitional//EN&quot; &quot;http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd&quot;&gt; <br/>&lt;html xmlns=&quot;http://www.w3.org/1999/xhtml&quot;&gt; <br/>&lt;head&gt; <br/>&lt;meta http-equiv=&quot;Content-Type&quot; content=&quot;text/html; charset=gb2312&quot; /&gt; <br/>&lt;title&gt;MessageBox演示&lt;/title&gt; <br/>&lt;script language=&quot;<a href="http://www.5bay.cn/tag/javascript" class="st_tag internal_tag" rel="tag" title="标签 javascript 下的日志">javascript</a>&quot;&gt; <br/>/******************************************************************************************* &nbsp; &nbsp;<br/> * http://2lin.net <br/> * Email:caoailin@gmail.com &nbsp;<br/> * QQ:38062022 &nbsp;<br/> * Creation date: 2006-11-27 &nbsp;<br/> * 下面的内容可以拷贝到一个JS文件里面 <br/>*********************************************************************************************/ <br/><br/>// 控制按钮常量 <br/>var MB_OK = 0; <br/>var MB_CANCEL = 1; <br/>var MB_OKCANCEL = 2; <br/>var MB_YES = 3; <br/>var MB_NO = 4; <br/>var MB_YESNO = 5; <br/>var MB_YESNOCANCEL = 6; <br/>// 控制按钮文本 <br/>var MB_OK_TEXT = &quot;确定&quot;; <br/>var MB_CANCEL_TEXT = &quot;取消&quot;; <br/>var MB_YES_TEXT = &quot; 是 &quot;; <br/>var MB_NO_TEXT = &quot; 否 &quot;; <br/>//提示图标 <br/>var MB_ICON = &quot;http://2lin.net/image/information.gif&quot;; <br/><br/>//委托方法 <br/>var MB_OK_METHOD = null; <br/>var MB_CANCEL_METHOD = null; <br/>var MB_YES_METHOD = null; <br/>var MB_NO_METHOD = null; <br/>var MB_BACKCALL = null; <br/>var MB_STR = &#039;&lt;style type=&quot;text/css&quot;&gt;&lt;!&#8211;&#039; + <br/> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&#039;body{margin:0px;}&#039; + <br/> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&#039;.msgbox_title{background-color: #B1CDF3;height:25px;position:relative;font-size:14px;line-height:25px;padding-left:10px;border-bottom:1px solid #000;}&#039; + <br/> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&#039;.msgbox_control{text-align:center;clear:both;height:28px;}&#039; + <br/> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&#039;.msgbox_button{background-color: #B1CDF3;border:1px solid #003366;font-size:12px;line-height:20px;height:21px;}&#039; + <br/> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&#039;.msgbox_content{padding:10px;float:left;line-height: 20px;}&#039; + <br/> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&#039;.msgbox_icon{width: 50px;height: 50px;float: left;text-align: center;line-height:50px;padding-top:10px;}&#039; + <br/> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&#039;.msgbox_mask{position:absolute;left:0px;top:0px;z-index:99999;background-color:#333333;width:100%;height:100%;}&#039; + <br/> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&#039;.msgbox{background-color: #EFFAFE;position: absolute;height:auto;font-size:12px;top:50%;left:50%;border:1px solid #999999;}&#039; + <br/> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&#039;&#8211;&gt;&lt;/style&gt;&#039; + <br/> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&#039;&lt;div id=&quot;msgBoxMask&quot; <a href="http://www.5bay.cn/tag/class" class="st_tag internal_tag" rel="tag" title="标签 class 下的日志">class</a>=&quot;msgbox_mask&quot; style=&quot;filter: alpha(opacity=0);display:none;&quot;&gt;&lt;/div&gt;&#039; + <br/> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&#039;&lt;div class=&quot;msgbox&quot; style=&quot;display:none; z-index:100000;&quot; id=&quot;msgBox&quot;&gt;&#039; + <br/> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&#039;&lt;div class=&quot;msgbox_title&quot; id=&quot;msgBoxTitle&quot;&gt;&lt;/div&gt;&#039; + <br/> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&#039;&lt;div class=&quot;msgbox_icon&quot; id=&quot;msgBoxIcon&quot;&gt;&lt;/div&gt;&#039; + <br/> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&#039;&lt;div class=&quot;msgbox_content&quot; id=&quot;msgBoxContent&quot;&gt;&lt;/div&gt;&#039; + <br/> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&#039;&lt;div class=&quot;msgbox_control&quot; id=&quot;msgBoxControl&quot;&gt;&lt;/div&gt;&lt;/div&gt;&#039;; <br/>var Timer = null; <br/>document.write(MB_STR); <br/>var icon = new Image(); <br/>icon.src = MB_ICON; <br/>/* 提示对话框 <br/> * 参数 1 : 提示内容 <br/> * 参数 2 : 提示标题 <br/> * 参数 3 : 图标路径 <br/> * 参数 4 : 按钮类型 <br/>*/ <br/>function <a href="http://www.5bay.cn/tag/messagebox" class="st_tag internal_tag" rel="tag" title="标签 messagebox 下的日志">MessageBox</a>(){ <br/> &nbsp; var _content = arguments[0] &#124;&#124; &quot;这是一个对话框！&quot;; <br/> &nbsp; var _title &nbsp; = arguments[1] &#124;&#124; &quot;提示&quot;; <br/> &nbsp; var _icon &nbsp; &nbsp;= arguments[2] &#124;&#124; MB_ICON; <br/> &nbsp; var _button &nbsp;= arguments[3] &#124;&#124; MB_OK; <br/> &nbsp; MB_BACKCALL &nbsp;= arguments[4]; <br/> &nbsp; var _iconStr = &#039;&lt;img src=&quot;{0}&quot;&gt;&#039;; <br/> &nbsp; var _btnStr &nbsp;= &#039;&lt;input name=&quot;{0}&quot; id=&quot;{0}&quot; type=&quot;button&quot; class=&quot;msgbox_button&quot; value=&quot;{1}&quot; onclick=&quot;MBMethod(this)&quot; /&gt;&#039;; <br/> &nbsp; &nbsp;<br/> &nbsp; switch(_button) <br/> &nbsp; { &nbsp; &nbsp; &nbsp; <br/> &nbsp; &nbsp; &nbsp;case MB_CANCEL &nbsp; &nbsp; &nbsp;: _btnStr = _btnStr.toFormatString(&quot;msgBoxBtnCancel&quot;, MB_CANCEL_TEXT); break; <br/> &nbsp; &nbsp; &nbsp;case MB_YES &nbsp; &nbsp; &nbsp; &nbsp; : _btnStr = _btnStr.toFormatString(&quot;msgBoxBtnYes&quot;, MB_YES_TEXT); break; <br/> &nbsp; &nbsp; &nbsp;case MB_NO &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;: _btnStr = _btnStr.toFormatString(&quot;msgBoxBtnNo&quot;, MB_NO_TEXT); break; <br/> &nbsp; &nbsp; &nbsp;case MB_OKCANCEL &nbsp; &nbsp;: &nbsp;<br/> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; _btnStr = _btnStr.toFormatString(&quot;msgBoxBtnOk&quot;, MB_OK_TEXT) + &quot; &nbsp;&quot; + <br/> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;_btnStr.toFormatString(&quot;msgBoxBtnCancel&quot;, MB_CANCEL_TEXT); &nbsp;<br/> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; break; <br/> &nbsp; &nbsp; &nbsp;case MB_YESNO &nbsp; &nbsp; &nbsp; : <br/> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;_btnStr = _btnStr.toFormatString(&quot;msgBoxBtnYes&quot;, MB_YES_TEXT) + &quot; &nbsp;&quot; + <br/> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;_btnStr.toFormatString(&quot;msgBoxBtnNo&quot;, MB_NO_TEXT); &nbsp;<br/> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;break; <br/> &nbsp; &nbsp; &nbsp;case MB_YESNOCANCEL : <br/> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;_btnStr = _btnStr.toFormatString(&quot;msgBoxBtnYes&quot;, MB_YES_TEXT) + &quot; &nbsp;&quot; + <br/> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;_btnStr.toFormatString(&quot;msgBoxBtnNo&quot;, MB_NO_TEXT) + &quot; &nbsp;&quot; + <br/> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;_btnStr.toFormatString(&quot;msgBoxBtnCancel&quot;, MB_CANCEL_TEXT); &nbsp;<br/> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;break; <br/> &nbsp; &nbsp; &nbsp;default : &nbsp;_btnStr = _btnStr.toFormatString(&quot;msgBoxBtnOk&quot;, MB_OK_TEXT); &nbsp;break; &nbsp; <br/> &nbsp; } <br/> &nbsp; //<a href="http://www.5bay.cn/tag/%E8%A7%A3%E5%86%B3" class="st_tag internal_tag" rel="tag" title="标签 解决 下的日志">解决</a>　FF 下会复位 <br/> &nbsp; ScrollTop = GetBrowserDocument().scrollTop; &nbsp;<br/> &nbsp; ScrollLeft = GetBrowserDocument().scrollLeft; &nbsp;<br/> &nbsp; GetBrowserDocument().style.overflow = &quot;hidden&quot;; <br/> &nbsp; GetBrowserDocument().scrollTop = ScrollTop; &nbsp; &nbsp;<br/> &nbsp; GetBrowserDocument().scrollLeft = ScrollLeft; &nbsp;<br/> &nbsp; $(&quot;msgBoxTitle&quot;).innerHTML = _title; <br/> &nbsp; $(&quot;msgBoxIcon&quot;).innerHTML = _iconStr.toFormatString(_icon); <br/> &nbsp; $(&quot;msgBoxContent&quot;).innerHTML = _content; &nbsp;<br/> &nbsp; $(&quot;msgBoxControl&quot;).innerHTML = &nbsp;_btnStr; <br/> &nbsp; OpacityValue = 0; <br/> &nbsp; $(&quot;msgBox&quot;).style.display = &quot;&quot;; &nbsp; &nbsp; &nbsp; &nbsp;<br/> &nbsp; try{$(&quot;msgBoxMask&quot;).filters(&quot;alpha&quot;).opacity = 0;}catch(e){}; <br/> &nbsp; $(&quot;msgBoxMask&quot;).style.opacity = 0; <br/> &nbsp; $(&quot;msgBoxMask&quot;).style.display = &quot;&quot;; <br/> &nbsp; $(&quot;msgBoxMask&quot;).style.height = GetBrowserDocument().scrollHeight + &quot;px&quot;; <br/> &nbsp; $(&quot;msgBoxMask&quot;).style.width = GetBrowserDocument().scrollWidth + &quot;px&quot;; <br/> &nbsp; Timer = setInterval(&quot;DoAlpha()&quot;,1); <br/> &nbsp; //设置位置 &nbsp; &nbsp;<br/> &nbsp; $(&quot;msgBox&quot;).style.width = &quot;100%&quot;; &nbsp; &nbsp;<br/> &nbsp; $(&quot;msgBox&quot;).style.width = ($(&quot;msgBoxIcon&quot;).offsetWidth + $(&quot;msgBoxContent&quot;).offsetWidth + 2) + &quot;px&quot;; <br/> &nbsp; $(&quot;msgBox&quot;).style.marginTop = (-$(&quot;msgBox&quot;).offsetHeight/2 + GetBrowserDocument().scrollTop) + &quot;px&quot;; <br/> &nbsp; $(&quot;msgBox&quot;).style.marginLeft = (-$(&quot;msgBox&quot;).offsetWidth/2 + GetBrowserDocument().scrollLeft) + &quot;px&quot;; &nbsp; &nbsp;<br/> &nbsp; if(_button == MB_OK &#124;&#124; _button == MB_OKCANCEL){ <br/> &nbsp; &nbsp; $(&quot;msgBoxBtnOk&quot;).focus(); <br/> &nbsp; }else if(_button == MB_YES &#124;&#124; _button == MB_YESNO &#124;&#124; _button == MB_YESNOCANCEL){ <br/> &nbsp; &nbsp; &nbsp; $(&quot;msgBoxBtnYes&quot;).focus(); <br/> &nbsp; } &nbsp; <br/>} <br/>var OpacityValue = 0; <br/>var ScrollTop = 0; <br/>var ScrollLeft = 0; <br/>function GetBrowserDocument() <br/>{ <br/> &nbsp; var _dcw = document.documentElement.clientHeight; <br/> &nbsp; var _dow = document.documentElement.offsetHeight; <br/> &nbsp; var _bcw = document.body.clientHeight; <br/> &nbsp; var _bow = document.body.offsetHeight; <br/> &nbsp; if(_dcw == 0) return document.body; <br/> &nbsp; if(_dcw == _dow) return document.documentElement; <br/> &nbsp; if(_bcw == _bow &amp;&amp; _dcw != 0) &nbsp;<br/> &nbsp; &nbsp; return document.documentElement; <br/> &nbsp; else <br/> &nbsp; &nbsp; return document.body; <br/>} <br/>function SetOpacity(obj,opacity){ <br/> &nbsp; &nbsp; &nbsp; &nbsp;if(opacity &gt;=1 ) opacity = opacity / 100; &nbsp; &nbsp; <br/> &nbsp; &nbsp; &nbsp; &nbsp;try{obj.style.opacity = opacity; }catch(e){} <br/> &nbsp; &nbsp; &nbsp; &nbsp;try{ &nbsp;<br/> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;if(obj.filters){ <br/> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;obj.filters(&quot;alpha&quot;).opacity = opacity * 100; <br/> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;} <br/> &nbsp; &nbsp; &nbsp; &nbsp;}catch(e){} <br/>} <br/>function DoAlpha(){ <br/> &nbsp; &nbsp;if (OpacityValue &gt; 20){clearInterval(Timer);return 0;} <br/> &nbsp; &nbsp;OpacityValue += 5; &nbsp; &nbsp; <br/> &nbsp; &nbsp;SetOpacity($(&quot;msgBoxMask&quot;),OpacityValue); <br/>} <br/>function MBMethod(obj) <br/>{ &nbsp; &nbsp;<br/> &nbsp; switch(obj.id) <br/> &nbsp; { <br/> &nbsp; &nbsp; &nbsp;case &quot;msgBoxBtnOk&quot; : if(MB_BACKCALL) {MB_BACKCALL(MB_OK);} else {if(MB_OK_METHOD) MB_OK_METHOD();} break; <br/> &nbsp; &nbsp; &nbsp;case &quot;msgBoxBtnCancel&quot; : if(MB_BACKCALL) {MB_BACKCALL(MB_CANCEL);} else {if(MB_CANCEL_METHOD) MB_CANCEL_METHOD();} break; <br/> &nbsp; &nbsp; &nbsp;case &quot;msgBoxBtnYes&quot; : if(MB_BACKCALL) {MB_BACKCALL(MB_YES);} else {if(MB_YES_METHOD) MB_YES_METHOD();} break; <br/> &nbsp; &nbsp; &nbsp;case &quot;msgBoxBtnNo&quot; : if(MB_BACKCALL) {MB_BACKCALL(MB_NO);} else {if(MB_NO_METHOD) MB_NO_METHOD();} break; <br/> &nbsp; } &nbsp; &nbsp;<br/> &nbsp; MB_OK_METHOD = null; <br/> &nbsp; MB_CANCEL_METHOD = null; <br/> &nbsp; MB_YES_METHOD = null; <br/> &nbsp; MB_NO_METHOD = null; <br/> &nbsp; MB_BACKCALL = null; <br/> &nbsp; MB_OK_TEXT = &quot;确定&quot;; <br/> &nbsp; MB_CANCEL_TEXT = &quot;取消&quot;; <br/> &nbsp; MB_YES_TEXT = &quot; 是 &quot;; <br/> &nbsp; MB_NO_TEXT = &quot; 否 &quot;; <br/> &nbsp; $(&quot;msgBox&quot;).style.display = &quot;none&quot;; &nbsp; <br/> &nbsp; $(&quot;msgBoxMask&quot;).style.display = &quot;none&quot;; &nbsp; &nbsp; &nbsp;<br/> &nbsp; GetBrowserDocument().style.overflow = &quot;&quot;; &nbsp;<br/> &nbsp; GetBrowserDocument().scrollTop = ScrollTop; <br/> &nbsp; GetBrowserDocument().scrollLeft = ScrollLeft; &nbsp;<br/>} <br/>String.prototype.toFormatString = function(){ &nbsp; <br/> &nbsp; var _str = this; <br/> &nbsp; for(var i = 0; i &lt; arguments.length; i++){ &nbsp; &nbsp; <br/> &nbsp; &nbsp; &nbsp;_str = eval(&quot;_str.replace(/&#92;&#92;{&quot;+ i +&quot;&#92;&#92;}/ig,&#039;&quot; + arguments<i> + &quot;&#039;)&quot;); <br/> &nbsp; } <br/> &nbsp; return _str; <br/>} <br/>function $(obj){ <br/> &nbsp; return document.getElementById(obj); <br/>} <br/>/////////////////////////////////////////////////////////////////////////////////////// <br/>&lt;/script&gt; <br/>&lt;script language=&quot;javascript&quot;&gt; <br/>function test() <br/>{ <br/> &nbsp; var _msg = &quot;&lt;font color=red&gt;&lt;b&gt;演示：&lt;/b&gt;&lt;/font&gt;&lt;br/&gt;普通对话框！&quot;; <br/> &nbsp; MessageBox(_msg); <br/>} <br/>function test1() <br/>{ <br/> &nbsp;MB_OK_METHOD = function(){alert(&#039;你按了OK&#039;);} <br/> &nbsp;MB_YES_METHOD = function(){alert(&#039;你按了YES&#039;);} <br/> &nbsp;MB_NO_METHOD = function(){alert(&#039;你按了NO&#039;);} <br/> &nbsp;MB_CANCEL_METHOD = function(){alert(&#039;你按了CANCEL&#039;);} &nbsp;<br/> &nbsp;var _msg = &quot;&lt;font color=red&gt;&lt;b&gt;演示：&lt;/b&gt;&lt;/font&gt;&lt;br/&gt;调用对话框。是、否、取消&quot;; <br/> &nbsp;MessageBox(_msg,&quot;演示&quot;,null,MB_YESNOCANCEL); &nbsp; <br/>} <br/>function test2() <br/>{ &nbsp;<br/> &nbsp;var _msg = &quot;&lt;font color=red&gt;&lt;b&gt;演示：&lt;/b&gt;&lt;/font&gt;&lt;br/&gt;调用对话框。是、否、取消&quot;; <br/> &nbsp;MessageBox(_msg,&quot;演示&quot;,MB_ICON,MB_YESNOCANCEL,callback); <br/>} <br/>function test4() <br/>{ &nbsp;<br/> &nbsp;var _msg = &quot;&lt;font color=red&gt;&lt;b&gt;演示：&lt;/b&gt;&lt;/font&gt;&lt;br/&gt;调用对话框。确定、取消&quot;; <br/> &nbsp;MessageBox(_msg,&quot;演示&quot;,MB_ICON,MB_OKCANCEL,callback); <br/>} <br/>function callback(value) <br/>{ <br/> &nbsp;switch(value) <br/> &nbsp;{ <br/> &nbsp; &nbsp; case MB_OK : alert(&#039;你按了OK&#039;); break; <br/> &nbsp; &nbsp; case MB_YES : alert(&#039;你按了YES&#039;); break; <br/> &nbsp; &nbsp; case MB_NO : alert(&#039;你按了NO&#039;); break; <br/> &nbsp; &nbsp; case MB_CANCEL : alert(&#039;你按了CANCEL&#039;); break; <br/> &nbsp; } <br/>} <br/>function test3() <br/>{ &nbsp;<br/> &nbsp;MB_YES_TEXT = &quot;演示一&quot;; <br/> &nbsp;MB_NO_TEXT = &quot;演示二&quot;; <br/> &nbsp;MB_CANCEL_TEXT = &quot;演示三&quot;; <br/> &nbsp;var _msg = &quot;&lt;font color=red&gt;&lt;b&gt;演示：&lt;/b&gt;&lt;/font&gt;&lt;br/&gt;这是自定义的对话框&lt;br/&gt; &lt;font color=green&gt;MB_YES_TEXT &nbsp;MB_NO_TEXT MB_CANCEL_TEXT MB_OK_TEXT&lt;/font&gt;&quot;; <br/> &nbsp;MessageBox(_msg,&quot;演示&quot;,MB_ICON,MB_YESNOCANCEL,callback); <br/>} <br/>&lt;/script&gt; <br/>&lt;/head&gt; <br/>&lt;body&gt; <br/>&lt;table width=&quot;1500&quot; height=&quot;1000&quot; border=&quot;1&quot; bordercolor=&quot;#000000&quot;&gt; <br/> &nbsp;&lt;tr&gt; <br/> &nbsp; &nbsp;&lt;td&gt;　&lt;/td&gt; <br/> &nbsp; &nbsp;&lt;td align=&quot;center&quot;&gt;&lt;a href=&quot;javascript:test()&quot;&gt;普通演示&lt;/a&gt;&lt;/td&gt; <br/> &nbsp; &nbsp;&lt;td&gt;　&lt;/td&gt; <br/> &nbsp;&lt;/tr&gt; <br/> &nbsp;&lt;tr&gt; <br/> &nbsp; &nbsp;&lt;td&gt; &lt;/td&gt; <br/> &nbsp; &nbsp;&lt;td align=&quot;center&quot;&gt;&lt;a href=&quot;javascript:test1()&quot;&gt;回调演示一&lt;/a&gt; <br/> &nbsp; &nbsp;&lt;label&gt;&lt;/label&gt;&lt;/td&gt; <br/> &nbsp; &nbsp;&lt;td&gt; &lt;/td&gt; <br/> &nbsp;&lt;/tr&gt; <br/> &nbsp;&lt;tr&gt; <br/> &nbsp; &nbsp;&lt;td&gt; &lt;/td&gt; <br/> &nbsp; &nbsp;&lt;td align=&quot;center&quot;&gt;&lt;a href=&quot;javascript:test2()&quot;&gt;回调演示二 <br/> &nbsp; &nbsp;&lt;/a&gt;&lt;/td&gt; <br/> &nbsp; &nbsp;&lt;td&gt; &lt;/td&gt; <br/> &nbsp;&lt;/tr&gt; <br/> &nbsp;&lt;tr&gt; <br/> &nbsp; &nbsp;&lt;td&gt; &lt;/td&gt; <br/> &nbsp; &nbsp;&lt;td align=&quot;center&quot;&gt;&lt;a href=&quot;javascript:test4()&quot;&gt;回调演示三&lt;/a&gt;&lt;a href=&quot;javascript:test3()&quot;&gt;&lt;/a&gt;&lt;/td&gt; <br/> &nbsp; &nbsp;&lt;td&gt; &lt;/td&gt; <br/> &nbsp;&lt;/tr&gt; <br/> &nbsp;&lt;tr&gt; <br/> &nbsp; &nbsp;&lt;td&gt; &lt;/td&gt; <br/> &nbsp; &nbsp;&lt;td align=&quot;center&quot;&gt;&lt;a href=&quot;javascript:test3()&quot;&gt;自定义演示 <br/> &nbsp; &nbsp;&lt;/a&gt;&lt;/td&gt; <br/> &nbsp; &nbsp;&lt;td&gt; &lt;/td&gt; <br/> &nbsp;&lt;/tr&gt; <br/>&lt;/table&gt; <br/>&lt;/body&gt; <br/>&lt;/html&gt;<br/></p>
<h2  class="related_post_title">相关博文</h2><ul class="related_post"><li>2010年07月28日 -- <a href="http://www.5bay.cn/server-building/aspeaojie.html" title="ASP防注入新方式，希望对大家是有用的">ASP防注入新方式，希望对大家是有用的</a> (0)</li><li>2010年07月26日 -- <a href="http://www.5bay.cn/network-programming/ajax.html" title="AJAX的各种控件和类库">AJAX的各种控件和类库</a> (0)</li><li>2010年07月26日 -- <a href="http://www.5bay.cn/network-programming/innerhtmleenertexteeterhtmlqia.html" title="innerHTML、innerText和outerHTML的用法">innerHTML、innerText和outerHTML的用法</a> (0)</li><li>2010年07月26日 -- <a href="http://www.5bay.cn/network-programming/xmlhttpe.html" title="XMLHTTP对象封装技术">XMLHTTP对象封装技术</a> (0)</li><li>2010年07月26日 -- <a href="http://www.5bay.cn/network-programming/ajaxeeeeseeao.html" title="ajax基础知识:js事件触发大全">ajax基础知识:js事件触发大全</a> (0)</li><li>2010年07月26日 -- <a href="http://www.5bay.cn/network-programming/ajaxxuan.html" title="ajax的缺点">ajax的缺点</a> (0)</li><li>2010年07月26日 -- <a href="http://www.5bay.cn/network-programming/eesoneeajaxeehuai.html" title="基于JSON的高级AJAX开发技术">基于JSON的高级AJAX开发技术</a> (0)</li><li>2010年05月23日 -- <a href="http://www.5bay.cn/network-programming/phpfengzhuangchangyongjavascriptweijsleiyibiankuaisudiaoyong.html" title="PHP封装常用Javascript为JS类以便快速调用">PHP封装常用Javascript为JS类以便快速调用</a> (1)</li><li>2010年05月23日 -- <a href="http://www.5bay.cn/network-programming/jsshixianquanjingtuxiaoguo360duxuanzhuan.html" title="JS实现全景图效果360度旋转">JS实现全景图效果360度旋转</a> (1)</li><li>2010年05月23日 -- <a href="http://www.5bay.cn/server-building/nginxderewriteguize.html" title="nginx的rewrite规则">nginx的rewrite规则</a> (1)</li><li>2010年05月23日 -- <a href="http://www.5bay.cn/server-building/gaoxingnengwangzhanjianshezhinandushubiji.html" title="《高性能网站建设指南》读书笔记">《高性能网站建设指南》读书笔记</a> (0)</li><li>2008年01月2日 -- <a href="http://www.5bay.cn/network-programming/javascript-ajax/js%E8%A1%A8%E5%8D%95%E8%BE%93%E5%85%A5%E5%88%A4%E6%96%AD.html" title="js表单输入判断">js表单输入判断</a> (0)</li><li>2007年08月17日 -- <a href="http://www.5bay.cn/network-programming/javascript-ajax/js%E6%89%A9%E5%B1%95%E5%87%BD%E6%95%B0%E9%9B%86%E5%90%88.html" title="JS扩展函数集合">JS扩展函数集合</a> (0)</li><li>2007年08月17日 -- <a href="http://www.5bay.cn/network-programming/javascript-ajax/js%E5%8F%96%E5%BE%97%E7%BD%91%E9%A1%B5%E4%B8%AD%E7%9A%84%E9%80%89%E4%B8%AD%E6%96%87%E5%AD%97.html" title="js取得网页中的选中文字">js取得网页中的选中文字</a> (0)</li><li>2007年08月16日 -- <a href="http://www.5bay.cn/network-programming/javascript-ajax/google%E4%B8%AA%E6%80%A7%E4%B8%BB%E9%A1%B5%E7%9A%84%E6%8B%96%E6%8B%BD%E6%95%88%E6%9E%9C%E7%9A%84js%E7%9A%84%E5%AE%8C%E6%95%B4%E6%B3%A8%E9%87%8A.html" title="google个性主页的拖拽效果的js的完整注释">google个性主页的拖拽效果的js的完整注释</a> (0)</li></ul>
	标签Tags：<a href="http://www.5bay.cn/category/network-programming/javascript-ajax" title="JavaScript&amp;Ajax" rel="tag">JavaScript&amp;Ajax</a>, <a href="http://www.5bay.cn/tag/js" title="js" rel="tag">js</a>, <a href="http://www.5bay.cn/tag/messagebox" title="messagebox" rel="tag">messagebox</a><br />
]]></content:encoded>
			<wfw:commentRss>http://www.5bay.cn/network-programming/javascript-ajax/js%E7%9A%84messagebox.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>过滤HTML代码的函数包括过滤CSS和JS</title>
		<link>http://www.5bay.cn/network-programming/asp/%E8%BF%87%E6%BB%A4html%E4%BB%A3%E7%A0%81%E7%9A%84%E5%87%BD%E6%95%B0%E5%8C%85%E6%8B%AC%E8%BF%87%E6%BB%A4css%E5%92%8Cjs.html</link>
		<comments>http://www.5bay.cn/network-programming/asp/%E8%BF%87%E6%BB%A4html%E4%BB%A3%E7%A0%81%E7%9A%84%E5%87%BD%E6%95%B0%E5%8C%85%E6%8B%AC%E8%BF%87%E6%BB%A4css%E5%92%8Cjs.html#comments</comments>
		<pubDate>Fri, 22 Dec 2006 01:10:32 +0000</pubDate>
		<dc:creator>江小邪</dc:creator>
				<category><![CDATA[ASP]]></category>
		<category><![CDATA[css]]></category>
		<category><![CDATA[js]]></category>
		<category><![CDATA[函数]]></category>

		<guid isPermaLink="false">?p=155</guid>
		<description><![CDATA[<a href="http://www.5bay.cn/network-programming/asp/%E8%BF%87%E6%BB%A4html%E4%BB%A3%E7%A0%81%E7%9A%84%E5%87%BD%E6%95%B0%E5%8C%85%E6%8B%AC%E8%BF%87%E6%BB%A4css%E5%92%8Cjs.html"><img align="left" hspace="5" width="150" height="150" src="http://www.5bay.cn/wp-content/plugins/thumbnail-for-excerpts/tfe_no_thumb.png" class="alignleft wp-post-image tfe" alt="" title="" /></a>&#039;过滤HTML代码的函数包括过滤CSS和JSFunction RemoveHTML(strHTML) &#160; &#160;&#039;过滤HTML代码的函数包括过滤CSS和JSStrHtml = Replace(StrHtml,vbCrLf,&#34;&#34;)StrHtml = Replace(StrHtml,Chr(13)&#38;Chr(10),&#34;&#34;)StrHtml = Replace(StrHtml,Chr(13),&#34;&#34;)StrHtml = Replace(StrHtml,Chr(10),&#34;&#34;)StrHtml = Replace(StrHtml,&#34; &#34;,&#34;&#34;)StrHtml = Replace(StrHtml,&#34; &#160; &#160;&#34;,&#34;&#34;) Dim objRegExp, Match, Matches Set objRegExp = New Regexp objRegExp.IgnoreCase = True objRegExp.Global = True &#039;取闭合的&#60;&#62; objRegExp.Pattern = &#34;&#34; &#039;进行匹配 Set Matches = objRegExp.Execute(strHTML) &#039; 遍历匹配集合，并替换掉匹配的项目 For Each Match in Matches strHtml=Replace(strHTML,Match.Value,&#34;&#34;) Next &#160;&#039;取闭合的&#60;&#62; objRegExp.Pattern = [...]]]></description>
			<content:encoded><![CDATA[<p><span id="more-155"></span><br/>&#039;过滤HTML代码的函数包括过滤CSS和JS<br/>Function RemoveHTML(strHTML) &nbsp; &nbsp;&#039;过滤HTML代码的函数包括过滤CSS和JS<br/>StrHtml = Replace(StrHtml,vbCrLf,&quot;&quot;)<br/>StrHtml = Replace(StrHtml,Chr(13)&amp;Chr(10),&quot;&quot;)<br/>StrHtml = Replace(StrHtml,Chr(13),&quot;&quot;)<br/>StrHtml = Replace(StrHtml,Chr(10),&quot;&quot;)<br/>StrHtml = Replace(StrHtml,&quot; &quot;,&quot;&quot;)<br/>StrHtml = Replace(StrHtml,&quot; &nbsp; &nbsp;&quot;,&quot;&quot;)<br/> Dim objRegExp, Match, Matches <br/> Set objRegExp = New Regexp<br/> objRegExp.IgnoreCase = True<br/> objRegExp.Global = True<br/> &#039;取闭合的&lt;&gt;<br/> objRegExp.Pattern = &quot;&quot;<br/> &#039;进行匹配<br/> Set Matches = objRegExp.Execute(strHTML)<br/> &#039; 遍历匹配集合，并替换掉匹配的项目<br/> For Each Match in Matches <br/> strHtml=Replace(strHTML,Match.Value,&quot;&quot;)<br/> Next<br/> &nbsp;&#039;取闭合的&lt;&gt;<br/> objRegExp.Pattern = &quot;&quot;<br/> &#039;进行匹配<br/> Set Matches = objRegExp.Execute(strHTML)<br/> &#039; 遍历匹配集合，并替换掉匹配的项目<br/> For Each Match in Matches <br/> strHtml=Replace(strHTML,Match.Value,&quot;&quot;)<br/> Next<br/> &nbsp;&#039;取闭合的&lt;&gt;<br/> objRegExp.Pattern = &quot;&lt;.+?&gt;&quot;<br/> &#039;进行匹配<br/> Set Matches = objRegExp.Execute(strHTML)<br/> &#039; 遍历匹配集合，并替换掉匹配的项目<br/> For Each Match in Matches <br/> strHtml=Replace(strHTML,Match.Value,&quot;&quot;)<br/> Next<br/> RemoveHTML=strHTML<br/> Set objRegExp = Nothing<br/>End Function</p>
<h2  class="related_post_title">相关博文</h2><ul class="related_post"><li>2010年07月26日 -- <a href="http://www.5bay.cn/network-programming/ajax.html" title="AJAX的各种控件和类库">AJAX的各种控件和类库</a> (0)</li><li>2010年07月28日 -- <a href="http://www.5bay.cn/server-building/aspeaojie.html" title="ASP防注入新方式，希望对大家是有用的">ASP防注入新方式，希望对大家是有用的</a> (0)</li><li>2010年05月23日 -- <a href="http://www.5bay.cn/server-building/nginxderewriteguize.html" title="nginx的rewrite规则">nginx的rewrite规则</a> (1)</li><li>2010年05月23日 -- <a href="http://www.5bay.cn/website/nginxtongguouser-agentpanduanshoujizhongduan.html" title="nginx 通过user-agent判断手机终端">nginx 通过user-agent判断手机终端</a> (0)</li><li>2010年05月23日 -- <a href="http://www.5bay.cn/server-building/gaoxingnengwangzhanjianshezhinandushubiji.html" title="《高性能网站建设指南》读书笔记">《高性能网站建设指南》读书笔记</a> (0)</li><li>2006年12月27日 -- <a href="http://www.5bay.cn/network-programming/asp/%E5%A4%9A%E5%AD%97%E6%AE%B5%E6%A8%A1%E7%B3%8A%E6%90%9C%E7%B4%A2%E5%87%BD%E6%95%B0.html" title="多字段模糊搜索函数">多字段模糊搜索函数</a> (3)</li><li>2006年12月22日 -- <a href="http://www.5bay.cn/network-programming/asp/asp%E9%95%BF%E6%96%87%E7%AB%A0%E7%9A%84%E8%87%AA%E5%8A%A8%E5%88%86%E9%A1%B5%E4%BB%A3%E7%A0%81.html" title="asp长文章的自动分页代码">asp长文章的自动分页代码</a> (0)</li><li>2006年12月8日 -- <a href="http://www.5bay.cn/network-programming/javascript-ajax/%E5%8A%A8%E6%80%81css%EF%BC%8C%E6%8D%A2%E8%82%A4%E6%8A%80%E6%9C%AF.html" title="动态CSS，换肤技术">动态CSS，换肤技术</a> (0)</li><li>2006年12月8日 -- <a href="http://www.5bay.cn/network-programming/javascript-ajax/%E7%B2%BE%E5%8D%8E%E4%BB%A3%E7%A0%81%E9%9B%86.html" title="精华代码集">精华代码集</a> (0)</li><li>2006年11月20日 -- <a href="http://www.5bay.cn/network-programming/javascript-ajax/javascript%E5%B8%B8%E7%94%A8%E6%A3%80%E6%B5%8B%E8%84%9A%E6%9C%AC.html" title="JavaScript常用检测脚本">JavaScript常用检测脚本</a> (0)</li><li>2006年10月27日 -- <a href="http://www.5bay.cn/network-programming/php/%E4%B8%BAjs%E5%86%99%E4%BA%86%E4%B8%80%E4%B8%AAinclude%E5%87%BD%E6%95%B0.html" title="为JS写了一个include函数">为JS写了一个include函数</a> (3)</li><li>2011年12月16日 -- <a href="http://www.5bay.cn/server-building/apachezhongkeepalivepeizhidehelishiyong.html" title="Apache 中 KeepAlive 配置的合理使用">Apache 中 KeepAlive 配置的合理使用</a> (0)</li><li>2011年06月29日 -- <a href="http://www.5bay.cn/me/kaiyuanruanjiandeyinglimoshi.html" title="开源软件的盈利模式">开源软件的盈利模式</a> (0)</li><li>2010年07月28日 -- <a href="http://www.5bay.cn/server-building/eeprn-asp-jpg.html" title="如何删除删不掉的”PRN.asp:.jpg”">如何删除删不掉的”PRN.asp:.jpg”</a> (0)</li><li>2010年07月26日 -- <a href="http://www.5bay.cn/network-programming/phpeecketee.html" title="PHP和Socket简介">PHP和Socket简介</a> (0)</li></ul>
	标签Tags：<a href="http://www.5bay.cn/category/network-programming/asp" title="ASP" rel="tag">ASP</a>, <a href="http://www.5bay.cn/tag/asp" title="ASP" rel="tag">ASP</a>, <a href="http://www.5bay.cn/tag/css" title="css" rel="tag">css</a>, <a href="http://www.5bay.cn/tag/js" title="js" rel="tag">js</a>, <a href="http://www.5bay.cn/tag/%E5%87%BD%E6%95%B0" title="函数" rel="tag">函数</a><br />
]]></content:encoded>
			<wfw:commentRss>http://www.5bay.cn/network-programming/asp/%E8%BF%87%E6%BB%A4html%E4%BB%A3%E7%A0%81%E7%9A%84%E5%87%BD%E6%95%B0%E5%8C%85%E6%8B%AC%E8%BF%87%E6%BB%A4css%E5%92%8Cjs.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>动态CSS，换肤技术</title>
		<link>http://www.5bay.cn/network-programming/javascript-ajax/%E5%8A%A8%E6%80%81css%EF%BC%8C%E6%8D%A2%E8%82%A4%E6%8A%80%E6%9C%AF.html</link>
		<comments>http://www.5bay.cn/network-programming/javascript-ajax/%E5%8A%A8%E6%80%81css%EF%BC%8C%E6%8D%A2%E8%82%A4%E6%8A%80%E6%9C%AF.html#comments</comments>
		<pubDate>Fri, 08 Dec 2006 20:00:15 +0000</pubDate>
		<dc:creator>江小邪</dc:creator>
				<category><![CDATA[JavaScript&Ajax]]></category>
		<category><![CDATA[css]]></category>
		<category><![CDATA[dhtml]]></category>
		<category><![CDATA[js]]></category>
		<category><![CDATA[换肤]]></category>

		<guid isPermaLink="false">?p=142</guid>
		<description><![CDATA[<a href="http://www.5bay.cn/network-programming/javascript-ajax/%E5%8A%A8%E6%80%81css%EF%BC%8C%E6%8D%A2%E8%82%A4%E6%8A%80%E6%9C%AF.html"><img align="left" hspace="5" width="150" height="150" src="http://www.5bay.cn/wp-content/plugins/thumbnail-for-excerpts/tfe_no_thumb.png" class="alignleft wp-post-image tfe" alt="" title="" /></a>常见的例子就是：一个站点上有多个页面样式提供浏览者选择。同时，在选择了某样式后，再次打开该页面时，将仍然保持该样式。自然会想到了Cookie技术下面是HTML代码部分（另外再加需要的CSS文件就可以使用了）：&#60;HTML&#62;&#60;HEAD&#62;&#60;link ID=&#34;skin&#34; rel=&#34;stylesheet&#34; type=&#34;text/css&#34;&#62;&#60;TITLE&#62;换肤技术&#60;/TITLE&#62;&#60;SCRIPT LANGUAGE=javascript&#62;&#60;!&#8211;function SetCookie(name,value){ &#160; &#160; var argv=SetCookie.arguments; &#160; &#160; var argc=SetCookie.arguments.length; &#160; &#160; var expires=(2&#60;argc)?argv[2]:null; &#160; &#160; var path=(3&#60;argc)?argv[3]:null; &#160; &#160; var domain=(4&#60;argc)?argv[4]:null; &#160; &#160; var secure=(5&#60;argc)?argv[5]:false; &#160; &#160; document.cookie=name+&#34;=&#34;+escape(value)+((expires==null)?&#34;&#34;:(&#34;; expires=&#34;+expires.toGMTString()))+((path==null)?&#34;&#34;:(&#34;; path=&#34;+path))+((domain==null)?&#34;&#34;:(&#34;; domain=&#34;+domain))+((secure==true)?&#34;; secure&#34;:&#34;&#34;);}function GetCookie(Name) { &#160; &#160; var search = Name + &#34;=&#34;; &#160; &#160; var returnvalue = &#34;&#34;; &#160; &#160; [...]]]></description>
			<content:encoded><![CDATA[<p>常见的例子就是：一个站点上有多个页面样式提供浏览者选择。<br/><br/>同时，在选择了某样式后，再次打开该页面时，将仍然保持该样式。<br/><br/>自然会想到了Cookie技术<span id="more-142"></span><br/><br/>下面是HTML代码部分（另外再加需要的CSS文件就可以使用了）：<br/><br/>&lt;<a href="http://www.5bay.cn/tag/html" class="st_tag internal_tag" rel="tag" title="标签 html 下的日志">HTML</a>&gt;<br/>&lt;HEAD&gt;<br/>&lt;link ID=&quot;skin&quot; rel=&quot;stylesheet&quot; type=&quot;text/<a href="http://www.5bay.cn/tag/css" class="st_tag internal_tag" rel="tag" title="标签 css 下的日志">css</a>&quot;&gt;<br/>&lt;TITLE&gt;换肤技术&lt;/TITLE&gt;<br/>&lt;SCRIPT LANGUAGE=<a href="http://www.5bay.cn/tag/javascript" class="st_tag internal_tag" rel="tag" title="标签 javascript 下的日志">javascript</a>&gt;<br/>&lt;!&#8211;<br/>function SetCookie(name,value){<br/> &nbsp; &nbsp; var argv=SetCookie.arguments;<br/> &nbsp; &nbsp; var argc=SetCookie.arguments.length;<br/> &nbsp; &nbsp; var expires=(2&lt;argc)?argv[2]:null;<br/> &nbsp; &nbsp; var path=(3&lt;argc)?argv[3]:null;<br/> &nbsp; &nbsp; var <a href="http://www.5bay.cn/tag/domain" class="st_tag internal_tag" rel="tag" title="标签 domain 下的日志">domain</a>=(4&lt;argc)?argv[4]:null;<br/> &nbsp; &nbsp; var secure=(5&lt;argc)?argv[5]:false;<br/> &nbsp; &nbsp; document.<a href="http://www.5bay.cn/tag/cookie" class="st_tag internal_tag" rel="tag" title="标签 cookie 下的日志">cookie</a>=name+&quot;=&quot;+escape(value)+((expires==null)?&quot;&quot;:(&quot;; expires=&quot;+expires.toGMTString()))+((path==null)?&quot;&quot;:(&quot;; path=&quot;+path))+((domain==null)?&quot;&quot;:(&quot;; domain=&quot;+domain))+((secure==true)?&quot;; secure&quot;:&quot;&quot;);<br/>}<br/><br/>function GetCookie(Name) {<br/> &nbsp; &nbsp; var search = Name + &quot;=&quot;;<br/> &nbsp; &nbsp; var returnvalue = &quot;&quot;;<br/> &nbsp; &nbsp; if (document.cookie.length &gt; 0) {<br/> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; offset = document.cookie.indexOf(search);<br/> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if (offset != -1) { &nbsp; &nbsp; <br/> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; offset += search.length;<br/> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; end = document.cookie.indexOf(&quot;;&quot;, offset); &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br/> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if (end == -1)<br/> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; end = document.cookie.length;<br/> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; returnvalue=unescape(document.cookie.substring(offset,end));<br/> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }<br/> &nbsp; &nbsp; }<br/> &nbsp; &nbsp; return returnvalue;<br/>}<br/><br/>var thisskin;<br/>thisskin=GetCookie(&quot;nowskin&quot;);<br/>if(thisskin!=&quot;&quot;)<br/> &nbsp; &nbsp; skin.href=thisskin;<br/>else<br/> &nbsp; &nbsp; skin.href=&quot;css.css&quot;;<br/><br/>function changecss(url){<br/> &nbsp; &nbsp; if(url!=&quot;&quot;){<br/> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; skin.href=url;<br/> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; var expdate=new Date();<br/> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; expdate.setTime(expdate.getTime()+(24*60*60*1000*30));<br/> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; //expdate=null;<br/> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; //以下设置COOKIES时间为1年,自己随便设置该时间..<br/> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; SetCookie(&quot;nowskin&quot;,url,expdate,&quot;/&quot;,null,false);<br/> &nbsp; &nbsp; }<br/>}<br/>//&#8211;&gt;<br/>&lt;/SCRIPT&gt;<br/>&lt;/HEAD&gt;<br/>&lt;BODY&gt;<br/><br/>&lt;P&gt;请选择下面的下拉菜单测试换肤效果&lt;/P&gt;<br/><br/>&lt;a href=# onclick=&quot;changecss(&#039;css.css&#039;)&quot;&gt;css.css&lt;/a&gt;<br/>&lt;a href=# onclick=&quot;changecss(&#039;css1.css&#039;)&quot;&gt;css1.css&lt;/a&gt;<br/>&lt;a href=# onclick=&quot;changecss(&#039;css2.css&#039;)&quot;&gt;css2.css&lt;/a&gt;<br/>&lt;a href=# onclick=&quot;changecss(&#039;css3.css&#039;)&quot;&gt;css3.css&lt;/a&gt;<br/>&lt;br&gt;<br/><br/>&lt;select onchange=&quot;changecss(this.value)&quot;&gt;<br/>&lt;option&gt;选择样式单文件&lt;/option&gt;<br/>&lt;script language=&quot;javascript&quot;&gt;<br/>var csss=new Array();<br/>csss[0]=&quot;css.css&quot;;<br/>csss[1]=&quot;css1.css&quot;;<br/>csss[2]=&quot;css2.css&quot;;<br/>csss[3]=&quot;css3.css&quot;;<br/>var i;<br/>for(i=0;i&lt;4;i++)<br/> &nbsp; &nbsp; if(thisskin==csss<i>)<br/> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; document.write(&quot;&lt;option value=&#92;&quot;&quot;+csss<i>+&quot;&#92;&quot; selected&gt;&quot;+csss<i>+&quot;样式单文件&lt;/option&gt;&quot;);<br/> &nbsp; &nbsp; else<br/> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; document.write(&quot;&lt;option value=&#92;&quot;&quot;+csss<i>+&quot;&#92;&quot;&gt;&quot;+csss<i>+&quot;样式单文件&lt;/option&gt;&quot;);<br/>&lt;/script&gt;<br/>&lt;/select&gt;<br/>&lt;/BODY&gt;<br/>&lt;/HTML&gt;<br/></p>
<h2  class="related_post_title">相关博文</h2><ul class="related_post"><li>2010年07月26日 -- <a href="http://www.5bay.cn/network-programming/ajax.html" title="AJAX的各种控件和类库">AJAX的各种控件和类库</a> (0)</li><li>2010年07月26日 -- <a href="http://www.5bay.cn/network-programming/eejaxeeeeee.html" title="使用Ajax时的十个常犯的错误">使用Ajax时的十个常犯的错误</a> (0)</li><li>2010年05月23日 -- <a href="http://www.5bay.cn/server-building/nginxderewriteguize.html" title="nginx的rewrite规则">nginx的rewrite规则</a> (1)</li><li>2010年05月23日 -- <a href="http://www.5bay.cn/server-building/gaoxingnengwangzhanjianshezhinandushubiji.html" title="《高性能网站建设指南》读书笔记">《高性能网站建设指南》读书笔记</a> (0)</li><li>2006年12月22日 -- <a href="http://www.5bay.cn/network-programming/asp/%E8%BF%87%E6%BB%A4html%E4%BB%A3%E7%A0%81%E7%9A%84%E5%87%BD%E6%95%B0%E5%8C%85%E6%8B%AC%E8%BF%87%E6%BB%A4css%E5%92%8Cjs.html" title="过滤HTML代码的函数包括过滤CSS和JS ">过滤HTML代码的函数包括过滤CSS和JS </a> (0)</li><li>2006年12月8日 -- <a href="http://www.5bay.cn/network-programming/dhtml-css/mozilla%E5%BB%BA%E8%AE%AE%E7%9A%84css%E4%B9%A6%E5%86%99%E9%A1%BA%E5%BA%8F.html" title="Mozilla建议的CSS书写顺序">Mozilla建议的CSS书写顺序</a> (0)</li><li>2011年12月16日 -- <a href="http://www.5bay.cn/server-building/apachezhongkeepalivepeizhidehelishiyong.html" title="Apache 中 KeepAlive 配置的合理使用">Apache 中 KeepAlive 配置的合理使用</a> (0)</li><li>2010年07月28日 -- <a href="http://www.5bay.cn/server-building/aspeaojie.html" title="ASP防注入新方式，希望对大家是有用的">ASP防注入新方式，希望对大家是有用的</a> (0)</li><li>2010年07月26日 -- <a href="http://www.5bay.cn/network-programming/ajaxeeaoe.html" title="AJAX应用程序开发七宗罪">AJAX应用程序开发七宗罪</a> (0)</li><li>2010年07月26日 -- <a href="http://www.5bay.cn/network-programming/innerhtmleenertexteeterhtmlqia.html" title="innerHTML、innerText和outerHTML的用法">innerHTML、innerText和outerHTML的用法</a> (0)</li><li>2010年07月26日 -- <a href="http://www.5bay.cn/network-programming/xmlhttpe.html" title="XMLHTTP对象封装技术">XMLHTTP对象封装技术</a> (0)</li><li>2010年07月26日 -- <a href="http://www.5bay.cn/network-programming/ajaxeeeeseeao.html" title="ajax基础知识:js事件触发大全">ajax基础知识:js事件触发大全</a> (0)</li><li>2010年07月26日 -- <a href="http://www.5bay.cn/network-programming/ajaxxuan.html" title="ajax的缺点">ajax的缺点</a> (0)</li><li>2010年07月26日 -- <a href="http://www.5bay.cn/network-programming/eesoneeajaxeehuai.html" title="基于JSON的高级AJAX开发技术">基于JSON的高级AJAX开发技术</a> (0)</li><li>2010年07月22日 -- <a href="http://www.5bay.cn/me/csseeeeyao.html" title="CSS 中的太极拳口诀">CSS 中的太极拳口诀</a> (0)</li></ul>
	标签Tags：<a href="http://www.5bay.cn/tag/css" title="css" rel="tag">css</a>, <a href="http://www.5bay.cn/tag/dhtml" title="dhtml" rel="tag">dhtml</a>, <a href="http://www.5bay.cn/category/network-programming/javascript-ajax" title="JavaScript&amp;Ajax" rel="tag">JavaScript&amp;Ajax</a>, <a href="http://www.5bay.cn/tag/js" title="js" rel="tag">js</a>, <a href="http://www.5bay.cn/tag/%E6%8D%A2%E8%82%A4" title="换肤" rel="tag">换肤</a><br />
]]></content:encoded>
			<wfw:commentRss>http://www.5bay.cn/network-programming/javascript-ajax/%E5%8A%A8%E6%80%81css%EF%BC%8C%E6%8D%A2%E8%82%A4%E6%8A%80%E6%9C%AF.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

