<?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>三水清三水清</title>
	<atom:link href="http://js8.in/author/admin/feed" rel="self" type="application/rss+xml" />
	<link>http://js8.in</link>
	<description>专注前端开发,分享Javascript/CSS/PHP等Web前端开发技巧</description>
	<lastBuildDate>Sat, 21 Apr 2012 02:50:09 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.6</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>nodePPT — nodejs做的手机端控制PC端的PPT演示文档javascript框架</title>
		<link>http://js8.in/989.html</link>
		<comments>http://js8.in/989.html#comments</comments>
		<pubDate>Sat, 21 Apr 2012 02:47:01 +0000</pubDate>
		<dc:creator>三水清</dc:creator>
				<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[web前端开发]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[nodejs]]></category>
		<category><![CDATA[PPT]]></category>

		<guid isPermaLink="false">http://js8.in/?p=989</guid>
		<description><![CDATA[nodePPT使用nodejs写的，可以手机端控制pc端的演示文档框架。nodePPT是在webSlide基础上二次开发的，使用nodejs做服务器，通过websocket来实现手机端和PC的通信，主要功能是手机端可以控制pc端PPT播放进度，并且手机端可以给每张PPT做备注。
第一次做个程序的nodejs作品，并且测试时间比较短，肯定会有很多问题和bug，希望大家一起斧正。另外页面样式css高手可以自己写，包括动画自定义都可以在css文件中直接修改添加。
说明
因为是PPT演示文档，所以需要投影仪分辨率，所以演示页面的最佳分辨率为全屏模式下的 1024*768 ，如果在自己电脑上查看，可以通过 ctrl + - 和 ctrl + + 缩放到合适的比例查看效果。
建议浏览器chrome 16+，全屏模式（F11），以达到最佳动画效果。在Firefox下会出现拖尾现象，个人认为是Firefox 8下对CSS3动画效果渲染太慢导致，其他浏览器未测试。
使用说明

配置route.json
配置ppt的文件
启动node：node server.js
PC访问：如127.0.0.1:3000/demo.ppt
手机端访问：127.0.0.1:3000/ctrl
手机端setup，选择控制用户后，开始控制

具体使用方法启动node server.js之后访问127.0.0.1:3000/index.ppt，里面有详细的介绍
快捷键

空格/→/↓/Tab/pageDown：下一页
←/↑/pageUp：上一页
P：开画板
C：清除画板

版本库地址

支持三种访问协议：

HTTP协议： https://ksky521@github.com/ksky521/nodePPT.git 。
Git协议： git://github.com/ksky521/nodePPT.git 。
SSH协议： ssh://git@github.com:ksky521/nodePPT.git 。

克隆版本库
操作示例：
$ git clone git://github.com/ksky521/nodePPT.git

联系方式
作者博客：js8.in
作者新浪微博：@三水清

声明：文章未声明为原创文章，本文链接 http://js8.in/989.html. 转载请注明转自 JS8.IN ™
随机文章

十七届三中全会思想汇报~
08.11.17
IE6 PNG图片不透明问题的解决方法
解决jQuery中dbclick事件触发两次click事件
Adobe紧急发布flash Clickjacking漏洞暂时的解决方案
我被遨游撞了一下腰
jQuery+google weather API轻松实现天气地图（二）
关于wBox iFrame回调关闭问题的解决方案


© 三水清 for 三水清, 2012. &#124;
3 comments &#124;在微博关注我：@清-三水清
收藏到：
人人网 &#124; 豆瓣 &#124; 开心网 &#124; QQ书签 &#124; 新浪微博 &#124; 腾讯微博

Post tags: javascript, nodejs, PPT
<table class="wumii-related-items" cellspacing="0" cellpadding="3" border="0"  style="clear: both;">
    
    <tr>
        <td colspan="4"><b><font size="-1"  style="display: block !important; padding: 20px 0 5px !important;">猜你喜欢：</font></b></td>
    </tr>
    
        <tr>
                <td width="102" valign="top" style="padding: 5px !important; margin: 0 !important;">
                    <a target="_blank" title="nodejs教程：配置nodejs.exe的windows目录结构" style="text-decoration: none !important; cursor: pointer !important;" href="http://app.wumii.com/ext/redirect?url=http%3A%2F%2Fjs8.in%2F764.html&from=http%3A%2F%2Fjs8.in%2F989.html">
                        <img style="margin: 0 !important; padding: 2px !important; border: 1px solid #DDDDDD !important; width: 96px !important; height: 96px !important;" src="http://static.wumii.com/site_images/2011/11/17/10978302.png" width="96px" height="96px" /><br />
                        <font size="-1" color="#333333" style="display: block !important; line-height: 15px !important; width: 102px !important; font: 12px/15px arial !important; height: 60px !important; margin: 3px 0 0 0 !important; padding: 0 !important; overflow: hidden !important;">nodejs教程：配置nodejs.exe的windows目录结构</font>
                    </a>
                </td>
                <td width="102" valign="top" style="padding: 5px !important; margin: 0 !important; border-left: 1px solid #DDDDDD !important;">
                    <a target="_blank" title="webSlide — PPT演示文档javascript框架" style="text-decoration: none !important; cursor: pointer !important;" href="http://app.wumii.com/ext/redirect?url=http%3A%2F%2Fjs8.in%2F974.html&from=http%3A%2F%2Fjs8.in%2F989.html">
                        <img style="margin: 0 !important; padding: 2px !important; border: 1px solid #DDDDDD !important; width: 96px !important; height: 96px !important;" src="http://static.wumii.com/site_images/2012/03/08/16731779.png" width="96px" height="96px" /><br />
                        <font size="-1" color="#333333" style="display: block !important; line-height: 15px !important; width: 102px !important; font: 12px/15px arial !important; height: 60px !important; margin: 3px 0 0 0 !important; padding: 0 !important; overflow: hidden !important;">webSlide — PPT演示文档javascript框架</font>
                    </a>
                </td>
                <td width="102" valign="top" style="padding: 5px !important; margin: 0 !important; border-left: 1px solid #DDDDDD !important;">
                    <a target="_blank" title="nodejs教程：安装express及配置app.js文件" style="text-decoration: none !important; cursor: pointer !important;" href="http://app.wumii.com/ext/redirect?url=http%3A%2F%2Fjs8.in%2F774.html&from=http%3A%2F%2Fjs8.in%2F989.html">
                        <img style="margin: 0 !important; padding: 2px !important; border: 1px solid #DDDDDD !important; width: 96px !important; height: 96px !important;" src="http://static.wumii.com/site_images/2011/11/17/10978526.png" width="96px" height="96px" /><br />
                        <font size="-1" color="#333333" style="display: block !important; line-height: 15px !important; width: 102px !important; font: 12px/15px arial !important; height: 60px !important; margin: 3px 0 0 0 !important; padding: 0 !important; overflow: hidden !important;">nodejs教程：安装express及配置app.js文件</font>
                    </a>
                </td>
                <td width="102" valign="top" style="padding: 5px !important; margin: 0 !important; border-left: 1px solid #DDDDDD !important;">
                    <a target="_blank" title="使用cygwin在windows下安装nodeJS" style="text-decoration: none !important; cursor: pointer !important;" href="http://app.wumii.com/ext/redirect?url=http%3A%2F%2Fjs8.in%2F758.html&from=http%3A%2F%2Fjs8.in%2F989.html">
                        <img style="margin: 0 !important; padding: 2px !important; border: 1px solid #DDDDDD !important; width: 96px !important; height: 96px !important;" src="http://static.wumii.com/site_images/2011/09/21/32572660.png" width="96px" height="96px" /><br />
                        <font size="-1" color="#333333" style="display: block !important; line-height: 15px !important; width: 102px !important; font: 12px/15px arial !important; height: 60px !important; margin: 3px 0 0 0 !important; padding: 0 !important; overflow: hidden !important;">使用cygwin在windows下安装nodeJS</font>
                    </a>
                </td>
        </tr>
    
    <tr>
        <td colspan="4" align="right">
            <a style="text-decoration: none !important;" href="http://www.wumii.com/widget/relatedItems" target="_blank" title="无觅相关文章插件">
                <font size="-1" color="#bbbbbb" style="display: block !important; font-family: arial !important; padding: 5px 0 !important; font-size: 12px !important; color: #bbb !important;">无觅</font>
            </a>
        </td>
    </tr>
</table>]]></description>
			<content:encoded><![CDATA[<p><a target="_blank" href="https://github.com/ksky521/nodePPT">nodePPT</a>使用nodejs写的，可以手机端控制pc端的演示文档框架。<strong>nodePPT</strong>是在<a target="_blank" href="https://github.com/ksky521/webSlide">webSlide</a>基础上二次开发的，使用nodejs做服务器，通过websocket来实现手机端和PC的通信，主要功能是手机端可以控制pc端PPT播放进度，并且手机端可以给每张PPT做备注。</p>
<p>第一次做个程序的<strong>nodejs</strong>作品，并且测试时间比较短，肯定会有很多问题和bug，希望大家一起斧正。另外页面样式css高手可以自己写，包括动画自定义都可以在css文件中直接修改添加。</p>
<h2>说明</h2>
<p>因为是PPT演示文档，所以需要投影仪分辨率，所以演示页面的最佳分辨率为全屏模式下的 <code>1024*768</code> ，如果在自己电脑上查看，可以通过 <code>ctrl + -</code> 和 <code>ctrl + +</code> 缩放到合适的比例查看效果。</p>
<p>建议浏览器chrome 16+，全屏模式（F11），以达到最佳动画效果。在Firefox下会出现拖尾现象，个人认为是Firefox 8下对CSS3动画效果渲染太慢导致，其他浏览器未测试。<br />
<div id="attachment_995" class="wp-caption aligncenter" style="width: 450px"><a href="http://js8.in/989.html/796f423btw1ds70hjcu93j" rel="attachment wp-att-995"><img src="http://js8.in/wp-content/uploads/2012/04/796f423btw1ds70hjcu93j.jpg" alt="nodePPT iphone手机端截图" title="nodePPT iphone手机端截图" width="440" height="616" class="size-full wp-image-995" /></a><p class="wp-caption-text">nodePPT iphone手机端截图</p></div></p>
<h4>使用说明</h4>
<ol>
<li>配置route.json</li>
<li>配置ppt的文件</li>
<li>启动node：node server.js</li>
<li>PC访问：如127.0.0.1:3000/demo.ppt</li>
<li>手机端访问：127.0.0.1:3000/ctrl</li>
<li>手机端setup，选择控制用户后，开始控制</li>
</ol>
<p>具体使用方法启动node server.js之后访问127.0.0.1:3000/index.ppt，里面有详细的介绍</p>
<h2>快捷键</h2>
<ul>
<li>空格/→/↓/Tab/pageDown：下一页</li>
<li>←/↑/pageUp：上一页</li>
<li>P：开画板</li>
<li>C：清除画板</li>
</ul>
<h2>版本库地址</h2>
<p><span id="more-989"></span><br />
支持三种访问协议：</p>
<ol>
<li>HTTP协议： <code>https://ksky521@github.com/ksky521/nodePPT.git</code> 。</li>
<li>Git协议： <code>git://github.com/ksky521/nodePPT.git</code> 。</li>
<li>SSH协议： <code>ssh://git@github.com:ksky521/nodePPT.git</code> 。</li>
</ol>
<h2>克隆版本库</h2>
<p>操作示例：</p>
<pre><code>$ git clone git://github.com/ksky521/nodePPT.git
</code></pre>
<h2>联系方式</h2>
<p>作者博客：<a href="http://js8.in">js8.in</a></p>
<p>作者新浪微博：<a target="_blank" href="http://weibo.com/sanshuiqing">@三水清</a>
<div class="copyright">
<strong>声明：</strong>文章未声明为原创文章，本文链接 <a href="http://js8.in/989.html" title="nodePPT — nodejs做的手机端控制PC端的PPT演示文档javascript框架">http://js8.in/989.html</a>. 转载请注明转自<a href="http://js8.in" title="前端开发博客"> JS8.IN ™</a></span></span></div>
<h3 class="box-title">随机文章</h3>
<ul class="box_random">
<li><a href="http://js8.in/639.html" title="企业黄页网站GongSiHuangYe.COM上线" rel="bookmark inlinks">企业黄页网站GongSiHuangYe.COM上线</a></li>
<li><a href="http://js8.in/35.html" title="评论开通了~加上啦~" rel="bookmark inlinks">评论开通了~加上啦~</a></li>
<li><a href="http://js8.in/946.html" title="windows搭建memcached环境" rel="bookmark inlinks">windows搭建memcached环境</a></li>
<li><a href="http://js8.in/416.html" title="jQuery选择器使用详解" rel="bookmark inlinks">jQuery选择器使用详解</a></li>
<li><a href="http://js8.in/586.html" title="通过PHP批量下载图片文件" rel="bookmark inlinks">通过PHP批量下载图片文件</a></li>
<li><a href="http://js8.in/16.html" title="终于快转正啦~" rel="bookmark inlinks">终于快转正啦~</a></li>
<li><a href="http://js8.in/519.html" title="windows下安装基于Apache的SVN服务器" rel="bookmark inlinks">windows下安装基于Apache的SVN服务器</a></li>
<li><a href="http://js8.in/15.html" title="奋斗了两天！" rel="bookmark inlinks">奋斗了两天！</a></li>
</ul>
<hr />
<p><small>© 三水清 for <a href="http://js8.in">三水清</a>, 2012. |
<a href="http://js8.in/989.html#comments">3 comments</a> |在微博关注我：<a href="//weibo.com/sanshuiqing" target="_blank" title="关注断桥残雪的新浪微博">@清-三水清</a>
<br/>收藏到：
<a rel="nofollow" href="http://share.renren.com/share/buttonshare.do?link=%posturl%&title=%posttitle%" title="收藏本文到人人网" target="_blank">人人网</a> | <a rel="nofollow" href="http://www.douban.com/recommend/?url=%posturl%&title=%posttitle%" title="收藏本文到豆瓣" target="_blank">豆瓣</a> | <a rel="nofollow" href="http://www.kaixin001.com/repaste/share.php?rtitle=%posttitle%&rurl=%posturl%" title="收藏本文到开心网" target="_blank">开心网</a> | <a rel="nofollow" href="http://shuqian.qq.com/post?title=%posttitle%&%20uri=%posturl%" title="收藏本文到QQ书签" target="_blank">QQ书签</a> | <a rel="nofollow" href="http://v.t.sina.com.cn/share/share.php?url=%posturl%&title=%posttitle%" title="收藏本文到新浪微博" target="_blank">新浪微博</a> | <a rel="nofollow" href="http://v.t.qq.com/share/share.php?title=%posttitle%&url=%posturl%&site=http://www.kaixin100.info" title="收藏本文到腾讯微博" target="_blank">腾讯微博</a>
<br/>
Post tags: <a href="http://js8.in/tag/javascript" rel="tag">javascript</a>, <a href="http://js8.in/tag/nodejs" rel="tag">nodejs</a>, <a href="http://js8.in/tag/ppt" rel="tag">PPT</a><br/>
</small></p><table class="wumii-related-items" cellspacing="0" cellpadding="3" border="0"  style="clear: both;">
    
    <tr>
        <td colspan="4"><b><font size="-1"  style="display: block !important; padding: 20px 0 5px !important;">猜你喜欢：</font></b></td>
    </tr>
    
        <tr>
                <td width="102" valign="top" style="padding: 5px !important; margin: 0 !important;">
                    <a target="_blank" title="nodejs教程：配置nodejs.exe的windows目录结构" style="text-decoration: none !important; cursor: pointer !important;" href="http://app.wumii.com/ext/redirect?url=http%3A%2F%2Fjs8.in%2F764.html&from=http%3A%2F%2Fjs8.in%2F989.html">
                        <img style="margin: 0 !important; padding: 2px !important; border: 1px solid #DDDDDD !important; width: 96px !important; height: 96px !important;" src="http://static.wumii.com/site_images/2011/11/17/10978302.png" width="96px" height="96px" /><br />
                        <font size="-1" color="#333333" style="display: block !important; line-height: 15px !important; width: 102px !important; font: 12px/15px arial !important; height: 60px !important; margin: 3px 0 0 0 !important; padding: 0 !important; overflow: hidden !important;">nodejs教程：配置nodejs.exe的windows目录结构</font>
                    </a>
                </td>
                <td width="102" valign="top" style="padding: 5px !important; margin: 0 !important; border-left: 1px solid #DDDDDD !important;">
                    <a target="_blank" title="webSlide — PPT演示文档javascript框架" style="text-decoration: none !important; cursor: pointer !important;" href="http://app.wumii.com/ext/redirect?url=http%3A%2F%2Fjs8.in%2F974.html&from=http%3A%2F%2Fjs8.in%2F989.html">
                        <img style="margin: 0 !important; padding: 2px !important; border: 1px solid #DDDDDD !important; width: 96px !important; height: 96px !important;" src="http://static.wumii.com/site_images/2012/03/08/16731779.png" width="96px" height="96px" /><br />
                        <font size="-1" color="#333333" style="display: block !important; line-height: 15px !important; width: 102px !important; font: 12px/15px arial !important; height: 60px !important; margin: 3px 0 0 0 !important; padding: 0 !important; overflow: hidden !important;">webSlide — PPT演示文档javascript框架</font>
                    </a>
                </td>
                <td width="102" valign="top" style="padding: 5px !important; margin: 0 !important; border-left: 1px solid #DDDDDD !important;">
                    <a target="_blank" title="nodejs教程：安装express及配置app.js文件" style="text-decoration: none !important; cursor: pointer !important;" href="http://app.wumii.com/ext/redirect?url=http%3A%2F%2Fjs8.in%2F774.html&from=http%3A%2F%2Fjs8.in%2F989.html">
                        <img style="margin: 0 !important; padding: 2px !important; border: 1px solid #DDDDDD !important; width: 96px !important; height: 96px !important;" src="http://static.wumii.com/site_images/2011/11/17/10978526.png" width="96px" height="96px" /><br />
                        <font size="-1" color="#333333" style="display: block !important; line-height: 15px !important; width: 102px !important; font: 12px/15px arial !important; height: 60px !important; margin: 3px 0 0 0 !important; padding: 0 !important; overflow: hidden !important;">nodejs教程：安装express及配置app.js文件</font>
                    </a>
                </td>
                <td width="102" valign="top" style="padding: 5px !important; margin: 0 !important; border-left: 1px solid #DDDDDD !important;">
                    <a target="_blank" title="使用cygwin在windows下安装nodeJS" style="text-decoration: none !important; cursor: pointer !important;" href="http://app.wumii.com/ext/redirect?url=http%3A%2F%2Fjs8.in%2F758.html&from=http%3A%2F%2Fjs8.in%2F989.html">
                        <img style="margin: 0 !important; padding: 2px !important; border: 1px solid #DDDDDD !important; width: 96px !important; height: 96px !important;" src="http://static.wumii.com/site_images/2011/09/21/32572660.png" width="96px" height="96px" /><br />
                        <font size="-1" color="#333333" style="display: block !important; line-height: 15px !important; width: 102px !important; font: 12px/15px arial !important; height: 60px !important; margin: 3px 0 0 0 !important; padding: 0 !important; overflow: hidden !important;">使用cygwin在windows下安装nodeJS</font>
                    </a>
                </td>
        </tr>
    
    <tr>
        <td colspan="4" align="right">
            <a style="text-decoration: none !important;" href="http://www.wumii.com/widget/relatedItems" target="_blank" title="无觅相关文章插件">
                <font size="-1" color="#bbbbbb" style="display: block !important; font-family: arial !important; padding: 5px 0 !important; font-size: 12px !important; color: #bbb !important;">无觅</font>
            </a>
        </td>
    </tr>
</table>]]></content:encoded>
			<wfw:commentRss>http://js8.in/989.html/feed</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>addEventListener第二个参数的handleEvent</title>
		<link>http://js8.in/983.html</link>
		<comments>http://js8.in/983.html#comments</comments>
		<pubDate>Thu, 08 Mar 2012 02:48:17 +0000</pubDate>
		<dc:creator>三水清</dc:creator>
				<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[addEventListener]]></category>
		<category><![CDATA[javascript]]></category>

		<guid isPermaLink="false">http://js8.in/?p=983</guid>
		<description><![CDATA[昨天无意中看到一篇老外的文章，文章提到了addEventListener第二个参数可以传入object，并且对象中handleEvent为事件处理函数。例如下面的javascript代码：

var obj = &#123;
	handleEvent: function&#40;&#41; &#123;
		alert&#40;'body clicked'&#41;;
	&#125;
&#125;;
document.body.addEventListener&#40;'click',obj,false&#41;;

测试发现这段代码在IE9+，chrome，FF，opera等浏览器是正确的（测试范围可能不够宽），而且可以成功的绑定click事件。在Qwrap群里一问才知道是DOM2中接口，很有意思的一个发现，@貘大大 也发微博说自己先入为主了，我相信很多人跟@貘大大 一样都先入为主了。
addEventListener的handleEvent应用
发现了这个“新大陆”有什么用法呢？哈哈~首先想到的是对象引用。看下面的javascript代码：

&#60;script type=&#34;text/javascript&#34;&#62;
var obj = {
handleEvent: function() {
	alert('body clicked');
}
};
document.body.addEventListener('click',obj,false);
function fn2(){
	obj.handleEvent = function(){
		alert('fn2');
	};
}
&#60;/script&#62;
&#60;button onclick=&#34;fn2();&#34;&#62;change&#60;/button&#62;

因为对象的引用关系，点击下button就可以切换绑定事件的处理函数，而不需要remove之前的事件，然后重新绑定一个新的处理函数。

如果你觉得这个不够炫，那么下面的javascript代码可能就更有吸引力了哦~

var obj2 = &#123;
	addEvent:function&#40;el&#41;&#123;
		el.addEventListener&#40;'click',this,false&#41;;
	&#125;,
	handleEvent:function&#40;e&#41;&#123;
		alert&#40;e.target&#41;;
	&#125;
&#125;;
obj2.addEvent&#40;document.body&#41;;

addEventListener handleEvent缺点
显而易见，IE6~IE8不能使用……可是如果是高级浏览器还是不错的功能哦~
扩展阅读
http://peter.michaux.ca/articles/our-backwards-dom-event-libraries
http://ajaxian.com/archives/an-alternative-way-to-addeventlistener

声明：文章未声明为原创文章，本文链接 http://js8.in/983.html. 转载请注明转自 JS8.IN ™
随机文章

css解决chrome 12px字号限制
linux安装PHP加速器eAccelerator
使用JavaScript在IE和Firefox下进行iframe的DOM操作
推荐漂亮的一款WordPress新年插件
检查nginx配置，重载配置以及重启的方法
留言板美化结束
推荐六个在线制作Loading图标的网站
利用百度ping服务API加快文章收录，秒收不是梦


© 三水清 for 三水清, 2012. &#124;
One comment &#124;在微博关注我：@清-三水清
收藏到：
人人网 &#124; 豆瓣 &#124; 开心网 &#124; QQ书签 &#124; 新浪微博 &#124; 腾讯微博

Post tags: addEventListener, javascript
<table class="wumii-related-items" cellspacing="0" cellpadding="3" border="0"  style="clear: both;">
    
    <tr>
        <td colspan="4"><b><font size="-1"  style="display: block !important; padding: 20px 0 5px !important;">猜你喜欢：</font></b></td>
    </tr>
    
        <tr>
                <td width="102" valign="top" style="padding: 5px !important; margin: 0 !important;">
                    <a target="_blank" title="非字母javascript" style="text-decoration: none !important; cursor: pointer !important;" href="http://app.wumii.com/ext/redirect?url=http%3A%2F%2Fjs8.in%2F918.html&from=http%3A%2F%2Fjs8.in%2F983.html">
                        <img style="margin: 0 !important; padding: 2px !important; border: 1px solid #DDDDDD !important; width: 96px !important; height: 96px !important;" src="http://static.wumii.com/site_images/2011/11/30/11698517.jpg" width="96px" height="96px" /><br />
                        <font size="-1" color="#333333" style="display: block !important; line-height: 15px !important; width: 102px !important; font: 12px/15px arial !important; height: 60px !important; margin: 3px 0 0 0 !important; padding: 0 !important; overflow: hidden !important;">非字母javascript</font>
                    </a>
                </td>
                <td width="102" valign="top" style="padding: 5px !important; margin: 0 !important; border-left: 1px solid #DDDDDD !important;">
                    <a target="_blank" title="通过javascript实现整站黑白效果" style="text-decoration: none !important; cursor: pointer !important;" href="http://app.wumii.com/ext/redirect?url=http%3A%2F%2Fjs8.in%2F529.html&from=http%3A%2F%2Fjs8.in%2F983.html">
                        <img style="margin: 0 !important; padding: 2px !important; border: 1px solid #DDDDDD !important; width: 96px !important; height: 96px !important;" src="http://static.wumii.com/site_images/2011/11/18/10979192.gif" width="96px" height="96px" /><br />
                        <font size="-1" color="#333333" style="display: block !important; line-height: 15px !important; width: 102px !important; font: 12px/15px arial !important; height: 60px !important; margin: 3px 0 0 0 !important; padding: 0 !important; overflow: hidden !important;">通过javascript实现整站黑白效果</font>
                    </a>
                </td>
                <td width="102" valign="top" style="padding: 5px !important; margin: 0 !important; border-left: 1px solid #DDDDDD !important;">
                    <a target="_blank" title="Javascript正则表达式详解" style="text-decoration: none !important; cursor: pointer !important;" href="http://app.wumii.com/ext/redirect?url=http%3A%2F%2Fjs8.in%2F473.html&from=http%3A%2F%2Fjs8.in%2F983.html">
                        <img style="margin: 0 !important; padding: 2px !important; border: 1px solid #DDDDDD !important; width: 96px !important; height: 96px !important;" src="http://static.wumii.com/site_images/2012/02/06/14873015.jpg" width="96px" height="96px" /><br />
                        <font size="-1" color="#333333" style="display: block !important; line-height: 15px !important; width: 102px !important; font: 12px/15px arial !important; height: 60px !important; margin: 3px 0 0 0 !important; padding: 0 !important; overflow: hidden !important;">Javascript正则表达式详解</font>
                    </a>
                </td>
                <td width="102" valign="top" style="padding: 5px !important; margin: 0 !important; border-left: 1px solid #DDDDDD !important;">
                    <a target="_blank" title="Javascript设置光标位置到结尾并显示出来" style="text-decoration: none !important; cursor: pointer !important;" href="http://app.wumii.com/ext/redirect?url=http%3A%2F%2Fjs8.in%2F467.html&from=http%3A%2F%2Fjs8.in%2F983.html">
                        <img style="margin: 0 !important; padding: 2px !important; border: 1px solid #DDDDDD !important; width: 96px !important; height: 96px !important;" src="http://static.wumii.com/site_images/2011/11/18/11027176.jpg" width="96px" height="96px" /><br />
                        <font size="-1" color="#333333" style="display: block !important; line-height: 15px !important; width: 102px !important; font: 12px/15px arial !important; height: 60px !important; margin: 3px 0 0 0 !important; padding: 0 !important; overflow: hidden !important;">Javascript设置光标位置到结尾并显示出来</font>
                    </a>
                </td>
        </tr>
    
    <tr>
        <td colspan="4" align="right">
            <a style="text-decoration: none !important;" href="http://www.wumii.com/widget/relatedItems" target="_blank" title="无觅相关文章插件">
                <font size="-1" color="#bbbbbb" style="display: block !important; font-family: arial !important; padding: 5px 0 !important; font-size: 12px !important; color: #bbb !important;">无觅</font>
            </a>
        </td>
    </tr>
</table>]]></description>
			<content:encoded><![CDATA[<p>昨天无意中看到一篇<a target="_blank" href="http://peter.michaux.ca/articles/our-backwards-dom-event-libraries" target="_blank">老外的文章</a>，文章提到了<strong>addEventListener</strong>第二个参数可以传入object，并且对象中handleEvent为事件处理函数。例如下面的javascript代码：</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #003366; font-weight: bold;">var</span> obj <span style="color: #339933;">=</span> <span style="color: #009900;">&#123;</span>
	handleEvent<span style="color: #339933;">:</span> <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
		<span style="color: #000066;">alert</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'body clicked'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span><span style="color: #339933;">;</span>
document.<span style="color: #660066;">body</span>.<span style="color: #660066;">addEventListener</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'click'</span><span style="color: #339933;">,</span>obj<span style="color: #339933;">,</span><span style="color: #003366; font-weight: bold;">false</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p>测试发现这段代码在IE9+，chrome，FF，opera等浏览器是正确的（测试范围可能不够宽），而且可以成功的绑定click事件。在Qwrap群里一问才知道是<a target="_blank" href="http://www.w3.org/TR/DOM-Level-2-Events/events.html#Events-EventListener" target="_blank">DOM2中接口</a>，很有意思的一个发现，<a target="_blank" href="http://weibo.com/itapir" target="_blank">@貘大大</a> 也发微博说自己先入为主了，我相信很多人跟<a target="_blank" href="http://weibo.com/itapir" target="_blank">@貘大大</a> 一样都先入为主了。</p>
<h2>addEventListener的handleEvent应用</h2>
<p>发现了这个“新大陆”有什么用法呢？哈哈~首先想到的是<a href="http://js8.in/736.html" target="_blank">对象引用</a>。看下面的javascript代码：</p>

<div class="wp_syntax"><div class="code"><pre class="html" style="font-family:monospace;">&lt;script type=&quot;text/javascript&quot;&gt;
var obj = {
handleEvent: function() {
	alert('body clicked');
}
};
document.body.addEventListener('click',obj,false);
function fn2(){
	obj.handleEvent = function(){
		alert('fn2');
	};
}
&lt;/script&gt;
&lt;button onclick=&quot;fn2();&quot;&gt;change&lt;/button&gt;</pre></div></div>

<p>因为对象的引用关系，点击下button就可以切换绑定事件的处理函数，而不需要remove之前的事件，然后重新绑定一个新的处理函数。<br />
<span id="more-983"></span><br />
如果你觉得这个不够炫，那么下面的javascript代码可能就更有吸引力了哦~</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #003366; font-weight: bold;">var</span> obj2 <span style="color: #339933;">=</span> <span style="color: #009900;">&#123;</span>
	addEvent<span style="color: #339933;">:</span><span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span>el<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
		el.<span style="color: #660066;">addEventListener</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'click'</span><span style="color: #339933;">,</span><span style="color: #000066; font-weight: bold;">this</span><span style="color: #339933;">,</span><span style="color: #003366; font-weight: bold;">false</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span><span style="color: #339933;">,</span>
	handleEvent<span style="color: #339933;">:</span><span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span>e<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
		<span style="color: #000066;">alert</span><span style="color: #009900;">&#40;</span>e.<span style="color: #660066;">target</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span><span style="color: #339933;">;</span>
obj2.<span style="color: #660066;">addEvent</span><span style="color: #009900;">&#40;</span>document.<span style="color: #660066;">body</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<h2>addEventListener handleEvent缺点</h2>
<p>显而易见，IE6~IE8不能使用……可是如果是高级浏览器还是不错的功能哦~</p>
<h3>扩展阅读</h3>
<p>http://peter.michaux.ca/articles/our-backwards-dom-event-libraries<br />
http://ajaxian.com/archives/an-alternative-way-to-addeventlistener
<div class="copyright">
<strong>声明：</strong>文章未声明为原创文章，本文链接 <a href="http://js8.in/983.html" title="addEventListener第二个参数的handleEvent">http://js8.in/983.html</a>. 转载请注明转自<a href="http://js8.in" title="前端开发博客"> JS8.IN ™</a></span></span></div>
<h3 class="box-title">随机文章</h3>
<ul class="box_random">
<li><a href="http://js8.in/529.html" title="通过javascript实现整站黑白效果" rel="bookmark inlinks">通过javascript实现整站黑白效果</a></li>
<li><a href="http://js8.in/333.html" title="在普加工作的十个要求" rel="bookmark inlinks">在普加工作的十个要求</a></li>
<li><a href="http://js8.in/267.html" title="新功能-QQ秀上线" rel="bookmark inlinks">新功能-QQ秀上线</a></li>
<li><a href="http://js8.in/366.html" title="设置htaccess应该注意的问题" rel="bookmark inlinks">设置htaccess应该注意的问题</a></li>
<li><a href="http://js8.in/341.html" title="chrome字体最小值12px问题及解决方法" rel="bookmark inlinks">chrome字体最小值12px问题及解决方法</a></li>
<li><a href="http://js8.in/29.html" title="08.11.13" rel="bookmark inlinks">08.11.13</a></li>
<li><a href="http://js8.in/537.html" title="承接企业网站建设，企业建站工作" rel="bookmark inlinks">承接企业网站建设，企业建站工作</a></li>
<li><a href="http://js8.in/466.html" title="javascript获取光标位置以及设置光标位置" rel="bookmark inlinks">javascript获取光标位置以及设置光标位置</a></li>
</ul>
<hr />
<p><small>© 三水清 for <a href="http://js8.in">三水清</a>, 2012. |
<a href="http://js8.in/983.html#comments">One comment</a> |在微博关注我：<a href="//weibo.com/sanshuiqing" target="_blank" title="关注断桥残雪的新浪微博">@清-三水清</a>
<br/>收藏到：
<a rel="nofollow" href="http://share.renren.com/share/buttonshare.do?link=%posturl%&title=%posttitle%" title="收藏本文到人人网" target="_blank">人人网</a> | <a rel="nofollow" href="http://www.douban.com/recommend/?url=%posturl%&title=%posttitle%" title="收藏本文到豆瓣" target="_blank">豆瓣</a> | <a rel="nofollow" href="http://www.kaixin001.com/repaste/share.php?rtitle=%posttitle%&rurl=%posturl%" title="收藏本文到开心网" target="_blank">开心网</a> | <a rel="nofollow" href="http://shuqian.qq.com/post?title=%posttitle%&%20uri=%posturl%" title="收藏本文到QQ书签" target="_blank">QQ书签</a> | <a rel="nofollow" href="http://v.t.sina.com.cn/share/share.php?url=%posturl%&title=%posttitle%" title="收藏本文到新浪微博" target="_blank">新浪微博</a> | <a rel="nofollow" href="http://v.t.qq.com/share/share.php?title=%posttitle%&url=%posturl%&site=http://www.kaixin100.info" title="收藏本文到腾讯微博" target="_blank">腾讯微博</a>
<br/>
Post tags: <a href="http://js8.in/tag/addeventlistener" rel="tag">addEventListener</a>, <a href="http://js8.in/tag/javascript" rel="tag">javascript</a><br/>
</small></p><table class="wumii-related-items" cellspacing="0" cellpadding="3" border="0"  style="clear: both;">
    
    <tr>
        <td colspan="4"><b><font size="-1"  style="display: block !important; padding: 20px 0 5px !important;">猜你喜欢：</font></b></td>
    </tr>
    
        <tr>
                <td width="102" valign="top" style="padding: 5px !important; margin: 0 !important;">
                    <a target="_blank" title="非字母javascript" style="text-decoration: none !important; cursor: pointer !important;" href="http://app.wumii.com/ext/redirect?url=http%3A%2F%2Fjs8.in%2F918.html&from=http%3A%2F%2Fjs8.in%2F983.html">
                        <img style="margin: 0 !important; padding: 2px !important; border: 1px solid #DDDDDD !important; width: 96px !important; height: 96px !important;" src="http://static.wumii.com/site_images/2011/11/30/11698517.jpg" width="96px" height="96px" /><br />
                        <font size="-1" color="#333333" style="display: block !important; line-height: 15px !important; width: 102px !important; font: 12px/15px arial !important; height: 60px !important; margin: 3px 0 0 0 !important; padding: 0 !important; overflow: hidden !important;">非字母javascript</font>
                    </a>
                </td>
                <td width="102" valign="top" style="padding: 5px !important; margin: 0 !important; border-left: 1px solid #DDDDDD !important;">
                    <a target="_blank" title="通过javascript实现整站黑白效果" style="text-decoration: none !important; cursor: pointer !important;" href="http://app.wumii.com/ext/redirect?url=http%3A%2F%2Fjs8.in%2F529.html&from=http%3A%2F%2Fjs8.in%2F983.html">
                        <img style="margin: 0 !important; padding: 2px !important; border: 1px solid #DDDDDD !important; width: 96px !important; height: 96px !important;" src="http://static.wumii.com/site_images/2011/11/18/10979192.gif" width="96px" height="96px" /><br />
                        <font size="-1" color="#333333" style="display: block !important; line-height: 15px !important; width: 102px !important; font: 12px/15px arial !important; height: 60px !important; margin: 3px 0 0 0 !important; padding: 0 !important; overflow: hidden !important;">通过javascript实现整站黑白效果</font>
                    </a>
                </td>
                <td width="102" valign="top" style="padding: 5px !important; margin: 0 !important; border-left: 1px solid #DDDDDD !important;">
                    <a target="_blank" title="Javascript正则表达式详解" style="text-decoration: none !important; cursor: pointer !important;" href="http://app.wumii.com/ext/redirect?url=http%3A%2F%2Fjs8.in%2F473.html&from=http%3A%2F%2Fjs8.in%2F983.html">
                        <img style="margin: 0 !important; padding: 2px !important; border: 1px solid #DDDDDD !important; width: 96px !important; height: 96px !important;" src="http://static.wumii.com/site_images/2012/02/06/14873015.jpg" width="96px" height="96px" /><br />
                        <font size="-1" color="#333333" style="display: block !important; line-height: 15px !important; width: 102px !important; font: 12px/15px arial !important; height: 60px !important; margin: 3px 0 0 0 !important; padding: 0 !important; overflow: hidden !important;">Javascript正则表达式详解</font>
                    </a>
                </td>
                <td width="102" valign="top" style="padding: 5px !important; margin: 0 !important; border-left: 1px solid #DDDDDD !important;">
                    <a target="_blank" title="Javascript设置光标位置到结尾并显示出来" style="text-decoration: none !important; cursor: pointer !important;" href="http://app.wumii.com/ext/redirect?url=http%3A%2F%2Fjs8.in%2F467.html&from=http%3A%2F%2Fjs8.in%2F983.html">
                        <img style="margin: 0 !important; padding: 2px !important; border: 1px solid #DDDDDD !important; width: 96px !important; height: 96px !important;" src="http://static.wumii.com/site_images/2011/11/18/11027176.jpg" width="96px" height="96px" /><br />
                        <font size="-1" color="#333333" style="display: block !important; line-height: 15px !important; width: 102px !important; font: 12px/15px arial !important; height: 60px !important; margin: 3px 0 0 0 !important; padding: 0 !important; overflow: hidden !important;">Javascript设置光标位置到结尾并显示出来</font>
                    </a>
                </td>
        </tr>
    
    <tr>
        <td colspan="4" align="right">
            <a style="text-decoration: none !important;" href="http://www.wumii.com/widget/relatedItems" target="_blank" title="无觅相关文章插件">
                <font size="-1" color="#bbbbbb" style="display: block !important; font-family: arial !important; padding: 5px 0 !important; font-size: 12px !important; color: #bbb !important;">无觅</font>
            </a>
        </td>
    </tr>
</table>]]></content:encoded>
			<wfw:commentRss>http://js8.in/983.html/feed</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>webSlide — PPT演示文档javascript框架</title>
		<link>http://js8.in/974.html</link>
		<comments>http://js8.in/974.html#comments</comments>
		<pubDate>Mon, 27 Feb 2012 03:15:58 +0000</pubDate>
		<dc:creator>三水清</dc:creator>
				<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[网络技术]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[PPT]]></category>
		<category><![CDATA[webSlide]]></category>

		<guid isPermaLink="false">http://js8.in/?p=974</guid>
		<description><![CDATA[互联网公司内部难免会有些技术分享之类的活动，需要用到PPT，前端开发工程师都喜欢自己的PPT帅一点，当然我也一样。于是开始用impress.js做PPT，所以有了上一篇PPT《XSS注入和防范》。不过在用的过程中发现impress.js性能有问题，假如页面太多，或者图片太多，就会出现卡的现象。于是开始琢磨自己写个javascript演示文档框架。嗯，于是webSlide就诞生了！
webSlide是用于在线PPT演示文档的javascript框架
鸣谢
webSlide的想法来自于impress.js，但是本人在使用过程中发现impress.js经常卡，尤其是当演示文档页面和图片比较多之时，经常出现动画效果不流畅。
写webSlide代码过程中，研究过impress.js和reveal.js，向两位作者表示感谢。
演示页面
演示页面地址http://ksky521.github.com/webSlide/，由于页面比较多，所以需要一定的加载时间。
国内可以访问SAE上的演示页面：http://qdemo.sinaapp.com/ppt/udc.htm。
演示页面内容为给公司UDC部门同事进行javascript入门培训的内容~
说明
因为是PPT演示文档，所以需要投影仪分辨率，所以演示页面的最佳分辨率为全屏模式下的 1024*768 ，如果在自己电脑上查看，可以通过 ctrl + - 和 ctrl + + 缩放到合适的比例查看效果。
建议浏览器chrome 16+，全屏模式（F11），以达到最佳动画效果。在Firefox下会出现拖尾现象，个人认为是Firefox 8下对CSS3动画效果渲染太慢导致，其他浏览器未测试。

使用示例
wSlide({
    slideId:'slide',//演示文档id
    canvasId:'myCanvas',//画板id
    ctrlId:'slideCtrl'//控制部分id
});

参数说明


slideId: 演示文档内容部分ID，class为step为每页，slide为带边框的页面，必填
canvasId: canvas元素画板部分ID，选填
ctrlId: 控制部分ID，class为home代表返回首页，class为paint开启画板，class为clearIt清除画板，选填
presentClass: 当前幻灯片class，选填，默认为present
pastClass: 上一页幻灯片class，选填，默认为past
futureClass: 下一页幻灯片class，选填，默认为future


快捷键

空格/→/↓/Tab/pageDown：下一页
←/↑/pageUp：上一页
P：开画板
C：清除画板

版本库地址
支持三种访问协议：

HTTP协议： https://ksky521@github.com/ksky521/webSlide.git 。
Git协议： git://github.com/ksky521/webSlide.git 。
SSH协议： ssh://git@github.com:ksky521/webSlide.git 。

克隆版本库
操作示例：
$ git clone git://github.com/ksky521/webSlide.git

联系方式
作者博客：js8.in
作者新浪微博：@三水清

声明：文章未声明为原创文章，本文链接 http://js8.in/974.html. 转载请注明转自 JS8.IN ™
随机文章

使用ZeroClipboard解决跨浏览器复制到剪贴板的问题
提供一个免费支持Jabber, AIM, MSN, Yahoo, Gtalk,Twitter 机器人
jQuery 1.4的十五大新功能实例精讲
google黑板报澄清退出中国的不实传言
生日party
javascript作用域和作用域链
音乐版上线
08.11.19


© 三水清 for 三水清, 2012. &#124;
6 comments &#124;在微博关注我：@清-三水清
收藏到：
人人网 &#124; 豆瓣 &#124; 开心网 [...]<table class="wumii-related-items" cellspacing="0" cellpadding="3" border="0"  style="clear: both;">
    
    <tr>
        <td colspan="4"><b><font size="-1"  style="display: block !important; padding: 20px 0 5px !important;">猜你喜欢：</font></b></td>
    </tr>
    
        <tr>
                <td width="102" valign="top" style="padding: 5px !important; margin: 0 !important;">
                    <a target="_blank" title="javascript入门到高级PPT" style="text-decoration: none !important; cursor: pointer !important;" href="http://app.wumii.com/ext/redirect?url=http%3A%2F%2Fjs8.in%2F750.html&from=http%3A%2F%2Fjs8.in%2F974.html">
                        <img style="margin: 0 !important; padding: 2px !important; border: 1px solid #DDDDDD !important; width: 96px !important; height: 96px !important;" src="http://static.wumii.com/site_images/2011/11/17/10979311.jpg" width="96px" height="96px" /><br />
                        <font size="-1" color="#333333" style="display: block !important; line-height: 15px !important; width: 102px !important; font: 12px/15px arial !important; height: 60px !important; margin: 3px 0 0 0 !important; padding: 0 !important; overflow: hidden !important;">javascript入门到高级PPT</font>
                    </a>
                </td>
                <td width="102" valign="top" style="padding: 5px !important; margin: 0 !important; border-left: 1px solid #DDDDDD !important;">
                    <a target="_blank" title="nodePPT — nodejs做的手机端控制PC端的PPT演示文档javascript框架" style="text-decoration: none !important; cursor: pointer !important;" href="http://app.wumii.com/ext/redirect?url=http%3A%2F%2Fjs8.in%2F989.html&from=http%3A%2F%2Fjs8.in%2F974.html">
                        <img style="margin: 0 !important; padding: 2px !important; border: 1px solid #DDDDDD !important; width: 96px !important; height: 96px !important;" src="http://static.wumii.com/site_images/2012/04/21/21201860.jpg" width="96px" height="96px" /><br />
                        <font size="-1" color="#333333" style="display: block !important; line-height: 15px !important; width: 102px !important; font: 12px/15px arial !important; height: 60px !important; margin: 3px 0 0 0 !important; padding: 0 !important; overflow: hidden !important;">nodePPT — nodejs做的手机端控制PC端的PPT演示文档javascript框架</font>
                    </a>
                </td>
                <td width="102" valign="top" style="padding: 5px !important; margin: 0 !important; border-left: 1px solid #DDDDDD !important;">
                    <a target="_blank" title="非字母javascript" style="text-decoration: none !important; cursor: pointer !important;" href="http://app.wumii.com/ext/redirect?url=http%3A%2F%2Fjs8.in%2F918.html&from=http%3A%2F%2Fjs8.in%2F974.html">
                        <img style="margin: 0 !important; padding: 2px !important; border: 1px solid #DDDDDD !important; width: 96px !important; height: 96px !important;" src="http://static.wumii.com/site_images/2011/11/30/11698517.jpg" width="96px" height="96px" /><br />
                        <font size="-1" color="#333333" style="display: block !important; line-height: 15px !important; width: 102px !important; font: 12px/15px arial !important; height: 60px !important; margin: 3px 0 0 0 !important; padding: 0 !important; overflow: hidden !important;">非字母javascript</font>
                    </a>
                </td>
                <td width="102" valign="top" style="padding: 5px !important; margin: 0 !important; border-left: 1px solid #DDDDDD !important;">
                    <a target="_blank" title="javascript获取光标位置以及设置光标位置" style="text-decoration: none !important; cursor: pointer !important;" href="http://app.wumii.com/ext/redirect?url=http%3A%2F%2Fjs8.in%2F466.html&from=http%3A%2F%2Fjs8.in%2F974.html">
                        <img style="margin: 0 !important; padding: 2px !important; border: 1px solid #DDDDDD !important; width: 96px !important; height: 96px !important;" src="http://static.wumii.com/site_images/2011/11/17/10979320.jpg" width="96px" height="96px" /><br />
                        <font size="-1" color="#333333" style="display: block !important; line-height: 15px !important; width: 102px !important; font: 12px/15px arial !important; height: 60px !important; margin: 3px 0 0 0 !important; padding: 0 !important; overflow: hidden !important;">javascript获取光标位置以及设置光标位置</font>
                    </a>
                </td>
        </tr>
    
    <tr>
        <td colspan="4" align="right">
            <a style="text-decoration: none !important;" href="http://www.wumii.com/widget/relatedItems" target="_blank" title="无觅相关文章插件">
                <font size="-1" color="#bbbbbb" style="display: block !important; font-family: arial !important; padding: 5px 0 !important; font-size: 12px !important; color: #bbb !important;">无觅</font>
            </a>
        </td>
    </tr>
</table>]]></description>
			<content:encoded><![CDATA[<p>互联网公司内部难免会有些技术分享之类的活动，需要用到PPT，<strong>前端开发</strong>工程师都喜欢自己的PPT帅一点，当然我也一样。于是开始用impress.js做PPT，所以有了上一篇PPT《<a target="_blank" href="http://js8.in/951.html" target="_blank">XSS注入和防范</a>》。不过在用的过程中发现impress.js性能有问题，假如页面太多，或者图片太多，就会出现卡的现象。于是开始琢磨自己写个javascript演示文档框架。嗯，于是<a href="https://github.com/ksky521/webSlide" target="_blank">webSlide</a>就诞生了！</p>
<p><a target="_blank" style="border-image: initial; font: inherit; color: #4183c4; text-decoration: none; font-family: Helvetica, arial, freesans, clean, sans-serif; line-height: 22px; padding: 0px; margin: 0px; border: 0px initial initial;" href="https://github.com/ksky521/webSlide">webSlide</a><span style="color: #333333; font-family: Helvetica, arial, freesans, clean, sans-serif; font-size: 14px; line-height: 22px;">是用于在线PPT演示文档的javascript框架</span></p>
<h2 style="margin-top: 20px; margin-right: 0px; margin-bottom: 10px; margin-left: 0px; border-top-width: 0px; border-right-width: 0px; border-bottom-width: 1px; border-left-width: 0px; border-style: initial; border-color: initial; border-image: initial; font: inherit; -webkit-font-smoothing: antialiased; border-bottom-style: solid; border-bottom-color: #cccccc; font-family: Helvetica, arial, freesans, clean, sans-serif; padding: 0px;">鸣谢</h2>
<p style="margin-top: 0px; margin-right: 0px; margin-bottom: 15px; margin-left: 0px; border-image: initial; font: inherit; color: #333333; font-family: Helvetica, arial, freesans, clean, sans-serif; line-height: 22px; padding: 0px; border: 0px initial initial;">webSlide的想法来自于impress.js，但是本人在使用过程中发现impress.js经常卡，尤其是当演示文档页面和图片比较多之时，经常出现动画效果不流畅。</p>
<p style="margin-top: 15px; margin-right: 0px; margin-bottom: 15px; margin-left: 0px; border-image: initial; font: inherit; color: #333333; font-family: Helvetica, arial, freesans, clean, sans-serif; line-height: 22px; padding: 0px; border: 0px initial initial;">写webSlide代码过程中，研究过<a target="_blank" style="border-image: initial; font-size: 14px; font: inherit; color: #4183c4; text-decoration: none; padding: 0px; margin: 0px; border: 0px initial initial;" href="http://bartaz.github.com/impress.js">impress.js</a>和<a target="_blank" style="border-image: initial; font-size: 14px; font: inherit; color: #4183c4; text-decoration: none; padding: 0px; margin: 0px; border: 0px initial initial;" href="http://lab.hakim.se/reveal-js/">reveal.js</a>，向两位作者表示感谢。</p>
<h2 style="margin-top: 20px; margin-right: 0px; margin-bottom: 10px; margin-left: 0px; border-top-width: 0px; border-right-width: 0px; border-bottom-width: 1px; border-left-width: 0px; border-style: initial; border-color: initial; border-image: initial; font: inherit; -webkit-font-smoothing: antialiased; border-bottom-style: solid; border-bottom-color: #cccccc; font-family: Helvetica, arial, freesans, clean, sans-serif; padding: 0px;">演示页面</h2>
<p style="margin-top: 0px; margin-right: 0px; margin-bottom: 15px; margin-left: 0px; border-image: initial; font: inherit; color: #333333; font-family: Helvetica, arial, freesans, clean, sans-serif; line-height: 22px; padding: 0px; border: 0px initial initial;">演示页面地址<a target="_blank" style="border-image: initial; font-size: 14px; font: inherit; color: #4183c4; text-decoration: none; padding: 0px; margin: 0px; border: 0px initial initial;" href="http://ksky521.github.com/webSlide/"></a><a target="_blank" style="border-image: initial; font-size: 14px; font: inherit; color: #4183c4; text-decoration: none; padding: 0px; margin: 0px; border: 0px initial initial;" href="http://ksky521.github.com/webSlide/">http://ksky521.github.com/webSlide/</a>，由于页面比较多，所以需要一定的加载时间。</p>
<p style="margin-top: 15px; margin-right: 0px; margin-bottom: 15px; margin-left: 0px; border-image: initial; font: inherit; color: #333333; font-family: Helvetica, arial, freesans, clean, sans-serif; line-height: 22px; padding: 0px; border: 0px initial initial;">国内可以访问SAE上的演示页面：<a target="_blank" style="border-image: initial; font-size: 14px; font: inherit; color: #4183c4; text-decoration: none; padding: 0px; margin: 0px; border: 0px initial initial;" href="http://qdemo.sinaapp.com/ppt/udc.htm"></a><a target="_blank" style="border-image: initial; font-size: 14px; font: inherit; color: #4183c4; text-decoration: none; padding: 0px; margin: 0px; border: 0px initial initial;" href="http://qdemo.sinaapp.com/ppt/udc.htm">http://qdemo.sinaapp.com/ppt/udc.htm</a>。</p>
<p style="margin-top: 15px; margin-right: 0px; margin-bottom: 15px; margin-left: 0px; border-image: initial; font: inherit; color: #333333; font-family: Helvetica, arial, freesans, clean, sans-serif; line-height: 22px; padding: 0px; border: 0px initial initial;">演示页面内容为给公司UDC部门同事进行javascript入门培训的内容~</p>
<h2 style="margin-top: 20px; margin-right: 0px; margin-bottom: 10px; margin-left: 0px; border-top-width: 0px; border-right-width: 0px; border-bottom-width: 1px; border-left-width: 0px; border-style: initial; border-color: initial; border-image: initial; font: inherit; -webkit-font-smoothing: antialiased; border-bottom-style: solid; border-bottom-color: #cccccc; font-family: Helvetica, arial, freesans, clean, sans-serif; padding: 0px;">说明</h2>
<p style="margin-top: 0px; margin-right: 0px; margin-bottom: 15px; margin-left: 0px; border-image: initial; font: inherit; color: #333333; font-family: Helvetica, arial, freesans, clean, sans-serif; line-height: 22px; padding: 0px; border: 0px initial initial;">因为是PPT演示文档，所以需要投影仪分辨率，所以演示页面的最佳分辨率为全屏模式下的 <code style="margin-top: 0px; margin-right: 2px; margin-bottom: 0px; margin-left: 2px; padding-top: 0px; padding-right: 5px; padding-bottom: 0px; padding-left: 5px; border-image: initial; font: inherit; font-family: 'Bitstream Vera Sans Mono', Courier, monospace; line-height: normal; white-space: nowrap; background-color: #f8f8f8; border-top-left-radius: 3px; border-top-right-radius: 3px; border-bottom-right-radius: 3px; border-bottom-left-radius: 3px; border: 1px solid #eaeaea;">1024*768</code> ，如果在自己电脑上查看，可以通过 <code style="margin-top: 0px; margin-right: 2px; margin-bottom: 0px; margin-left: 2px; padding-top: 0px; padding-right: 5px; padding-bottom: 0px; padding-left: 5px; border-image: initial; font: inherit; font-family: 'Bitstream Vera Sans Mono', Courier, monospace; line-height: normal; white-space: nowrap; background-color: #f8f8f8; border-top-left-radius: 3px; border-top-right-radius: 3px; border-bottom-right-radius: 3px; border-bottom-left-radius: 3px; border: 1px solid #eaeaea;">ctrl + -</code> 和 <code style="margin-top: 0px; margin-right: 2px; margin-bottom: 0px; margin-left: 2px; padding-top: 0px; padding-right: 5px; padding-bottom: 0px; padding-left: 5px; border-image: initial; font: inherit; font-family: 'Bitstream Vera Sans Mono', Courier, monospace; line-height: normal; white-space: nowrap; background-color: #f8f8f8; border-top-left-radius: 3px; border-top-right-radius: 3px; border-bottom-right-radius: 3px; border-bottom-left-radius: 3px; border: 1px solid #eaeaea;">ctrl + +</code> 缩放到合适的比例查看效果。</p>
<p style="margin-top: 15px; margin-right: 0px; margin-bottom: 15px; margin-left: 0px; border-image: initial; font: inherit; color: #333333; font-family: Helvetica, arial, freesans, clean, sans-serif; line-height: 22px; padding: 0px; border: 0px initial initial;">建议浏览器chrome 16+，全屏模式（F11），以达到最佳动画效果。在Firefox下会出现拖尾现象，个人认为是Firefox 8下对CSS3动画效果渲染太慢导致，其他浏览器未测试。</p>
<p><span id="more-974"></span></p>
<h2 style="margin-top: 20px; margin-right: 0px; margin-bottom: 10px; margin-left: 0px; border-top-width: 0px; border-right-width: 0px; border-bottom-width: 1px; border-left-width: 0px; border-style: initial; border-color: initial; border-image: initial; font: inherit; -webkit-font-smoothing: antialiased; border-bottom-style: solid; border-bottom-color: #cccccc; font-family: Helvetica, arial, freesans, clean, sans-serif; padding: 0px;">使用示例</h2>
<pre style="margin-top: 15px; margin-bottom: 15px; padding-top: 6px; padding-right: 10px; padding-bottom: 6px; padding-left: 10px; border-image: initial; font: inherit; font-family: 'Bitstream Vera Sans Mono', Courier, monospace; line-height: 19px; overflow-x: auto; overflow-y: auto; border-top-left-radius: 3px; border-top-right-radius: 3px; border-bottom-right-radius: 3px; border-bottom-left-radius: 3px; color: #333333; border: 1px solid #cccccc;"><code style="border-image: initial; font: inherit; font-family: 'Bitstream Vera Sans Mono', Courier, monospace; line-height: normal; background-color: transparent; border-top-left-radius: 3px; border-top-right-radius: 3px; border-bottom-right-radius: 3px; border-bottom-left-radius: 3px; background-image: initial; background-attachment: initial; background-origin: initial; background-clip: initial; padding: 0px; margin: 0px; border: initial none initial;">wSlide({
    slideId:'slide',//演示文档id
    canvasId:'myCanvas',//画板id
    ctrlId:'slideCtrl'//控制部分id
});
</code></pre>
<h4 style="margin-top: 20px; margin-right: 0px; margin-bottom: 10px; margin-left: 0px; border-image: initial; font: inherit; -webkit-font-smoothing: antialiased; color: #333333; font-family: Helvetica, arial, freesans, clean, sans-serif; padding: 0px; border: 0px initial initial;">参数说明</h4>
<blockquote style="margin-top: 15px; margin-right: 0px; margin-bottom: 15px; margin-left: 0px; padding-top: 0px; padding-right: 15px; padding-bottom: 0px; padding-left: 15px; border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 4px; border-style: initial; border-color: initial; border-image: initial; font: inherit; quotes: none; border-left-style: solid; border-left-color: #dddddd; color: #777777; font-family: Helvetica, arial, freesans, clean, sans-serif; line-height: 22px;">
<ul style="padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 30px; border-image: initial; font-size: 14px; font: inherit; margin: 0px; border: 0px initial initial;">
<li style="margin-top: 15px; margin-right: 0px; margin-bottom: 15px; margin-left: 0px; border-image: initial; font-size: 14px; font: inherit; padding: 0px; border: 0px initial initial;">slideId: 演示文档内容部分ID，class为step为每页，slide为带边框的页面，<strong style="border-image: initial; font-size: 14px; font: inherit; font-weight: bold; padding: 0px; margin: 0px; border: 0px initial initial;">必填</strong></li>
<li style="margin-top: 15px; margin-right: 0px; margin-bottom: 15px; margin-left: 0px; border-image: initial; font-size: 14px; font: inherit; padding: 0px; border: 0px initial initial;">canvasId: canvas元素画板部分ID，<strong style="border-image: initial; font-size: 14px; font: inherit; font-weight: bold; padding: 0px; margin: 0px; border: 0px initial initial;">选填</strong></li>
<li style="margin-top: 15px; margin-right: 0px; margin-bottom: 15px; margin-left: 0px; border-image: initial; font-size: 14px; font: inherit; padding: 0px; border: 0px initial initial;">ctrlId: 控制部分ID，class为home代表返回首页，class为paint开启画板，class为clearIt清除画板，<strong style="border-image: initial; font-size: 14px; font: inherit; font-weight: bold; padding: 0px; margin: 0px; border: 0px initial initial;">选填</strong></li>
<li style="margin-top: 15px; margin-right: 0px; margin-bottom: 15px; margin-left: 0px; border-image: initial; font-size: 14px; font: inherit; padding: 0px; border: 0px initial initial;">presentClass: 当前幻灯片class，<strong style="border-image: initial; font-size: 14px; font: inherit; font-weight: bold; padding: 0px; margin: 0px; border: 0px initial initial;">选填，默认为present</strong></li>
<li style="margin-top: 15px; margin-right: 0px; margin-bottom: 15px; margin-left: 0px; border-image: initial; font-size: 14px; font: inherit; padding: 0px; border: 0px initial initial;">pastClass: 上一页幻灯片class，<strong style="border-image: initial; font-size: 14px; font: inherit; font-weight: bold; padding: 0px; margin: 0px; border: 0px initial initial;">选填，默认为past</strong></li>
<li style="margin-top: 15px; margin-right: 0px; margin-bottom: 15px; margin-left: 0px; border-image: initial; font-size: 14px; font: inherit; padding: 0px; border: 0px initial initial;">futureClass: 下一页幻灯片class，<strong style="border-image: initial; font-size: 14px; font: inherit; font-weight: bold; padding: 0px; margin: 0px; border: 0px initial initial;">选填，默认为future</strong></li>
</ul>
</blockquote>
<h2 style="margin-top: 20px; margin-right: 0px; margin-bottom: 10px; margin-left: 0px; border-top-width: 0px; border-right-width: 0px; border-bottom-width: 1px; border-left-width: 0px; border-style: initial; border-color: initial; border-image: initial; font: inherit; -webkit-font-smoothing: antialiased; border-bottom-style: solid; border-bottom-color: #cccccc; font-family: Helvetica, arial, freesans, clean, sans-serif; padding: 0px;">快捷键</h2>
<ul style="margin-top: 15px; margin-right: 0px; margin-bottom: 15px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 30px; border-image: initial; font: inherit; color: #333333; font-family: Helvetica, arial, freesans, clean, sans-serif; line-height: 22px; border: 0px initial initial;">
<li style="margin-top: 15px; margin-right: 0px; margin-bottom: 15px; margin-left: 0px; border-image: initial; font-size: 14px; font: inherit; padding: 0px; border: 0px initial initial;">空格/→/↓/Tab/pageDown：下一页</li>
<li style="margin-top: 15px; margin-right: 0px; margin-bottom: 15px; margin-left: 0px; border-image: initial; font-size: 14px; font: inherit; padding: 0px; border: 0px initial initial;">←/↑/pageUp：上一页</li>
<li style="margin-top: 15px; margin-right: 0px; margin-bottom: 15px; margin-left: 0px; border-image: initial; font-size: 14px; font: inherit; padding: 0px; border: 0px initial initial;">P：开画板</li>
<li style="margin-top: 15px; margin-right: 0px; margin-bottom: 15px; margin-left: 0px; border-image: initial; font-size: 14px; font: inherit; padding: 0px; border: 0px initial initial;">C：清除画板</li>
</ul>
<h2 style="margin-top: 20px; margin-right: 0px; margin-bottom: 10px; margin-left: 0px; border-top-width: 0px; border-right-width: 0px; border-bottom-width: 1px; border-left-width: 0px; border-style: initial; border-color: initial; border-image: initial; font: inherit; -webkit-font-smoothing: antialiased; border-bottom-style: solid; border-bottom-color: #cccccc; font-family: Helvetica, arial, freesans, clean, sans-serif; padding: 0px;">版本库地址</h2>
<p style="margin-top: 0px; margin-right: 0px; margin-bottom: 15px; margin-left: 0px; border-image: initial; font: inherit; color: #333333; font-family: Helvetica, arial, freesans, clean, sans-serif; line-height: 22px; padding: 0px; border: 0px initial initial;">支持三种访问协议：</p>
<ul style="margin-top: 15px; margin-right: 0px; margin-bottom: 15px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 30px; border-image: initial; font: inherit; color: #333333; font-family: Helvetica, arial, freesans, clean, sans-serif; line-height: 22px; border: 0px initial initial;">
<li style="margin-top: 15px; margin-right: 0px; margin-bottom: 15px; margin-left: 0px; border-image: initial; font-size: 14px; font: inherit; padding: 0px; border: 0px initial initial;">HTTP协议： <code style="margin-top: 0px; margin-right: 2px; margin-bottom: 0px; margin-left: 2px; padding-top: 0px; padding-right: 5px; padding-bottom: 0px; padding-left: 5px; border-image: initial; font: inherit; font-family: 'Bitstream Vera Sans Mono', Courier, monospace; line-height: normal; white-space: nowrap; background-color: #f8f8f8; border-top-left-radius: 3px; border-top-right-radius: 3px; border-bottom-right-radius: 3px; border-bottom-left-radius: 3px; border: 1px solid #eaeaea;">https://ksky521@github.com/ksky521/webSlide.git</code> 。</li>
<li style="margin-top: 15px; margin-right: 0px; margin-bottom: 15px; margin-left: 0px; border-image: initial; font-size: 14px; font: inherit; padding: 0px; border: 0px initial initial;">Git协议： <code style="margin-top: 0px; margin-right: 2px; margin-bottom: 0px; margin-left: 2px; padding-top: 0px; padding-right: 5px; padding-bottom: 0px; padding-left: 5px; border-image: initial; font: inherit; font-family: 'Bitstream Vera Sans Mono', Courier, monospace; line-height: normal; white-space: nowrap; background-color: #f8f8f8; border-top-left-radius: 3px; border-top-right-radius: 3px; border-bottom-right-radius: 3px; border-bottom-left-radius: 3px; border: 1px solid #eaeaea;">git://github.com/ksky521/webSlide.git</code> 。</li>
<li style="margin-top: 15px; margin-right: 0px; margin-bottom: 15px; margin-left: 0px; border-image: initial; font-size: 14px; font: inherit; padding: 0px; border: 0px initial initial;">SSH协议： <code style="margin-top: 0px; margin-right: 2px; margin-bottom: 0px; margin-left: 2px; padding-top: 0px; padding-right: 5px; padding-bottom: 0px; padding-left: 5px; border-image: initial; font: inherit; font-family: 'Bitstream Vera Sans Mono', Courier, monospace; line-height: normal; white-space: nowrap; background-color: #f8f8f8; border-top-left-radius: 3px; border-top-right-radius: 3px; border-bottom-right-radius: 3px; border-bottom-left-radius: 3px; border: 1px solid #eaeaea;">ssh://git@github.com:ksky521/webSlide.git</code> 。</li>
</ul>
<h2 style="margin-top: 20px; margin-right: 0px; margin-bottom: 10px; margin-left: 0px; border-top-width: 0px; border-right-width: 0px; border-bottom-width: 1px; border-left-width: 0px; border-style: initial; border-color: initial; border-image: initial; font: inherit; -webkit-font-smoothing: antialiased; border-bottom-style: solid; border-bottom-color: #cccccc; font-family: Helvetica, arial, freesans, clean, sans-serif; padding: 0px;">克隆版本库</h2>
<p style="margin-top: 0px; margin-right: 0px; margin-bottom: 15px; margin-left: 0px; border-image: initial; font: inherit; color: #333333; font-family: Helvetica, arial, freesans, clean, sans-serif; line-height: 22px; padding: 0px; border: 0px initial initial;">操作示例：</p>
<pre style="margin-top: 15px; margin-bottom: 15px; padding-top: 6px; padding-right: 10px; padding-bottom: 6px; padding-left: 10px; border-image: initial; font: inherit; font-family: 'Bitstream Vera Sans Mono', Courier, monospace; line-height: 19px; overflow-x: auto; overflow-y: auto; border-top-left-radius: 3px; border-top-right-radius: 3px; border-bottom-right-radius: 3px; border-bottom-left-radius: 3px; color: #333333; border: 1px solid #cccccc;"><code style="border-image: initial; font: inherit; font-family: 'Bitstream Vera Sans Mono', Courier, monospace; line-height: normal; background-color: transparent; border-top-left-radius: 3px; border-top-right-radius: 3px; border-bottom-right-radius: 3px; border-bottom-left-radius: 3px; background-image: initial; background-attachment: initial; background-origin: initial; background-clip: initial; padding: 0px; margin: 0px; border: initial none initial;">$ git clone git://github.com/ksky521/webSlide.git
</code></pre>
<h2 style="margin-top: 20px; margin-right: 0px; margin-bottom: 10px; margin-left: 0px; border-top-width: 0px; border-right-width: 0px; border-bottom-width: 1px; border-left-width: 0px; border-style: initial; border-color: initial; border-image: initial; font: inherit; -webkit-font-smoothing: antialiased; border-bottom-style: solid; border-bottom-color: #cccccc; font-family: Helvetica, arial, freesans, clean, sans-serif; padding: 0px;">联系方式</h2>
<p style="margin-top: 0px; margin-right: 0px; margin-bottom: 15px; margin-left: 0px; border-image: initial; font: inherit; color: #333333; font-family: Helvetica, arial, freesans, clean, sans-serif; line-height: 22px; padding: 0px; border: 0px initial initial;">作者博客：<a style="border-image: initial; font-size: 14px; font: inherit; color: #4183c4; text-decoration: none; padding: 0px; margin: 0px; border: 0px initial initial;" href="http://js8.in/">js8.in</a></p>
<p style="margin-top: 15px; margin-right: 0px; margin-bottom: 0px !important; margin-left: 0px; border-image: initial; font: inherit; color: #333333; font-family: Helvetica, arial, freesans, clean, sans-serif; line-height: 22px; padding: 0px; border: 0px initial initial;">作者新浪微博：<a target="_blank" style="border-image: initial; font-size: 14px; font: inherit; color: #4183c4; text-decoration: none; padding: 0px; margin: 0px; border: 0px initial initial;" href="http://weibo.com/sanshuiqing">@三水清</a></p>
<div class="copyright">
<strong>声明：</strong>文章未声明为原创文章，本文链接 <a href="http://js8.in/974.html" title="webSlide — PPT演示文档javascript框架">http://js8.in/974.html</a>. 转载请注明转自<a href="http://js8.in" title="前端开发博客"> JS8.IN ™</a></span></span></div>
<h3 class="box-title">随机文章</h3>
<ul class="box_random">
<li><a href="http://js8.in/380.html" title="IE6 PNG图片不透明问题的解决方法" rel="bookmark inlinks">IE6 PNG图片不透明问题的解决方法</a></li>
<li><a href="http://js8.in/47.html" title="十七届三中全会思想汇报~" rel="bookmark inlinks">十七届三中全会思想汇报~</a></li>
<li><a href="http://js8.in/774.html" title="nodejs教程：安装express及配置app.js文件" rel="bookmark inlinks">nodejs教程：安装express及配置app.js文件</a></li>
<li><a href="http://js8.in/238.html" title="真正的jQuery的radio与checkbox取值" rel="bookmark inlinks">真正的jQuery的radio与checkbox取值</a></li>
<li><a href="http://js8.in/692.html" title="新浪微博应用：微博送大礼" rel="bookmark inlinks">新浪微博应用：微博送大礼</a></li>
<li><a href="http://js8.in/401.html" title="微软官方发布IE调试工具：SuperPreview for IE" rel="bookmark inlinks">微软官方发布IE调试工具：SuperPreview for IE</a></li>
<li><a href="http://js8.in/379.html" title="cURL常用的几个PHP函数" rel="bookmark inlinks">cURL常用的几个PHP函数</a></li>
<li><a href="http://js8.in/547.html" title="去掉Eclipse插件Aptana启动显示My Aptana" rel="bookmark inlinks">去掉Eclipse插件Aptana启动显示My Aptana</a></li>
</ul>
<hr />
<p><small>© 三水清 for <a href="http://js8.in">三水清</a>, 2012. |
<a href="http://js8.in/974.html#comments">6 comments</a> |在微博关注我：<a href="//weibo.com/sanshuiqing" target="_blank" title="关注断桥残雪的新浪微博">@清-三水清</a>
<br/>收藏到：
<a rel="nofollow" href="http://share.renren.com/share/buttonshare.do?link=%posturl%&title=%posttitle%" title="收藏本文到人人网" target="_blank">人人网</a> | <a rel="nofollow" href="http://www.douban.com/recommend/?url=%posturl%&title=%posttitle%" title="收藏本文到豆瓣" target="_blank">豆瓣</a> | <a rel="nofollow" href="http://www.kaixin001.com/repaste/share.php?rtitle=%posttitle%&rurl=%posturl%" title="收藏本文到开心网" target="_blank">开心网</a> | <a rel="nofollow" href="http://shuqian.qq.com/post?title=%posttitle%&%20uri=%posturl%" title="收藏本文到QQ书签" target="_blank">QQ书签</a> | <a rel="nofollow" href="http://v.t.sina.com.cn/share/share.php?url=%posturl%&title=%posttitle%" title="收藏本文到新浪微博" target="_blank">新浪微博</a> | <a rel="nofollow" href="http://v.t.qq.com/share/share.php?title=%posttitle%&url=%posturl%&site=http://www.kaixin100.info" title="收藏本文到腾讯微博" target="_blank">腾讯微博</a>
<br/>
Post tags: <a href="http://js8.in/tag/javascript" rel="tag">javascript</a>, <a href="http://js8.in/tag/ppt" rel="tag">PPT</a>, <a href="http://js8.in/tag/webslide" rel="tag">webSlide</a><br/>
</small></p><table class="wumii-related-items" cellspacing="0" cellpadding="3" border="0"  style="clear: both;">
    
    <tr>
        <td colspan="4"><b><font size="-1"  style="display: block !important; padding: 20px 0 5px !important;">猜你喜欢：</font></b></td>
    </tr>
    
        <tr>
                <td width="102" valign="top" style="padding: 5px !important; margin: 0 !important;">
                    <a target="_blank" title="javascript入门到高级PPT" style="text-decoration: none !important; cursor: pointer !important;" href="http://app.wumii.com/ext/redirect?url=http%3A%2F%2Fjs8.in%2F750.html&from=http%3A%2F%2Fjs8.in%2F974.html">
                        <img style="margin: 0 !important; padding: 2px !important; border: 1px solid #DDDDDD !important; width: 96px !important; height: 96px !important;" src="http://static.wumii.com/site_images/2011/11/17/10979311.jpg" width="96px" height="96px" /><br />
                        <font size="-1" color="#333333" style="display: block !important; line-height: 15px !important; width: 102px !important; font: 12px/15px arial !important; height: 60px !important; margin: 3px 0 0 0 !important; padding: 0 !important; overflow: hidden !important;">javascript入门到高级PPT</font>
                    </a>
                </td>
                <td width="102" valign="top" style="padding: 5px !important; margin: 0 !important; border-left: 1px solid #DDDDDD !important;">
                    <a target="_blank" title="nodePPT — nodejs做的手机端控制PC端的PPT演示文档javascript框架" style="text-decoration: none !important; cursor: pointer !important;" href="http://app.wumii.com/ext/redirect?url=http%3A%2F%2Fjs8.in%2F989.html&from=http%3A%2F%2Fjs8.in%2F974.html">
                        <img style="margin: 0 !important; padding: 2px !important; border: 1px solid #DDDDDD !important; width: 96px !important; height: 96px !important;" src="http://static.wumii.com/site_images/2012/04/21/21201860.jpg" width="96px" height="96px" /><br />
                        <font size="-1" color="#333333" style="display: block !important; line-height: 15px !important; width: 102px !important; font: 12px/15px arial !important; height: 60px !important; margin: 3px 0 0 0 !important; padding: 0 !important; overflow: hidden !important;">nodePPT — nodejs做的手机端控制PC端的PPT演示文档javascript框架</font>
                    </a>
                </td>
                <td width="102" valign="top" style="padding: 5px !important; margin: 0 !important; border-left: 1px solid #DDDDDD !important;">
                    <a target="_blank" title="非字母javascript" style="text-decoration: none !important; cursor: pointer !important;" href="http://app.wumii.com/ext/redirect?url=http%3A%2F%2Fjs8.in%2F918.html&from=http%3A%2F%2Fjs8.in%2F974.html">
                        <img style="margin: 0 !important; padding: 2px !important; border: 1px solid #DDDDDD !important; width: 96px !important; height: 96px !important;" src="http://static.wumii.com/site_images/2011/11/30/11698517.jpg" width="96px" height="96px" /><br />
                        <font size="-1" color="#333333" style="display: block !important; line-height: 15px !important; width: 102px !important; font: 12px/15px arial !important; height: 60px !important; margin: 3px 0 0 0 !important; padding: 0 !important; overflow: hidden !important;">非字母javascript</font>
                    </a>
                </td>
                <td width="102" valign="top" style="padding: 5px !important; margin: 0 !important; border-left: 1px solid #DDDDDD !important;">
                    <a target="_blank" title="javascript获取光标位置以及设置光标位置" style="text-decoration: none !important; cursor: pointer !important;" href="http://app.wumii.com/ext/redirect?url=http%3A%2F%2Fjs8.in%2F466.html&from=http%3A%2F%2Fjs8.in%2F974.html">
                        <img style="margin: 0 !important; padding: 2px !important; border: 1px solid #DDDDDD !important; width: 96px !important; height: 96px !important;" src="http://static.wumii.com/site_images/2011/11/17/10979320.jpg" width="96px" height="96px" /><br />
                        <font size="-1" color="#333333" style="display: block !important; line-height: 15px !important; width: 102px !important; font: 12px/15px arial !important; height: 60px !important; margin: 3px 0 0 0 !important; padding: 0 !important; overflow: hidden !important;">javascript获取光标位置以及设置光标位置</font>
                    </a>
                </td>
        </tr>
    
    <tr>
        <td colspan="4" align="right">
            <a style="text-decoration: none !important;" href="http://www.wumii.com/widget/relatedItems" target="_blank" title="无觅相关文章插件">
                <font size="-1" color="#bbbbbb" style="display: block !important; font-family: arial !important; padding: 5px 0 !important; font-size: 12px !important; color: #bbb !important;">无觅</font>
            </a>
        </td>
    </tr>
</table>]]></content:encoded>
			<wfw:commentRss>http://js8.in/974.html/feed</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
		<item>
		<title>windows搭建memcached环境</title>
		<link>http://js8.in/946.html</link>
		<comments>http://js8.in/946.html#comments</comments>
		<pubDate>Tue, 07 Feb 2012 00:55:26 +0000</pubDate>
		<dc:creator>三水清</dc:creator>
				<category><![CDATA[php]]></category>
		<category><![CDATA[memcached]]></category>
		<category><![CDATA[缓存]]></category>

		<guid isPermaLink="false">http://js8.in/?p=946</guid>
		<description><![CDATA[最近练手php，一个地方需要缓存来支持，想来想去还是用memcached做缓存，可是电脑是windows系统，如果是linux系统安装memcached就比较容易，敲入几行shell就搞定，windows下还没搞过，于是记录下过程，备用。
Windows下的Memcache安装
1、下载memcache for windows。下载地址：http://jehiah.cz/projects/memcached-win32，推荐下载binaries版本，解压(本例中解压到c:\\memcached)。
2、在命令行状态下输入： c:\\memcached\\memcached.exe -d install 。至此memcached已经安装成windows服务
3、在命令行下输入： c:\\memcached\\memcached.exe -d start 以启动memcached服务。当然也可以选择在windows服务中启动
你没看错，就是这么简单，简简单单的三步memcache的服务器端就准备完毕
php安装Memcached模块支持
1、下载php_memcache.dll模块，你可以从http://downloads.php.net/pierre/找到对应的版本，
php5.3的直接下载http://shikii.net/blog/downloads/php_memcache-cvs-20090703-5.3-VC6-x86.zip
2、修改php.ini，添加如下内容：

extension=php_memcache.dll

3、重启apache服务器，然后查看一下phpinfo，如果有memcache，那么就说明安装成功！
测试windows下的Memcached
测试代码如下：

&#60;?php
$mem = new Memcache;
$mem-&#62;connect&#40;&#34;127.0.0.1&#34;, 11211&#41;;
$mem-&#62;set&#40;'key', 'Hello Memcached!', 0, 60&#41;;
$val = $mem-&#62;get&#40;'key'&#41;;
echo $val;

更多测试代码，需要移步：
http://www.php.net/manual/en/memcache.examples-overview.php
Memcached的基本设置

-p 监听的端口
-l 连接的IP地址, 默认是本机
-d start 启动memcached服务
-d restart 重起memcached服务
-d stop&#124;shutdown 关闭正在运行的memcached服务
-d install 安装memcached服务
-d uninstall 卸载memcached服务
-u 以的身份运行 (仅在以root运行的时候有效)
-m 最大内存使用，单位MB。默认64MB
-M 内存耗尽时返回错误，而不是删除项
-c 最大同时连接数，默认是1024
-f 块大小增长因子，默认是1.25
-n 最小分配空间，key+value+flags默认是48
-h 显示帮助
Memcache安装参考资源
http://www.codeforest.net/how-to-install-memcached-on-windows-machine
http://shikii.net/blog/installing-memcached-for-php-5-3-on-windows-7/

声明：文章未声明为原创文章，本文链接 http://js8.in/946.html. 转载请注明转自 JS8.IN ™
随机文章

7个JavaScript在IE和Firefox浏览器下的差异写法
QQ爱墙 许愿墙 祝福墙 程序源代码开发下载
新浪微博jsSDK操作指南
自己写的一个轻量级javascript框架的设计模式
2fool.cn域名健在，爱墙升级
php、js两种不同方式根据关键词返回经纬度接口【基于Google map API】
使用CSS控制打印页面格式
Sina App Engine开发实例：天气预报的定时短信（二）


© 三水清 [...]<table class="wumii-related-items" cellspacing="0" cellpadding="3" border="0"  style="clear: both;">
    
    <tr>
        <td colspan="4"><b><font size="-1"  style="display: block !important; padding: 20px 0 5px !important;">猜你喜欢：</font></b></td>
    </tr>
    
        <tr>
                <td width="102" valign="top" style="padding: 5px !important; margin: 0 !important;">
                    <a target="_blank" title="21个常用的 PHP 代码汇总" style="text-decoration: none !important; cursor: pointer !important;" href="http://app.wumii.com/ext/redirect?url=http%3A%2F%2Fjs8.in%2F457.html&from=http%3A%2F%2Fjs8.in%2F946.html">
                        <img style="margin: 0 !important; padding: 2px !important; border: 1px solid #DDDDDD !important; width: 96px !important; height: 96px !important;" src="http://static.wumii.com/site_images/2011/10/06/8663981.jpg" width="96px" height="96px" /><br />
                        <font size="-1" color="#333333" style="display: block !important; line-height: 15px !important; width: 102px !important; font: 12px/15px arial !important; height: 60px !important; margin: 3px 0 0 0 !important; padding: 0 !important; overflow: hidden !important;">21个常用的 PHP 代码汇总</font>
                    </a>
                </td>
                <td width="102" valign="top" style="padding: 5px !important; margin: 0 !important; border-left: 1px solid #DDDDDD !important;">
                    <a target="_blank" title="通过PHP批量下载图片文件" style="text-decoration: none !important; cursor: pointer !important;" href="http://app.wumii.com/ext/redirect?url=http%3A%2F%2Fjs8.in%2F586.html&from=http%3A%2F%2Fjs8.in%2F946.html">
                        <img style="margin: 0 !important; padding: 2px !important; border: 1px solid #DDDDDD !important; width: 96px !important; height: 96px !important;" src="http://static.wumii.com/site_images/2011/11/17/10977771.gif" width="96px" height="96px" /><br />
                        <font size="-1" color="#333333" style="display: block !important; line-height: 15px !important; width: 102px !important; font: 12px/15px arial !important; height: 60px !important; margin: 3px 0 0 0 !important; padding: 0 !important; overflow: hidden !important;">通过PHP批量下载图片文件</font>
                    </a>
                </td>
                <td width="102" valign="top" style="padding: 5px !important; margin: 0 !important; border-left: 1px solid #DDDDDD !important;">
                    <a target="_blank" title="PHP生成RSS类：RSS.class.php" style="text-decoration: none !important; cursor: pointer !important;" href="http://app.wumii.com/ext/redirect?url=http%3A%2F%2Fjs8.in%2F412.html&from=http%3A%2F%2Fjs8.in%2F946.html">
                        <img style="margin: 0 !important; padding: 2px !important; border: 1px solid #DDDDDD !important; width: 96px !important; height: 96px !important;" src="http://static.wumii.com/site_images/2011/11/17/10979694.jpg" width="96px" height="96px" /><br />
                        <font size="-1" color="#333333" style="display: block !important; line-height: 15px !important; width: 102px !important; font: 12px/15px arial !important; height: 60px !important; margin: 3px 0 0 0 !important; padding: 0 !important; overflow: hidden !important;">PHP生成RSS类：RSS.class.php</font>
                    </a>
                </td>
                <td width="102" valign="top" style="padding: 5px !important; margin: 0 !important; border-left: 1px solid #DDDDDD !important;">
                    <a target="_blank" title="linux安装PHP加速器eAccelerator" style="text-decoration: none !important; cursor: pointer !important;" href="http://app.wumii.com/ext/redirect?url=http%3A%2F%2Fjs8.in%2F888.html&from=http%3A%2F%2Fjs8.in%2F946.html">
                        <img style="margin: 0 !important; padding: 2px !important; border: 1px solid #DDDDDD !important; width: 96px !important; height: 96px !important;" src="http://static.wumii.com/site_images/2011/09/15/12184400.jpg" width="96px" height="96px" /><br />
                        <font size="-1" color="#333333" style="display: block !important; line-height: 15px !important; width: 102px !important; font: 12px/15px arial !important; height: 60px !important; margin: 3px 0 0 0 !important; padding: 0 !important; overflow: hidden !important;">linux安装PHP加速器eAccelerator</font>
                    </a>
                </td>
        </tr>
    
    <tr>
        <td colspan="4" align="right">
            <a style="text-decoration: none !important;" href="http://www.wumii.com/widget/relatedItems" target="_blank" title="无觅相关文章插件">
                <font size="-1" color="#bbbbbb" style="display: block !important; font-family: arial !important; padding: 5px 0 !important; font-size: 12px !important; color: #bbb !important;">无觅</font>
            </a>
        </td>
    </tr>
</table>]]></description>
			<content:encoded><![CDATA[<p>最近练手php，一个地方需要缓存来支持，想来想去还是用<strong>memcached</strong>做缓存，可是电脑是windows系统，如果是linux系统安装memcached就比较容易，敲入几行shell就搞定，windows下还没搞过，于是记录下过程，备用。</p>
<h2>Windows下的Memcache安装</h2>
<p>1、下载memcache for windows。下载地址：<a target="_blank" target="_blank" href="http://jehiah.cz/projects/memcached-win32">http://jehiah.cz/projects/memcached-win32</a>，推荐下载binaries版本，解压(本例中解压到c:\\memcached)。<br />
2、在命令行状态下输入： c:\\memcached\\memcached.exe -d install 。至此memcached已经安装成windows服务<br />
3、在命令行下输入： c:\\memcached\\memcached.exe -d start 以启动<strong>memcached服务</strong>。当然也可以选择在windows服务中启动<br />
你没看错，就是这么简单，简简单单的三步memcache的服务器端就准备完毕</p>
<h2>php安装Memcached模块支持</h2>
<p>1、下载<strong>php_memcache.dll</strong>模块，你可以从<a target="_blank" target="_blank" href="http://downloads.php.net/pierre/">http://downloads.php.net/pierre/</a>找到对应的版本，<br />
php5.3的直接下载<a target="_blank" target="_blank" href="http://shikii.net/blog/downloads/php_memcache-cvs-20090703-5.3-VC6-x86.zip">http://shikii.net/blog/downloads/php_memcache-cvs-20090703-5.3-VC6-x86.zip</a></p>
<p>2、修改php.ini，添加如下内容：</p>

<div class="wp_syntax"><div class="code"><pre class="html" style="font-family:monospace;">extension=php_memcache.dll</pre></div></div>

<p>3、重启apache服务器，然后查看一下phpinfo，如果有memcache，那么就说明安装成功！</p>
<h2>测试windows下的Memcached</h2>
<p>测试代码如下：</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?php</span>
<span style="color: #000088;">$mem</span> <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> Memcache<span style="color: #339933;">;</span>
<span style="color: #000088;">$mem</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">connect</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;127.0.0.1&quot;</span><span style="color: #339933;">,</span> <span style="color: #cc66cc;">11211</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$mem</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">set</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'key'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'Hello Memcached!'</span><span style="color: #339933;">,</span> <span style="color: #cc66cc;">0</span><span style="color: #339933;">,</span> <span style="color: #cc66cc;">60</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$val</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$mem</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">get</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'key'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #b1b100;">echo</span> <span style="color: #000088;">$val</span><span style="color: #339933;">;</span></pre></div></div>

<p>更多测试代码，需要移步：<br />
<a target="_blank" target="_blank" href="http://www.php.net/manual/en/memcache.examples-overview.php">http://www.php.net/manual/en/memcache.examples-overview.php</a></p>
<h2>Memcached的基本设置</h2>
<p><span id="more-946"></span></p>
<blockquote><p>-p 监听的端口<br />
-l 连接的IP地址, 默认是本机<br />
-d start 启动memcached服务<br />
-d restart 重起memcached服务<br />
-d stop|shutdown 关闭正在运行的memcached服务<br />
-d install 安装memcached服务<br />
-d uninstall 卸载memcached服务<br />
-u 以的身份运行 (仅在以root运行的时候有效)<br />
-m 最大内存使用，单位MB。默认64MB<br />
-M 内存耗尽时返回错误，而不是删除项<br />
-c 最大同时连接数，默认是1024<br />
-f 块大小增长因子，默认是1.25<br />
-n 最小分配空间，key+value+flags默认是48<br />
-h 显示帮助</p></blockquote>
<h3>Memcache安装参考资源</h3>
<p><a target="_blank" target="_blank" href="http://www.codeforest.net/how-to-install-memcached-on-windows-machine">http://www.codeforest.net/how-to-install-memcached-on-windows-machine</a><br />
<a target="_blank" target="_blank" href="http://shikii.net/blog/installing-memcached-for-php-5-3-on-windows-7/">http://shikii.net/blog/installing-memcached-for-php-5-3-on-windows-7/</a>
<div class="copyright">
<strong>声明：</strong>文章未声明为原创文章，本文链接 <a href="http://js8.in/946.html" title="windows搭建memcached环境">http://js8.in/946.html</a>. 转载请注明转自<a href="http://js8.in" title="前端开发博客"> JS8.IN ™</a></span></span></div>
<h3 class="box-title">随机文章</h3>
<ul class="box_random">
<li><a href="http://js8.in/314.html" title="让我们来搞搞搜狗云输入法" rel="bookmark inlinks">让我们来搞搞搜狗云输入法</a></li>
<li><a href="http://js8.in/715.html" title="NotePad++安装和配置" rel="bookmark inlinks">NotePad++安装和配置</a></li>
<li><a href="http://js8.in/267.html" title="新功能-QQ秀上线" rel="bookmark inlinks">新功能-QQ秀上线</a></li>
<li><a href="http://js8.in/592.html" title="发布一组QQ微博邀请链接" rel="bookmark inlinks">发布一组QQ微博邀请链接</a></li>
<li><a href="http://js8.in/559.html" title="实时公布腾讯微博邀请种子" rel="bookmark inlinks">实时公布腾讯微博邀请种子</a></li>
<li><a href="http://js8.in/391.html" title="Google2009年Logo大盘点——第一季" rel="bookmark inlinks">Google2009年Logo大盘点——第一季</a></li>
<li><a href="http://js8.in/516.html" title="js8.in PR值升为4" rel="bookmark inlinks">js8.in PR值升为4</a></li>
<li><a href="http://js8.in/667.html" title="修改获取验证码图片到本地的PHP程序" rel="bookmark inlinks">修改获取验证码图片到本地的PHP程序</a></li>
</ul>
<hr />
<p><small>© 三水清 for <a href="http://js8.in">三水清</a>, 2012. |
<a href="http://js8.in/946.html#comments">One comment</a> |在微博关注我：<a href="//weibo.com/sanshuiqing" target="_blank" title="关注断桥残雪的新浪微博">@清-三水清</a>
<br/>收藏到：
<a rel="nofollow" href="http://share.renren.com/share/buttonshare.do?link=%posturl%&title=%posttitle%" title="收藏本文到人人网" target="_blank">人人网</a> | <a rel="nofollow" href="http://www.douban.com/recommend/?url=%posturl%&title=%posttitle%" title="收藏本文到豆瓣" target="_blank">豆瓣</a> | <a rel="nofollow" href="http://www.kaixin001.com/repaste/share.php?rtitle=%posttitle%&rurl=%posturl%" title="收藏本文到开心网" target="_blank">开心网</a> | <a rel="nofollow" href="http://shuqian.qq.com/post?title=%posttitle%&%20uri=%posturl%" title="收藏本文到QQ书签" target="_blank">QQ书签</a> | <a rel="nofollow" href="http://v.t.sina.com.cn/share/share.php?url=%posturl%&title=%posttitle%" title="收藏本文到新浪微博" target="_blank">新浪微博</a> | <a rel="nofollow" href="http://v.t.qq.com/share/share.php?title=%posttitle%&url=%posturl%&site=http://www.kaixin100.info" title="收藏本文到腾讯微博" target="_blank">腾讯微博</a>
<br/>
Post tags: <a href="http://js8.in/tag/memcached" rel="tag">memcached</a>, <a href="http://js8.in/tag/php" rel="tag">php</a>, <a href="http://js8.in/tag/%e7%bc%93%e5%ad%98" rel="tag">缓存</a><br/>
</small></p><table class="wumii-related-items" cellspacing="0" cellpadding="3" border="0"  style="clear: both;">
    
    <tr>
        <td colspan="4"><b><font size="-1"  style="display: block !important; padding: 20px 0 5px !important;">猜你喜欢：</font></b></td>
    </tr>
    
        <tr>
                <td width="102" valign="top" style="padding: 5px !important; margin: 0 !important;">
                    <a target="_blank" title="21个常用的 PHP 代码汇总" style="text-decoration: none !important; cursor: pointer !important;" href="http://app.wumii.com/ext/redirect?url=http%3A%2F%2Fjs8.in%2F457.html&from=http%3A%2F%2Fjs8.in%2F946.html">
                        <img style="margin: 0 !important; padding: 2px !important; border: 1px solid #DDDDDD !important; width: 96px !important; height: 96px !important;" src="http://static.wumii.com/site_images/2011/10/06/8663981.jpg" width="96px" height="96px" /><br />
                        <font size="-1" color="#333333" style="display: block !important; line-height: 15px !important; width: 102px !important; font: 12px/15px arial !important; height: 60px !important; margin: 3px 0 0 0 !important; padding: 0 !important; overflow: hidden !important;">21个常用的 PHP 代码汇总</font>
                    </a>
                </td>
                <td width="102" valign="top" style="padding: 5px !important; margin: 0 !important; border-left: 1px solid #DDDDDD !important;">
                    <a target="_blank" title="通过PHP批量下载图片文件" style="text-decoration: none !important; cursor: pointer !important;" href="http://app.wumii.com/ext/redirect?url=http%3A%2F%2Fjs8.in%2F586.html&from=http%3A%2F%2Fjs8.in%2F946.html">
                        <img style="margin: 0 !important; padding: 2px !important; border: 1px solid #DDDDDD !important; width: 96px !important; height: 96px !important;" src="http://static.wumii.com/site_images/2011/11/17/10977771.gif" width="96px" height="96px" /><br />
                        <font size="-1" color="#333333" style="display: block !important; line-height: 15px !important; width: 102px !important; font: 12px/15px arial !important; height: 60px !important; margin: 3px 0 0 0 !important; padding: 0 !important; overflow: hidden !important;">通过PHP批量下载图片文件</font>
                    </a>
                </td>
                <td width="102" valign="top" style="padding: 5px !important; margin: 0 !important; border-left: 1px solid #DDDDDD !important;">
                    <a target="_blank" title="PHP生成RSS类：RSS.class.php" style="text-decoration: none !important; cursor: pointer !important;" href="http://app.wumii.com/ext/redirect?url=http%3A%2F%2Fjs8.in%2F412.html&from=http%3A%2F%2Fjs8.in%2F946.html">
                        <img style="margin: 0 !important; padding: 2px !important; border: 1px solid #DDDDDD !important; width: 96px !important; height: 96px !important;" src="http://static.wumii.com/site_images/2011/11/17/10979694.jpg" width="96px" height="96px" /><br />
                        <font size="-1" color="#333333" style="display: block !important; line-height: 15px !important; width: 102px !important; font: 12px/15px arial !important; height: 60px !important; margin: 3px 0 0 0 !important; padding: 0 !important; overflow: hidden !important;">PHP生成RSS类：RSS.class.php</font>
                    </a>
                </td>
                <td width="102" valign="top" style="padding: 5px !important; margin: 0 !important; border-left: 1px solid #DDDDDD !important;">
                    <a target="_blank" title="linux安装PHP加速器eAccelerator" style="text-decoration: none !important; cursor: pointer !important;" href="http://app.wumii.com/ext/redirect?url=http%3A%2F%2Fjs8.in%2F888.html&from=http%3A%2F%2Fjs8.in%2F946.html">
                        <img style="margin: 0 !important; padding: 2px !important; border: 1px solid #DDDDDD !important; width: 96px !important; height: 96px !important;" src="http://static.wumii.com/site_images/2011/09/15/12184400.jpg" width="96px" height="96px" /><br />
                        <font size="-1" color="#333333" style="display: block !important; line-height: 15px !important; width: 102px !important; font: 12px/15px arial !important; height: 60px !important; margin: 3px 0 0 0 !important; padding: 0 !important; overflow: hidden !important;">linux安装PHP加速器eAccelerator</font>
                    </a>
                </td>
        </tr>
    
    <tr>
        <td colspan="4" align="right">
            <a style="text-decoration: none !important;" href="http://www.wumii.com/widget/relatedItems" target="_blank" title="无觅相关文章插件">
                <font size="-1" color="#bbbbbb" style="display: block !important; font-family: arial !important; padding: 5px 0 !important; font-size: 12px !important; color: #bbb !important;">无觅</font>
            </a>
        </td>
    </tr>
</table>]]></content:encoded>
			<wfw:commentRss>http://js8.in/946.html/feed</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>【PPT分享】XSS注入和防范</title>
		<link>http://js8.in/951.html</link>
		<comments>http://js8.in/951.html#comments</comments>
		<pubDate>Mon, 06 Feb 2012 09:53:29 +0000</pubDate>
		<dc:creator>三水清</dc:creator>
				<category><![CDATA[web前端开发]]></category>
		<category><![CDATA[PPT]]></category>
		<category><![CDATA[xss]]></category>
		<category><![CDATA[安全]]></category>

		<guid isPermaLink="false">http://js8.in/?p=951</guid>
		<description><![CDATA[xss是一种网站应用程序的安全漏洞攻击，是代码注入的一种。它允许恶意用户将代码注入到网页上，其他用户在观看网页时就会受到影响。这类攻击通常包含了HTML以及用户端脚本语言。<table class="wumii-related-items" cellspacing="0" cellpadding="3" border="0"  style="clear: both;">
    
    <tr>
        <td colspan="4"><b><font size="-1"  style="display: block !important; padding: 20px 0 5px !important;">猜你喜欢：</font></b></td>
    </tr>
    
        <tr>
                <td width="102" valign="top" style="padding: 5px !important; margin: 0 !important;">
                    <a target="_blank" title="webSlide — PPT演示文档javascript框架" style="text-decoration: none !important; cursor: pointer !important;" href="http://app.wumii.com/ext/redirect?url=http%3A%2F%2Fjs8.in%2F974.html&from=http%3A%2F%2Fjs8.in%2F951.html">
                        <img style="margin: 0 !important; padding: 2px !important; border: 1px solid #DDDDDD !important; width: 96px !important; height: 96px !important;" src="http://static.wumii.com/site_images/2012/03/08/16731779.png" width="96px" height="96px" /><br />
                        <font size="-1" color="#333333" style="display: block !important; line-height: 15px !important; width: 102px !important; font: 12px/15px arial !important; height: 60px !important; margin: 3px 0 0 0 !important; padding: 0 !important; overflow: hidden !important;">webSlide — PPT演示文档javascript框架</font>
                    </a>
                </td>
                <td width="102" valign="top" style="padding: 5px !important; margin: 0 !important; border-left: 1px solid #DDDDDD !important;">
                    <a target="_blank" title="nodePPT — nodejs做的手机端控制PC端的PPT演示文档javascript框架" style="text-decoration: none !important; cursor: pointer !important;" href="http://app.wumii.com/ext/redirect?url=http%3A%2F%2Fjs8.in%2F989.html&from=http%3A%2F%2Fjs8.in%2F951.html">
                        <img style="margin: 0 !important; padding: 2px !important; border: 1px solid #DDDDDD !important; width: 96px !important; height: 96px !important;" src="http://static.wumii.com/site_images/2012/04/21/21201860.jpg" width="96px" height="96px" /><br />
                        <font size="-1" color="#333333" style="display: block !important; line-height: 15px !important; width: 102px !important; font: 12px/15px arial !important; height: 60px !important; margin: 3px 0 0 0 !important; padding: 0 !important; overflow: hidden !important;">nodePPT — nodejs做的手机端控制PC端的PPT演示文档javascript框架</font>
                    </a>
                </td>
                <td width="102" valign="top" style="padding: 5px !important; margin: 0 !important; border-left: 1px solid #DDDDDD !important;">
                    <a target="_blank" title="javascript入门到高级PPT" style="text-decoration: none !important; cursor: pointer !important;" href="http://app.wumii.com/ext/redirect?url=http%3A%2F%2Fjs8.in%2F750.html&from=http%3A%2F%2Fjs8.in%2F951.html">
                        <img style="margin: 0 !important; padding: 2px !important; border: 1px solid #DDDDDD !important; width: 96px !important; height: 96px !important;" src="http://static.wumii.com/site_images/2011/11/17/10979311.jpg" width="96px" height="96px" /><br />
                        <font size="-1" color="#333333" style="display: block !important; line-height: 15px !important; width: 102px !important; font: 12px/15px arial !important; height: 60px !important; margin: 3px 0 0 0 !important; padding: 0 !important; overflow: hidden !important;">javascript入门到高级PPT</font>
                    </a>
                </td>
                <td width="102" valign="top" style="padding: 5px !important; margin: 0 !important; border-left: 1px solid #DDDDDD !important;">
                    <a target="_blank" title="分享一个php验证码类，支持中文字母数字，还可自定义字体" style="text-decoration: none !important; cursor: pointer !important;" href="http://app.wumii.com/ext/redirect?url=http%3A%2F%2Fjs8.in%2F646.html&from=http%3A%2F%2Fjs8.in%2F951.html">
                        <img style="margin: 0 !important; padding: 2px !important; border: 1px solid #DDDDDD !important; width: 96px !important; height: 96px !important;" src="http://static.wumii.com/site_images/2011/11/17/10978884.jpg" width="96px" height="96px" /><br />
                        <font size="-1" color="#333333" style="display: block !important; line-height: 15px !important; width: 102px !important; font: 12px/15px arial !important; height: 60px !important; margin: 3px 0 0 0 !important; padding: 0 !important; overflow: hidden !important;">分享一个php验证码类，支持中文字母数字，还可自定义字体</font>
                    </a>
                </td>
        </tr>
    
    <tr>
        <td colspan="4" align="right">
            <a style="text-decoration: none !important;" href="http://www.wumii.com/widget/relatedItems" target="_blank" title="无觅相关文章插件">
                <font size="-1" color="#bbbbbb" style="display: block !important; font-family: arial !important; padding: 5px 0 !important; font-size: 12px !important; color: #bbb !important;">无觅</font>
            </a>
        </td>
    </tr>
</table>]]></description>
			<content:encoded><![CDATA[<p>这是我前些日子准备的关于《<a target="_blank" href="http://qdemo.sinaapp.com/ppt/xss/" target="_blank">XSS注入和防范</a>》的技术分享ppt，现在放出来，之前是做的powderpoint文件，后来网上流传<a target="_blank" href="http://bartaz.github.com/impress.js" target="_blank">impress.js</a>做ppt，于是自己也整了个impress.js版本的放在了SAE上面，经过测试发现当ppt的内容较多，带有图片等，<strong>impress.js</strong>效果就会比较卡。不多说其他的，说说ppt的内容：</p>
<p>《XSS注入和防范》主要从xss是什么，xss的危害，xss的类型及其防范的措施，几个方面来讲解xss。希望对大家理解xss有所帮助，另外多说句cookie的httponly方式，在apache下面有个漏洞，当cookie超过4k的时候就会出现泄漏，所以要注意这个漏洞！（具体代码：<a target="_blank" href="https://gist.github.com/1955a1c28324d4724b7b/7fe51f2a66c1d4a40a736540b3ad3fde02b7fb08" target="_blank">狂点此处</a>）</p>
<p>废话不多说了，上ppt地址：<a target="_blank" href="http://qdemo.sinaapp.com/ppt/xss" target="_blank">【PPT分享】XSS注入和防范</a>，请使用支持chrome浏览器查看ppt页面<br />
<div id="attachment_952" class="wp-caption aligncenter" style="width: 410px"><a href="http://js8.in/951.html/02-06_152043" rel="attachment wp-att-952"><img src="http://js8.in/wp-content/uploads/2012/02/02-06_152043.png" alt="XSS注入和防范" title="XSS注入和防范" width="400" height="284" class="size-full wp-image-952" /></a><p class="wp-caption-text">XSS注入和防范</p></div><br />
<span id="more-951"></span></p>
<p><strong>xss</strong>是一种网站应用程序的安全漏洞攻击，是代码注入的一种。它允许恶意用户将代码注入到网页上，其他用户在观看网页时就会受到影响。这类攻击通常包含了HTML以及用户端脚本语言。
<div class="copyright">
<strong>声明：</strong>文章未声明为原创文章，本文链接 <a href="http://js8.in/951.html" title="【PPT分享】XSS注入和防范">http://js8.in/951.html</a>. 转载请注明转自<a href="http://js8.in" title="前端开发博客"> JS8.IN ™</a></span></span></div>
<h3 class="box-title">随机文章</h3>
<ul class="box_random">
<li><a href="http://js8.in/380.html" title="IE6 PNG图片不透明问题的解决方法" rel="bookmark inlinks">IE6 PNG图片不透明问题的解决方法</a></li>
<li><a href="http://js8.in/24.html" title="关于最近局域网受到Arp欺骗攻击" rel="bookmark inlinks">关于最近局域网受到Arp欺骗攻击</a></li>
<li><a href="http://js8.in/455.html" title="谷歌退出中国事件尘埃落定" rel="bookmark inlinks">谷歌退出中国事件尘埃落定</a></li>
<li><a href="http://js8.in/37.html" title="“学长，你考研挺忙吧？！”" rel="bookmark inlinks">“学长，你考研挺忙吧？！”</a></li>
<li><a href="http://js8.in/561.html" title="推荐一款支持win7的超酷3D水纹屏保-Watery Desktop" rel="bookmark inlinks">推荐一款支持win7的超酷3D水纹屏保-Watery Desktop</a></li>
<li><a href="http://js8.in/607.html" title="提高Firefox的innerHTML()的性能" rel="bookmark inlinks">提高Firefox的innerHTML()的性能</a></li>
<li><a href="http://js8.in/38.html" title="Ajax文章评论上线！" rel="bookmark inlinks">Ajax文章评论上线！</a></li>
<li><a href="http://js8.in/338.html" title="最新的DreamHost优惠码免费发放" rel="bookmark inlinks">最新的DreamHost优惠码免费发放</a></li>
</ul>
<hr />
<p><small>© 三水清 for <a href="http://js8.in">三水清</a>, 2012. |
<a href="http://js8.in/951.html#comments">One comment</a> |在微博关注我：<a href="//weibo.com/sanshuiqing" target="_blank" title="关注断桥残雪的新浪微博">@清-三水清</a>
<br/>收藏到：
<a rel="nofollow" href="http://share.renren.com/share/buttonshare.do?link=%posturl%&title=%posttitle%" title="收藏本文到人人网" target="_blank">人人网</a> | <a rel="nofollow" href="http://www.douban.com/recommend/?url=%posturl%&title=%posttitle%" title="收藏本文到豆瓣" target="_blank">豆瓣</a> | <a rel="nofollow" href="http://www.kaixin001.com/repaste/share.php?rtitle=%posttitle%&rurl=%posturl%" title="收藏本文到开心网" target="_blank">开心网</a> | <a rel="nofollow" href="http://shuqian.qq.com/post?title=%posttitle%&%20uri=%posturl%" title="收藏本文到QQ书签" target="_blank">QQ书签</a> | <a rel="nofollow" href="http://v.t.sina.com.cn/share/share.php?url=%posturl%&title=%posttitle%" title="收藏本文到新浪微博" target="_blank">新浪微博</a> | <a rel="nofollow" href="http://v.t.qq.com/share/share.php?title=%posttitle%&url=%posturl%&site=http://www.kaixin100.info" title="收藏本文到腾讯微博" target="_blank">腾讯微博</a>
<br/>
Post tags: <a href="http://js8.in/tag/ppt" rel="tag">PPT</a>, <a href="http://js8.in/tag/xss" rel="tag">xss</a>, <a href="http://js8.in/tag/%e5%ae%89%e5%85%a8" rel="tag">安全</a><br/>
</small></p><table class="wumii-related-items" cellspacing="0" cellpadding="3" border="0"  style="clear: both;">
    
    <tr>
        <td colspan="4"><b><font size="-1"  style="display: block !important; padding: 20px 0 5px !important;">猜你喜欢：</font></b></td>
    </tr>
    
        <tr>
                <td width="102" valign="top" style="padding: 5px !important; margin: 0 !important;">
                    <a target="_blank" title="webSlide — PPT演示文档javascript框架" style="text-decoration: none !important; cursor: pointer !important;" href="http://app.wumii.com/ext/redirect?url=http%3A%2F%2Fjs8.in%2F974.html&from=http%3A%2F%2Fjs8.in%2F951.html">
                        <img style="margin: 0 !important; padding: 2px !important; border: 1px solid #DDDDDD !important; width: 96px !important; height: 96px !important;" src="http://static.wumii.com/site_images/2012/03/08/16731779.png" width="96px" height="96px" /><br />
                        <font size="-1" color="#333333" style="display: block !important; line-height: 15px !important; width: 102px !important; font: 12px/15px arial !important; height: 60px !important; margin: 3px 0 0 0 !important; padding: 0 !important; overflow: hidden !important;">webSlide — PPT演示文档javascript框架</font>
                    </a>
                </td>
                <td width="102" valign="top" style="padding: 5px !important; margin: 0 !important; border-left: 1px solid #DDDDDD !important;">
                    <a target="_blank" title="nodePPT — nodejs做的手机端控制PC端的PPT演示文档javascript框架" style="text-decoration: none !important; cursor: pointer !important;" href="http://app.wumii.com/ext/redirect?url=http%3A%2F%2Fjs8.in%2F989.html&from=http%3A%2F%2Fjs8.in%2F951.html">
                        <img style="margin: 0 !important; padding: 2px !important; border: 1px solid #DDDDDD !important; width: 96px !important; height: 96px !important;" src="http://static.wumii.com/site_images/2012/04/21/21201860.jpg" width="96px" height="96px" /><br />
                        <font size="-1" color="#333333" style="display: block !important; line-height: 15px !important; width: 102px !important; font: 12px/15px arial !important; height: 60px !important; margin: 3px 0 0 0 !important; padding: 0 !important; overflow: hidden !important;">nodePPT — nodejs做的手机端控制PC端的PPT演示文档javascript框架</font>
                    </a>
                </td>
                <td width="102" valign="top" style="padding: 5px !important; margin: 0 !important; border-left: 1px solid #DDDDDD !important;">
                    <a target="_blank" title="javascript入门到高级PPT" style="text-decoration: none !important; cursor: pointer !important;" href="http://app.wumii.com/ext/redirect?url=http%3A%2F%2Fjs8.in%2F750.html&from=http%3A%2F%2Fjs8.in%2F951.html">
                        <img style="margin: 0 !important; padding: 2px !important; border: 1px solid #DDDDDD !important; width: 96px !important; height: 96px !important;" src="http://static.wumii.com/site_images/2011/11/17/10979311.jpg" width="96px" height="96px" /><br />
                        <font size="-1" color="#333333" style="display: block !important; line-height: 15px !important; width: 102px !important; font: 12px/15px arial !important; height: 60px !important; margin: 3px 0 0 0 !important; padding: 0 !important; overflow: hidden !important;">javascript入门到高级PPT</font>
                    </a>
                </td>
                <td width="102" valign="top" style="padding: 5px !important; margin: 0 !important; border-left: 1px solid #DDDDDD !important;">
                    <a target="_blank" title="分享一个php验证码类，支持中文字母数字，还可自定义字体" style="text-decoration: none !important; cursor: pointer !important;" href="http://app.wumii.com/ext/redirect?url=http%3A%2F%2Fjs8.in%2F646.html&from=http%3A%2F%2Fjs8.in%2F951.html">
                        <img style="margin: 0 !important; padding: 2px !important; border: 1px solid #DDDDDD !important; width: 96px !important; height: 96px !important;" src="http://static.wumii.com/site_images/2011/11/17/10978884.jpg" width="96px" height="96px" /><br />
                        <font size="-1" color="#333333" style="display: block !important; line-height: 15px !important; width: 102px !important; font: 12px/15px arial !important; height: 60px !important; margin: 3px 0 0 0 !important; padding: 0 !important; overflow: hidden !important;">分享一个php验证码类，支持中文字母数字，还可自定义字体</font>
                    </a>
                </td>
        </tr>
    
    <tr>
        <td colspan="4" align="right">
            <a style="text-decoration: none !important;" href="http://www.wumii.com/widget/relatedItems" target="_blank" title="无觅相关文章插件">
                <font size="-1" color="#bbbbbb" style="display: block !important; font-family: arial !important; padding: 5px 0 !important; font-size: 12px !important; color: #bbb !important;">无觅</font>
            </a>
        </td>
    </tr>
</table>]]></content:encoded>
			<wfw:commentRss>http://js8.in/951.html/feed</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>IE6中a标签触发图片和ajax请求被abort</title>
		<link>http://js8.in/944.html</link>
		<comments>http://js8.in/944.html#comments</comments>
		<pubDate>Sat, 04 Feb 2012 07:28:10 +0000</pubDate>
		<dc:creator>三水清</dc:creator>
				<category><![CDATA[web前端开发]]></category>
		<category><![CDATA[abort]]></category>
		<category><![CDATA[a标签]]></category>
		<category><![CDATA[IE6]]></category>

		<guid isPermaLink="false">http://js8.in/?p=944</guid>
		<description><![CDATA[IE6 a标签的请求被abort的原因
最近项目中掉进IE6 a标签abort两次坑，第一次是a标签绑定一个事件，href='javascript:;'这样a标签触发了事件，切换验证码图片，结果验证码图片总是显示不出来，通过抓包显示状态为abort。其实这个的原因可以从IE6中a标签执行顺序说起，IE6中a标签执行onclick在执行默认事件（即href跳转）之前，当触发了绑定的事件之后，那么处理完事件之后，如果不return false或者阻止默认事件，则会继续执行href跳转，IE6会认为页面跳转到其他页面或者页面重新刷新，则abort之前onclick事件中的请求。

所以当onclick时，做出的获取最新验证码图片的请求，会因为下一步href的触发而abort。同时，如果你在a绑定的事件中做ajax请求，那么也会被无情的abort。
IE6 a标签的请求被abort的解决方案
解决的方法就是在onclick或者绑定事件中return false来阻止a标签跳转的默认事件。
例如下面的代码：

&#60;a href=&#34;javascript:void(0)&#34; onclick=&#34;fn();return false;&#34;&#62;Test&#60;/a&#62;

或者你也可以给a标签的href写成“#”，即当前页面的锚点，这样页面就不会跳转，自然不会abort请求。
最好的方式还是两种都用，保险！

声明：文章未声明为原创文章，本文链接 http://js8.in/944.html. 转载请注明转自 JS8.IN ™
随机文章

linux安装PHP加速器eAccelerator
jQuery浏览器判断一个bug，以及修改建议
使用Apache htpasswd.exe来管理SVN帐户
病毒清除啦~可是似乎xp中访问博客还是很慢！
是不是应该出售2fool.cn的域名
音乐版上线
javascript的String.replace的妙用
淘宝秒杀门事件始末


© 三水清 for 三水清, 2012. &#124;
4 comments &#124;在微博关注我：@清-三水清
收藏到：
人人网 &#124; 豆瓣 &#124; 开心网 &#124; QQ书签 &#124; 新浪微博 &#124; 腾讯微博

Post tags: abort, a标签, IE6
<table class="wumii-related-items" cellspacing="0" cellpadding="3" border="0"  style="clear: both;">
    
    <tr>
        <td colspan="4"><b><font size="-1"  style="display: block !important; padding: 20px 0 5px !important;">猜你喜欢：</font></b></td>
    </tr>
    
        <tr>
                <td width="102" valign="top" style="padding: 5px !important; margin: 0 !important;">
                    <a target="_blank" title="IE6中a标签location.href失效解决方法" style="text-decoration: none !important; cursor: pointer !important;" href="http://app.wumii.com/ext/redirect?url=http%3A%2F%2Fjs8.in%2F706.html&from=http%3A%2F%2Fjs8.in%2F944.html">
                        <img style="margin: 0 !important; padding: 2px !important; border: 1px solid #DDDDDD !important; width: 96px !important; height: 96px !important;" src="http://static.wumii.com/site_images/2011/07/21/18318778.jpg" width="96px" height="96px" /><br />
                        <font size="-1" color="#333333" style="display: block !important; line-height: 15px !important; width: 102px !important; font: 12px/15px arial !important; height: 60px !important; margin: 3px 0 0 0 !important; padding: 0 !important; overflow: hidden !important;">IE6中a标签location.href失效解决方法</font>
                    </a>
                </td>
                <td width="102" valign="top" style="padding: 5px !important; margin: 0 !important; border-left: 1px solid #DDDDDD !important;">
                    <a target="_blank" title="IE6下javascript不能隐藏select标签的bug" style="text-decoration: none !important; cursor: pointer !important;" href="http://app.wumii.com/ext/redirect?url=http%3A%2F%2Fjs8.in%2F686.html&from=http%3A%2F%2Fjs8.in%2F944.html">
                        <img style="margin: 0 !important; padding: 2px !important; border: 1px solid #DDDDDD !important; width: 96px !important; height: 96px !important;" src="http://static.wumii.com/site_images/2011/11/17/10987937.png" width="96px" height="96px" /><br />
                        <font size="-1" color="#333333" style="display: block !important; line-height: 15px !important; width: 102px !important; font: 12px/15px arial !important; height: 60px !important; margin: 3px 0 0 0 !important; padding: 0 !important; overflow: hidden !important;">IE6下javascript不能隐藏select标签的bug</font>
                    </a>
                </td>
                <td width="102" valign="top" style="padding: 5px !important; margin: 0 !important; border-left: 1px solid #DDDDDD !important;">
                    <a target="_blank" title="IE6 PNG图片不透明问题的解决方法" style="text-decoration: none !important; cursor: pointer !important;" href="http://app.wumii.com/ext/redirect?url=http%3A%2F%2Fjs8.in%2F380.html&from=http%3A%2F%2Fjs8.in%2F944.html">
                        <img style="margin: 0 !important; padding: 2px !important; border: 1px solid #DDDDDD !important; width: 96px !important; height: 96px !important;" src="http://static.wumii.com/site_images/2011/09/01/2770440.png" width="96px" height="96px" /><br />
                        <font size="-1" color="#333333" style="display: block !important; line-height: 15px !important; width: 102px !important; font: 12px/15px arial !important; height: 60px !important; margin: 3px 0 0 0 !important; padding: 0 !important; overflow: hidden !important;">IE6 PNG图片不透明问题的解决方法</font>
                    </a>
                </td>
                <td width="102" valign="top" style="padding: 5px !important; margin: 0 !important; border-left: 1px solid #DDDDDD !important;">
                    <a target="_blank" title="解决IE6 select z-index无效，遮挡div的bug" style="text-decoration: none !important; cursor: pointer !important;" href="http://app.wumii.com/ext/redirect?url=http%3A%2F%2Fjs8.in%2F553.html&from=http%3A%2F%2Fjs8.in%2F944.html">
                        <img style="margin: 0 !important; padding: 2px !important; border: 1px solid #DDDDDD !important; width: 96px !important; height: 96px !important;" src="http://static.wumii.com/site_images/2011/11/17/10987560.png" width="96px" height="96px" /><br />
                        <font size="-1" color="#333333" style="display: block !important; line-height: 15px !important; width: 102px !important; font: 12px/15px arial !important; height: 60px !important; margin: 3px 0 0 0 !important; padding: 0 !important; overflow: hidden !important;">解决IE6 select z-index无效，遮挡div的bug</font>
                    </a>
                </td>
        </tr>
    
    <tr>
        <td colspan="4" align="right">
            <a style="text-decoration: none !important;" href="http://www.wumii.com/widget/relatedItems" target="_blank" title="无觅相关文章插件">
                <font size="-1" color="#bbbbbb" style="display: block !important; font-family: arial !important; padding: 5px 0 !important; font-size: 12px !important; color: #bbb !important;">无觅</font>
            </a>
        </td>
    </tr>
</table>]]></description>
			<content:encoded><![CDATA[<h2>IE6 a标签的请求被abort的原因</h2>
<p>最近项目中掉进IE6 a标签abort两次坑，第一次是a标签绑定一个事件，<code>href='javascript:;'</code>这样a标签触发了事件，切换验证码图片，结果验证码图片总是显示不出来，通过抓包显示状态为<strong>abort</strong>。其实这个的原因可以从IE6中a标签执行顺序说起，IE6中a标签执行onclick在执行默认事件（即href跳转）之前，当触发了绑定的事件之后，那么处理完事件之后，如果不<code>return false</code>或者阻止默认事件，则会继续执行href跳转，IE6会认为页面跳转到其他页面或者页面重新刷新，则abort之前<strong>onclick</strong>事件中的请求。<br />
<span id="more-944"></span></p>
<p>所以当onclick时，做出的获取最新验证码图片的请求，会因为下一步href的触发而abort。同时，如果你在a绑定的事件中做ajax请求，那么也会被无情的<code>abort</code>。</p>
<h2>IE6 a标签的请求被abort的解决方案</h2>
<p>解决的方法就是在onclick或者绑定事件中<code>return false</code>来阻止a标签跳转的默认事件。<br />
例如下面的代码：</p>

<div class="wp_syntax"><div class="code"><pre class="html" style="font-family:monospace;">&lt;a href=&quot;javascript:void(0)&quot; onclick=&quot;fn();return false;&quot;&gt;Test&lt;/a&gt;</pre></div></div>

<p>或者你也可以给a标签的href写成“#”，即当前页面的锚点，这样页面就不会跳转，自然不会abort请求。</p>
<p>最好的方式还是两种都用，保险！
<div class="copyright">
<strong>声明：</strong>文章未声明为原创文章，本文链接 <a href="http://js8.in/944.html" title="IE6中a标签触发图片和ajax请求被abort">http://js8.in/944.html</a>. 转载请注明转自<a href="http://js8.in" title="前端开发博客"> JS8.IN ™</a></span></span></div>
<h3 class="box-title">随机文章</h3>
<ul class="box_random">
<li><a href="http://js8.in/349.html" title="发布一个Follow5的API PHP类" rel="bookmark inlinks">发布一个Follow5的API PHP类</a></li>
<li><a href="http://js8.in/539.html" title="jQuery弹出框插件wBox 1.0正式发布" rel="bookmark inlinks">jQuery弹出框插件wBox 1.0正式发布</a></li>
<li><a href="http://js8.in/851.html" title="正确理解javascript的this关键字" rel="bookmark inlinks">正确理解javascript的this关键字</a></li>
<li><a href="http://js8.in/606.html" title="解决IE6不支持max-height的bug" rel="bookmark inlinks">解决IE6不支持max-height的bug</a></li>
<li><a href="http://js8.in/414.html" title="js判断浏览器的函数，可区分chrome，safari" rel="bookmark inlinks">js判断浏览器的函数，可区分chrome，safari</a></li>
<li><a href="http://js8.in/603.html" title="关于jQuery ready()方法一些用法解释" rel="bookmark inlinks">关于jQuery ready()方法一些用法解释</a></li>
<li><a href="http://js8.in/774.html" title="nodejs教程：安装express及配置app.js文件" rel="bookmark inlinks">nodejs教程：安装express及配置app.js文件</a></li>
<li><a href="http://js8.in/243.html" title="送给你的TA另类的礼物，定要TA感动——爱墙" rel="bookmark inlinks">送给你的TA另类的礼物，定要TA感动——爱墙</a></li>
</ul>
<hr />
<p><small>© 三水清 for <a href="http://js8.in">三水清</a>, 2012. |
<a href="http://js8.in/944.html#comments">4 comments</a> |在微博关注我：<a href="//weibo.com/sanshuiqing" target="_blank" title="关注断桥残雪的新浪微博">@清-三水清</a>
<br/>收藏到：
<a rel="nofollow" href="http://share.renren.com/share/buttonshare.do?link=%posturl%&title=%posttitle%" title="收藏本文到人人网" target="_blank">人人网</a> | <a rel="nofollow" href="http://www.douban.com/recommend/?url=%posturl%&title=%posttitle%" title="收藏本文到豆瓣" target="_blank">豆瓣</a> | <a rel="nofollow" href="http://www.kaixin001.com/repaste/share.php?rtitle=%posttitle%&rurl=%posturl%" title="收藏本文到开心网" target="_blank">开心网</a> | <a rel="nofollow" href="http://shuqian.qq.com/post?title=%posttitle%&%20uri=%posturl%" title="收藏本文到QQ书签" target="_blank">QQ书签</a> | <a rel="nofollow" href="http://v.t.sina.com.cn/share/share.php?url=%posturl%&title=%posttitle%" title="收藏本文到新浪微博" target="_blank">新浪微博</a> | <a rel="nofollow" href="http://v.t.qq.com/share/share.php?title=%posttitle%&url=%posturl%&site=http://www.kaixin100.info" title="收藏本文到腾讯微博" target="_blank">腾讯微博</a>
<br/>
Post tags: <a href="http://js8.in/tag/abort" rel="tag">abort</a>, <a href="http://js8.in/tag/a%e6%a0%87%e7%ad%be" rel="tag">a标签</a>, <a href="http://js8.in/tag/ie6" rel="tag">IE6</a><br/>
</small></p><table class="wumii-related-items" cellspacing="0" cellpadding="3" border="0"  style="clear: both;">
    
    <tr>
        <td colspan="4"><b><font size="-1"  style="display: block !important; padding: 20px 0 5px !important;">猜你喜欢：</font></b></td>
    </tr>
    
        <tr>
                <td width="102" valign="top" style="padding: 5px !important; margin: 0 !important;">
                    <a target="_blank" title="IE6中a标签location.href失效解决方法" style="text-decoration: none !important; cursor: pointer !important;" href="http://app.wumii.com/ext/redirect?url=http%3A%2F%2Fjs8.in%2F706.html&from=http%3A%2F%2Fjs8.in%2F944.html">
                        <img style="margin: 0 !important; padding: 2px !important; border: 1px solid #DDDDDD !important; width: 96px !important; height: 96px !important;" src="http://static.wumii.com/site_images/2011/07/21/18318778.jpg" width="96px" height="96px" /><br />
                        <font size="-1" color="#333333" style="display: block !important; line-height: 15px !important; width: 102px !important; font: 12px/15px arial !important; height: 60px !important; margin: 3px 0 0 0 !important; padding: 0 !important; overflow: hidden !important;">IE6中a标签location.href失效解决方法</font>
                    </a>
                </td>
                <td width="102" valign="top" style="padding: 5px !important; margin: 0 !important; border-left: 1px solid #DDDDDD !important;">
                    <a target="_blank" title="IE6下javascript不能隐藏select标签的bug" style="text-decoration: none !important; cursor: pointer !important;" href="http://app.wumii.com/ext/redirect?url=http%3A%2F%2Fjs8.in%2F686.html&from=http%3A%2F%2Fjs8.in%2F944.html">
                        <img style="margin: 0 !important; padding: 2px !important; border: 1px solid #DDDDDD !important; width: 96px !important; height: 96px !important;" src="http://static.wumii.com/site_images/2011/11/17/10987937.png" width="96px" height="96px" /><br />
                        <font size="-1" color="#333333" style="display: block !important; line-height: 15px !important; width: 102px !important; font: 12px/15px arial !important; height: 60px !important; margin: 3px 0 0 0 !important; padding: 0 !important; overflow: hidden !important;">IE6下javascript不能隐藏select标签的bug</font>
                    </a>
                </td>
                <td width="102" valign="top" style="padding: 5px !important; margin: 0 !important; border-left: 1px solid #DDDDDD !important;">
                    <a target="_blank" title="IE6 PNG图片不透明问题的解决方法" style="text-decoration: none !important; cursor: pointer !important;" href="http://app.wumii.com/ext/redirect?url=http%3A%2F%2Fjs8.in%2F380.html&from=http%3A%2F%2Fjs8.in%2F944.html">
                        <img style="margin: 0 !important; padding: 2px !important; border: 1px solid #DDDDDD !important; width: 96px !important; height: 96px !important;" src="http://static.wumii.com/site_images/2011/09/01/2770440.png" width="96px" height="96px" /><br />
                        <font size="-1" color="#333333" style="display: block !important; line-height: 15px !important; width: 102px !important; font: 12px/15px arial !important; height: 60px !important; margin: 3px 0 0 0 !important; padding: 0 !important; overflow: hidden !important;">IE6 PNG图片不透明问题的解决方法</font>
                    </a>
                </td>
                <td width="102" valign="top" style="padding: 5px !important; margin: 0 !important; border-left: 1px solid #DDDDDD !important;">
                    <a target="_blank" title="解决IE6 select z-index无效，遮挡div的bug" style="text-decoration: none !important; cursor: pointer !important;" href="http://app.wumii.com/ext/redirect?url=http%3A%2F%2Fjs8.in%2F553.html&from=http%3A%2F%2Fjs8.in%2F944.html">
                        <img style="margin: 0 !important; padding: 2px !important; border: 1px solid #DDDDDD !important; width: 96px !important; height: 96px !important;" src="http://static.wumii.com/site_images/2011/11/17/10987560.png" width="96px" height="96px" /><br />
                        <font size="-1" color="#333333" style="display: block !important; line-height: 15px !important; width: 102px !important; font: 12px/15px arial !important; height: 60px !important; margin: 3px 0 0 0 !important; padding: 0 !important; overflow: hidden !important;">解决IE6 select z-index无效，遮挡div的bug</font>
                    </a>
                </td>
        </tr>
    
    <tr>
        <td colspan="4" align="right">
            <a style="text-decoration: none !important;" href="http://www.wumii.com/widget/relatedItems" target="_blank" title="无觅相关文章插件">
                <font size="-1" color="#bbbbbb" style="display: block !important; font-family: arial !important; padding: 5px 0 !important; font-size: 12px !important; color: #bbb !important;">无觅</font>
            </a>
        </td>
    </tr>
</table>]]></content:encoded>
			<wfw:commentRss>http://js8.in/944.html/feed</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>PHP实现javascript的escape和unescape函数</title>
		<link>http://js8.in/941.html</link>
		<comments>http://js8.in/941.html#comments</comments>
		<pubDate>Fri, 03 Feb 2012 04:57:03 +0000</pubDate>
		<dc:creator>三水清</dc:creator>
				<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[escape]]></category>
		<category><![CDATA[unescape]]></category>

		<guid isPermaLink="false">http://js8.in/?p=941</guid>
		<description><![CDATA[前端开发工程师都知道javascript有编码函数escape()和对应的解码函数unescape()，而php中只有个urlencode和urldecode，这个编码和解码函数对encodeURI和encodeURIComponent有效，但是对escape的是无效的。
javascript中的escape()函数和unescape()函数用户字符串编码，类似于PHP中的urlencode()函数，下面是php实现的escape函数代码：

/** 
 * js escape php 实现 
 * @param $string           the sting want to be escaped 
 * @param $in_encoding       
 * @param $out_encoding      
 */ 
function escape&#40;$string, $in_encoding = 'UTF-8',$out_encoding = 'UCS-2'&#41; [...]<table class="wumii-related-items" cellspacing="0" cellpadding="3" border="0"  style="clear: both;">
    
    <tr>
        <td colspan="4"><b><font size="-1"  style="display: block !important; padding: 20px 0 5px !important;">猜你喜欢：</font></b></td>
    </tr>
    
        <tr>
                <td width="102" valign="top" style="padding: 5px !important; margin: 0 !important;">
                    <a target="_blank" title="PHP生成RSS类：RSS.class.php" style="text-decoration: none !important; cursor: pointer !important;" href="http://app.wumii.com/ext/redirect?url=http%3A%2F%2Fjs8.in%2F412.html&from=http%3A%2F%2Fjs8.in%2F941.html">
                        <img style="margin: 0 !important; padding: 2px !important; border: 1px solid #DDDDDD !important; width: 96px !important; height: 96px !important;" src="http://static.wumii.com/site_images/2011/11/17/10979694.jpg" width="96px" height="96px" /><br />
                        <font size="-1" color="#333333" style="display: block !important; line-height: 15px !important; width: 102px !important; font: 12px/15px arial !important; height: 60px !important; margin: 3px 0 0 0 !important; padding: 0 !important; overflow: hidden !important;">PHP生成RSS类：RSS.class.php</font>
                    </a>
                </td>
                <td width="102" valign="top" style="padding: 5px !important; margin: 0 !important; border-left: 1px solid #DDDDDD !important;">
                    <a target="_blank" title="通过PHP批量下载图片文件" style="text-decoration: none !important; cursor: pointer !important;" href="http://app.wumii.com/ext/redirect?url=http%3A%2F%2Fjs8.in%2F586.html&from=http%3A%2F%2Fjs8.in%2F941.html">
                        <img style="margin: 0 !important; padding: 2px !important; border: 1px solid #DDDDDD !important; width: 96px !important; height: 96px !important;" src="http://static.wumii.com/site_images/2011/11/17/10977771.gif" width="96px" height="96px" /><br />
                        <font size="-1" color="#333333" style="display: block !important; line-height: 15px !important; width: 102px !important; font: 12px/15px arial !important; height: 60px !important; margin: 3px 0 0 0 !important; padding: 0 !important; overflow: hidden !important;">通过PHP批量下载图片文件</font>
                    </a>
                </td>
                <td width="102" valign="top" style="padding: 5px !important; margin: 0 !important; border-left: 1px solid #DDDDDD !important;">
                    <a target="_blank" title="PHP二维数组去重复项函数" style="text-decoration: none !important; cursor: pointer !important;" href="http://app.wumii.com/ext/redirect?url=http%3A%2F%2Fjs8.in%2F475.html&from=http%3A%2F%2Fjs8.in%2F941.html">
                        <img style="margin: 0 !important; padding: 2px !important; border: 1px solid #DDDDDD !important; width: 96px !important; height: 96px !important;" src="http://static.wumii.com/site_images/2011/11/09/10473995.jpg" width="96px" height="96px" /><br />
                        <font size="-1" color="#333333" style="display: block !important; line-height: 15px !important; width: 102px !important; font: 12px/15px arial !important; height: 60px !important; margin: 3px 0 0 0 !important; padding: 0 !important; overflow: hidden !important;">PHP二维数组去重复项函数</font>
                    </a>
                </td>
                <td width="102" valign="top" style="padding: 5px !important; margin: 0 !important; border-left: 1px solid #DDDDDD !important;">
                    <a target="_blank" title="cURL常用的几个PHP函数" style="text-decoration: none !important; cursor: pointer !important;" href="http://app.wumii.com/ext/redirect?url=http%3A%2F%2Fjs8.in%2F379.html&from=http%3A%2F%2Fjs8.in%2F941.html">
                        <img style="margin: 0 !important; padding: 2px !important; border: 1px solid #DDDDDD !important; width: 96px !important; height: 96px !important;" src="http://static.wumii.com/site_images/2011/11/18/11018919.png" width="96px" height="96px" /><br />
                        <font size="-1" color="#333333" style="display: block !important; line-height: 15px !important; width: 102px !important; font: 12px/15px arial !important; height: 60px !important; margin: 3px 0 0 0 !important; padding: 0 !important; overflow: hidden !important;">cURL常用的几个PHP函数</font>
                    </a>
                </td>
        </tr>
    
    <tr>
        <td colspan="4" align="right">
            <a style="text-decoration: none !important;" href="http://www.wumii.com/widget/relatedItems" target="_blank" title="无觅相关文章插件">
                <font size="-1" color="#bbbbbb" style="display: block !important; font-family: arial !important; padding: 5px 0 !important; font-size: 12px !important; color: #bbb !important;">无觅</font>
            </a>
        </td>
    </tr>
</table>]]></description>
			<content:encoded><![CDATA[<p><strong>前端开发</strong>工程师都知道javascript有编码函数<code>escape()</code>和对应的解码函数<code>unescape()</code>，而php中只有个urlencode和urldecode，这个编码和解码函数对encodeURI和encodeURIComponent有效，但是对<strong>escape</strong>的是无效的。</p>
<p>javascript中的escape()函数和unescape()函数用户字符串编码，类似于PHP中的urlencode()函数，下面是php实现的escape函数代码：</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #009933; font-style: italic;">/** 
 * js escape php 实现 
 * @param $string           the sting want to be escaped 
 * @param $in_encoding       
 * @param $out_encoding      
 */</span> 
<span style="color: #000000; font-weight: bold;">function</span> escape<span style="color: #009900;">&#40;</span><span style="color: #000088;">$string</span><span style="color: #339933;">,</span> <span style="color: #000088;">$in_encoding</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">'UTF-8'</span><span style="color: #339933;">,</span><span style="color: #000088;">$out_encoding</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">'UCS-2'</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span> 
    <span style="color: #000088;">$return</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">''</span><span style="color: #339933;">;</span> 
    <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #990000;">function_exists</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'mb_get_info'</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span> 
        <span style="color: #b1b100;">for</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$x</span> <span style="color: #339933;">=</span> <span style="color: #cc66cc;">0</span><span style="color: #339933;">;</span> <span style="color: #000088;">$x</span> <span style="color: #339933;">&lt;</span> <span style="color: #990000;">mb_strlen</span> <span style="color: #009900;">&#40;</span> <span style="color: #000088;">$string</span><span style="color: #339933;">,</span> <span style="color: #000088;">$in_encoding</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #000088;">$x</span> <span style="color: #339933;">++</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span> 
            <span style="color: #000088;">$str</span> <span style="color: #339933;">=</span> <span style="color: #990000;">mb_substr</span> <span style="color: #009900;">&#40;</span> <span style="color: #000088;">$string</span><span style="color: #339933;">,</span> <span style="color: #000088;">$x</span><span style="color: #339933;">,</span> <span style="color: #cc66cc;">1</span><span style="color: #339933;">,</span> <span style="color: #000088;">$in_encoding</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> 
            <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #990000;">strlen</span> <span style="color: #009900;">&#40;</span> <span style="color: #000088;">$str</span> <span style="color: #009900;">&#41;</span> <span style="color: #339933;">&gt;</span> <span style="color: #cc66cc;">1</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span> <span style="color: #666666; font-style: italic;">// 多字节字符 </span>
                <span style="color: #000088;">$return</span> <span style="color: #339933;">.=</span> <span style="color: #0000ff;">'%u'</span> <span style="color: #339933;">.</span> <span style="color: #990000;">strtoupper</span> <span style="color: #009900;">&#40;</span> <span style="color: #990000;">bin2hex</span> <span style="color: #009900;">&#40;</span> <span style="color: #990000;">mb_convert_encoding</span> <span style="color: #009900;">&#40;</span> <span style="color: #000088;">$str</span><span style="color: #339933;">,</span> <span style="color: #000088;">$out_encoding</span><span style="color: #339933;">,</span> <span style="color: #000088;">$in_encoding</span> <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> 
            <span style="color: #009900;">&#125;</span> <span style="color: #b1b100;">else</span> <span style="color: #009900;">&#123;</span> 
                <span style="color: #000088;">$return</span> <span style="color: #339933;">.=</span> <span style="color: #0000ff;">'%'</span> <span style="color: #339933;">.</span> <span style="color: #990000;">strtoupper</span> <span style="color: #009900;">&#40;</span> <span style="color: #990000;">bin2hex</span> <span style="color: #009900;">&#40;</span> <span style="color: #000088;">$str</span> <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> 
            <span style="color: #009900;">&#125;</span> 
        <span style="color: #009900;">&#125;</span> 
    <span style="color: #009900;">&#125;</span> 
    <span style="color: #b1b100;">return</span> <span style="color: #000088;">$return</span><span style="color: #339933;">;</span> 
<span style="color: #009900;">&#125;</span></pre></div></div>

<p><span id="more-941"></span></p>
<p>对应的解码<strong>php unescape</strong>代码是：</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">function</span> unescape<span style="color: #009900;">&#40;</span><span style="color: #000088;">$str</span><span style="color: #009900;">&#41;</span> 
<span style="color: #009900;">&#123;</span> 
    <span style="color: #000088;">$ret</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">''</span><span style="color: #339933;">;</span> 
    <span style="color: #000088;">$len</span> <span style="color: #339933;">=</span> <span style="color: #990000;">strlen</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$str</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> 
    <span style="color: #b1b100;">for</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$i</span> <span style="color: #339933;">=</span> <span style="color: #cc66cc;">0</span><span style="color: #339933;">;</span> <span style="color: #000088;">$i</span> <span style="color: #339933;">&lt;</span> <span style="color: #000088;">$len</span><span style="color: #339933;">;</span> <span style="color: #000088;">$i</span> <span style="color: #339933;">++</span><span style="color: #009900;">&#41;</span> 
    <span style="color: #009900;">&#123;</span> 
        <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$str</span><span style="color: #009900;">&#91;</span><span style="color: #000088;">$i</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">==</span> <span style="color: #0000ff;">'%'</span> <span style="color: #339933;">&amp;&amp;</span> <span style="color: #000088;">$str</span><span style="color: #009900;">&#91;</span><span style="color: #000088;">$i</span> <span style="color: #339933;">+</span> <span style="color: #cc66cc;">1</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">==</span> <span style="color: #0000ff;">'u'</span><span style="color: #009900;">&#41;</span> 
        <span style="color: #009900;">&#123;</span> 
            <span style="color: #000088;">$val</span> <span style="color: #339933;">=</span> <span style="color: #990000;">hexdec</span><span style="color: #009900;">&#40;</span><span style="color: #990000;">substr</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$str</span><span style="color: #339933;">,</span> <span style="color: #000088;">$i</span> <span style="color: #339933;">+</span> <span style="color: #cc66cc;">2</span><span style="color: #339933;">,</span> <span style="color: #cc66cc;">4</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> 
            <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$val</span> <span style="color: #339933;">&lt;</span> <span style="color: #208080;">0x7f</span><span style="color: #009900;">&#41;</span> 
                <span style="color: #000088;">$ret</span> <span style="color: #339933;">.=</span> <span style="color: #990000;">chr</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$val</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> 
            <span style="color: #b1b100;">else</span>  
                <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$val</span> <span style="color: #339933;">&lt;</span> <span style="color: #208080;">0x800</span><span style="color: #009900;">&#41;</span> 
                    <span style="color: #000088;">$ret</span> <span style="color: #339933;">.=</span> <span style="color: #990000;">chr</span><span style="color: #009900;">&#40;</span><span style="color: #208080;">0xc0</span> <span style="color: #339933;">|</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$val</span> <span style="color: #339933;">&gt;&gt;</span> <span style="color: #cc66cc;">6</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">.</span> 
                     <span style="color: #990000;">chr</span><span style="color: #009900;">&#40;</span><span style="color: #208080;">0x80</span> <span style="color: #339933;">|</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$val</span> <span style="color: #339933;">&amp;</span> <span style="color: #208080;">0x3f</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> 
                <span style="color: #b1b100;">else</span> 
                    <span style="color: #000088;">$ret</span> <span style="color: #339933;">.=</span> <span style="color: #990000;">chr</span><span style="color: #009900;">&#40;</span><span style="color: #208080;">0xe0</span> <span style="color: #339933;">|</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$val</span> <span style="color: #339933;">&gt;&gt;</span> <span style="color: #cc66cc;">12</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">.</span> 
                     <span style="color: #990000;">chr</span><span style="color: #009900;">&#40;</span><span style="color: #208080;">0x80</span> <span style="color: #339933;">|</span> <span style="color: #009900;">&#40;</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$val</span> <span style="color: #339933;">&gt;&gt;</span> <span style="color: #cc66cc;">6</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">&amp;</span> <span style="color: #208080;">0x3f</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">.</span> 
                     <span style="color: #990000;">chr</span><span style="color: #009900;">&#40;</span><span style="color: #208080;">0x80</span> <span style="color: #339933;">|</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$val</span> <span style="color: #339933;">&amp;</span> <span style="color: #208080;">0x3f</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> 
            <span style="color: #000088;">$i</span> <span style="color: #339933;">+=</span> <span style="color: #cc66cc;">5</span><span style="color: #339933;">;</span> 
        <span style="color: #009900;">&#125;</span> <span style="color: #b1b100;">else</span>  
            <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$str</span><span style="color: #009900;">&#91;</span><span style="color: #000088;">$i</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">==</span> <span style="color: #0000ff;">'%'</span><span style="color: #009900;">&#41;</span> 
            <span style="color: #009900;">&#123;</span> 
                <span style="color: #000088;">$ret</span> <span style="color: #339933;">.=</span> <span style="color: #990000;">urldecode</span><span style="color: #009900;">&#40;</span><span style="color: #990000;">substr</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$str</span><span style="color: #339933;">,</span> <span style="color: #000088;">$i</span><span style="color: #339933;">,</span> <span style="color: #cc66cc;">3</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> 
                <span style="color: #000088;">$i</span> <span style="color: #339933;">+=</span> <span style="color: #cc66cc;">2</span><span style="color: #339933;">;</span> 
            <span style="color: #009900;">&#125;</span> <span style="color: #b1b100;">else</span> 
                <span style="color: #000088;">$ret</span> <span style="color: #339933;">.=</span> <span style="color: #000088;">$str</span><span style="color: #009900;">&#91;</span><span style="color: #000088;">$i</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span> 
    <span style="color: #009900;">&#125;</span> 
    <span style="color: #b1b100;">return</span> <span style="color: #000088;">$ret</span><span style="color: #339933;">;</span> 
<span style="color: #009900;">&#125;</span></pre></div></div>

<div class="copyright">
<strong>声明：</strong>文章未声明为原创文章，本文链接 <a href="http://js8.in/941.html" title="PHP实现javascript的escape和unescape函数">http://js8.in/941.html</a>. 转载请注明转自<a href="http://js8.in" title="前端开发博客"> JS8.IN ™</a></span></span></div>
<h3 class="box-title">随机文章</h3>
<ul class="box_random">
<li><a href="http://js8.in/706.html" title="IE6中a标签location.href失效解决方法" rel="bookmark inlinks">IE6中a标签location.href失效解决方法</a></li>
<li><a href="http://js8.in/460.html" title="做个中国工会网竟然670万！" rel="bookmark inlinks">做个中国工会网竟然670万！</a></li>
<li><a href="http://js8.in/33.html" title="音乐版上线" rel="bookmark inlinks">音乐版上线</a></li>
<li><a href="http://js8.in/554.html" title="引入CSS 的两种方式：link和@import的区别" rel="bookmark inlinks">引入CSS 的两种方式：link和@import的区别</a></li>
<li><a href="http://js8.in/558.html" title="onbeforeunload与a标签在IE中的冲突bug" rel="bookmark inlinks">onbeforeunload与a标签在IE中的冲突bug</a></li>
<li><a href="http://js8.in/479.html" title="CSS+jQuery实现滑动幻灯片实例详解" rel="bookmark inlinks">CSS+jQuery实现滑动幻灯片实例详解</a></li>
<li><a href="http://js8.in/557.html" title="解决IE6背景图片不缓存的BUG" rel="bookmark inlinks">解决IE6背景图片不缓存的BUG</a></li>
<li><a href="http://js8.in/644.html" title="利用google博客的ping服务接口API加快网站收录" rel="bookmark inlinks">利用google博客的ping服务接口API加快网站收录</a></li>
</ul>
<hr />
<p><small>© 三水清 for <a href="http://js8.in">三水清</a>, 2012. |
<a href="http://js8.in/941.html#comments">No comment</a> |在微博关注我：<a href="//weibo.com/sanshuiqing" target="_blank" title="关注断桥残雪的新浪微博">@清-三水清</a>
<br/>收藏到：
<a rel="nofollow" href="http://share.renren.com/share/buttonshare.do?link=%posturl%&title=%posttitle%" title="收藏本文到人人网" target="_blank">人人网</a> | <a rel="nofollow" href="http://www.douban.com/recommend/?url=%posturl%&title=%posttitle%" title="收藏本文到豆瓣" target="_blank">豆瓣</a> | <a rel="nofollow" href="http://www.kaixin001.com/repaste/share.php?rtitle=%posttitle%&rurl=%posturl%" title="收藏本文到开心网" target="_blank">开心网</a> | <a rel="nofollow" href="http://shuqian.qq.com/post?title=%posttitle%&%20uri=%posturl%" title="收藏本文到QQ书签" target="_blank">QQ书签</a> | <a rel="nofollow" href="http://v.t.sina.com.cn/share/share.php?url=%posturl%&title=%posttitle%" title="收藏本文到新浪微博" target="_blank">新浪微博</a> | <a rel="nofollow" href="http://v.t.qq.com/share/share.php?title=%posttitle%&url=%posturl%&site=http://www.kaixin100.info" title="收藏本文到腾讯微博" target="_blank">腾讯微博</a>
<br/>
Post tags: <a href="http://js8.in/tag/escape" rel="tag">escape</a>, <a href="http://js8.in/tag/php" rel="tag">php</a>, <a href="http://js8.in/tag/unescape" rel="tag">unescape</a><br/>
</small></p><table class="wumii-related-items" cellspacing="0" cellpadding="3" border="0"  style="clear: both;">
    
    <tr>
        <td colspan="4"><b><font size="-1"  style="display: block !important; padding: 20px 0 5px !important;">猜你喜欢：</font></b></td>
    </tr>
    
        <tr>
                <td width="102" valign="top" style="padding: 5px !important; margin: 0 !important;">
                    <a target="_blank" title="PHP生成RSS类：RSS.class.php" style="text-decoration: none !important; cursor: pointer !important;" href="http://app.wumii.com/ext/redirect?url=http%3A%2F%2Fjs8.in%2F412.html&from=http%3A%2F%2Fjs8.in%2F941.html">
                        <img style="margin: 0 !important; padding: 2px !important; border: 1px solid #DDDDDD !important; width: 96px !important; height: 96px !important;" src="http://static.wumii.com/site_images/2011/11/17/10979694.jpg" width="96px" height="96px" /><br />
                        <font size="-1" color="#333333" style="display: block !important; line-height: 15px !important; width: 102px !important; font: 12px/15px arial !important; height: 60px !important; margin: 3px 0 0 0 !important; padding: 0 !important; overflow: hidden !important;">PHP生成RSS类：RSS.class.php</font>
                    </a>
                </td>
                <td width="102" valign="top" style="padding: 5px !important; margin: 0 !important; border-left: 1px solid #DDDDDD !important;">
                    <a target="_blank" title="通过PHP批量下载图片文件" style="text-decoration: none !important; cursor: pointer !important;" href="http://app.wumii.com/ext/redirect?url=http%3A%2F%2Fjs8.in%2F586.html&from=http%3A%2F%2Fjs8.in%2F941.html">
                        <img style="margin: 0 !important; padding: 2px !important; border: 1px solid #DDDDDD !important; width: 96px !important; height: 96px !important;" src="http://static.wumii.com/site_images/2011/11/17/10977771.gif" width="96px" height="96px" /><br />
                        <font size="-1" color="#333333" style="display: block !important; line-height: 15px !important; width: 102px !important; font: 12px/15px arial !important; height: 60px !important; margin: 3px 0 0 0 !important; padding: 0 !important; overflow: hidden !important;">通过PHP批量下载图片文件</font>
                    </a>
                </td>
                <td width="102" valign="top" style="padding: 5px !important; margin: 0 !important; border-left: 1px solid #DDDDDD !important;">
                    <a target="_blank" title="PHP二维数组去重复项函数" style="text-decoration: none !important; cursor: pointer !important;" href="http://app.wumii.com/ext/redirect?url=http%3A%2F%2Fjs8.in%2F475.html&from=http%3A%2F%2Fjs8.in%2F941.html">
                        <img style="margin: 0 !important; padding: 2px !important; border: 1px solid #DDDDDD !important; width: 96px !important; height: 96px !important;" src="http://static.wumii.com/site_images/2011/11/09/10473995.jpg" width="96px" height="96px" /><br />
                        <font size="-1" color="#333333" style="display: block !important; line-height: 15px !important; width: 102px !important; font: 12px/15px arial !important; height: 60px !important; margin: 3px 0 0 0 !important; padding: 0 !important; overflow: hidden !important;">PHP二维数组去重复项函数</font>
                    </a>
                </td>
                <td width="102" valign="top" style="padding: 5px !important; margin: 0 !important; border-left: 1px solid #DDDDDD !important;">
                    <a target="_blank" title="cURL常用的几个PHP函数" style="text-decoration: none !important; cursor: pointer !important;" href="http://app.wumii.com/ext/redirect?url=http%3A%2F%2Fjs8.in%2F379.html&from=http%3A%2F%2Fjs8.in%2F941.html">
                        <img style="margin: 0 !important; padding: 2px !important; border: 1px solid #DDDDDD !important; width: 96px !important; height: 96px !important;" src="http://static.wumii.com/site_images/2011/11/18/11018919.png" width="96px" height="96px" /><br />
                        <font size="-1" color="#333333" style="display: block !important; line-height: 15px !important; width: 102px !important; font: 12px/15px arial !important; height: 60px !important; margin: 3px 0 0 0 !important; padding: 0 !important; overflow: hidden !important;">cURL常用的几个PHP函数</font>
                    </a>
                </td>
        </tr>
    
    <tr>
        <td colspan="4" align="right">
            <a style="text-decoration: none !important;" href="http://www.wumii.com/widget/relatedItems" target="_blank" title="无觅相关文章插件">
                <font size="-1" color="#bbbbbb" style="display: block !important; font-family: arial !important; padding: 5px 0 !important; font-size: 12px !important; color: #bbb !important;">无觅</font>
            </a>
        </td>
    </tr>
</table>]]></content:encoded>
			<wfw:commentRss>http://js8.in/941.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>javascript contains方法来判断元素包含关系</title>
		<link>http://js8.in/934.html</link>
		<comments>http://js8.in/934.html#comments</comments>
		<pubDate>Thu, 05 Jan 2012 01:49:20 +0000</pubDate>
		<dc:creator>三水清</dc:creator>
				<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[contains]]></category>
		<category><![CDATA[javascript]]></category>

		<guid isPermaLink="false">http://js8.in/?p=934</guid>
		<description><![CDATA[IE中的contains方法可以判断A元素是否包含B元素，如果包含则返回true，否则返回false，在开发中会在事件代理处理上面用到。W3C的方法是compareDocumentPosition，所以综上来说：JS通过contains和compareDocumentPosition方法来确定DOM节点间的关系,判断一个元素(对象)是否为另一个元素的子元素。
IE的contains方法很简单，但是W3C的DOMElement.contains(DOMNode)方法会返回却是一个数值。
DOMElement.contains(DOMNode)
link：https://developer.mozilla.org/En/DOM/Node.compareDocumentPosition。
DOMElement.contains(DOMNode)返回的不是一个布尔值，而是一个很奇怪的数值，它是通过如下方式累加计算出来的：





      


Bits
Number
Meaning




000000
0
元素一致


000001
1
节点在不同的文档（或者一个在文档之外）


000010
2
节点 B 在节点 A 之前


000100
4
节点 A 在节点 B 之前 


001000
8
节点 B 包含节点 A


010000
16
节点 A 包含节点 B


100000 
32
浏览器的私有使用 




综上，来个@司徒正美 大大的方案：

var contains  = function&#40;root, el&#41; &#123;
	 if &#40;root.compareDocumentPosition&#41;
		 return root === el &#124;&#124; !!&#40;root.compareDocumentPosition&#40;el&#41; &#38; 16&#41;;
	 if &#40;root.contains &#38;&#38; el.nodeType === 1&#41;&#123;
		 return root.contains&#40;el&#41; &#38;&#38; root !== el;
	 &#125;
	 while [...]<table class="wumii-related-items" cellspacing="0" cellpadding="3" border="0"  style="clear: both;">
    
    <tr>
        <td colspan="4"><b><font size="-1"  style="display: block !important; padding: 20px 0 5px !important;">猜你喜欢：</font></b></td>
    </tr>
    
        <tr>
                <td width="102" valign="top" style="padding: 5px !important; margin: 0 !important;">
                    <a target="_blank" title="Javascript事件触发列表与详解" style="text-decoration: none !important; cursor: pointer !important;" href="http://app.wumii.com/ext/redirect?url=http%3A%2F%2Fjs8.in%2F480.html&from=http%3A%2F%2Fjs8.in%2F934.html">
                        <img style="margin: 0 !important; padding: 2px !important; border: 1px solid #DDDDDD !important; width: 96px !important; height: 96px !important;" src="http://static.wumii.com/site_images/2011/11/17/10982510.bmp" width="96px" height="96px" /><br />
                        <font size="-1" color="#333333" style="display: block !important; line-height: 15px !important; width: 102px !important; font: 12px/15px arial !important; height: 60px !important; margin: 3px 0 0 0 !important; padding: 0 !important; overflow: hidden !important;">Javascript事件触发列表与详解</font>
                    </a>
                </td>
                <td width="102" valign="top" style="padding: 5px !important; margin: 0 !important; border-left: 1px solid #DDDDDD !important;">
                    <a target="_blank" title="javascript获取光标位置以及设置光标位置" style="text-decoration: none !important; cursor: pointer !important;" href="http://app.wumii.com/ext/redirect?url=http%3A%2F%2Fjs8.in%2F466.html&from=http%3A%2F%2Fjs8.in%2F934.html">
                        <img style="margin: 0 !important; padding: 2px !important; border: 1px solid #DDDDDD !important; width: 96px !important; height: 96px !important;" src="http://static.wumii.com/site_images/2011/11/17/10979320.jpg" width="96px" height="96px" /><br />
                        <font size="-1" color="#333333" style="display: block !important; line-height: 15px !important; width: 102px !important; font: 12px/15px arial !important; height: 60px !important; margin: 3px 0 0 0 !important; padding: 0 !important; overflow: hidden !important;">javascript获取光标位置以及设置光标位置</font>
                    </a>
                </td>
                <td width="102" valign="top" style="padding: 5px !important; margin: 0 !important; border-left: 1px solid #DDDDDD !important;">
                    <a target="_blank" title="非字母javascript" style="text-decoration: none !important; cursor: pointer !important;" href="http://app.wumii.com/ext/redirect?url=http%3A%2F%2Fjs8.in%2F918.html&from=http%3A%2F%2Fjs8.in%2F934.html">
                        <img style="margin: 0 !important; padding: 2px !important; border: 1px solid #DDDDDD !important; width: 96px !important; height: 96px !important;" src="http://static.wumii.com/site_images/2011/11/30/11698517.jpg" width="96px" height="96px" /><br />
                        <font size="-1" color="#333333" style="display: block !important; line-height: 15px !important; width: 102px !important; font: 12px/15px arial !important; height: 60px !important; margin: 3px 0 0 0 !important; padding: 0 !important; overflow: hidden !important;">非字母javascript</font>
                    </a>
                </td>
                <td width="102" valign="top" style="padding: 5px !important; margin: 0 !important; border-left: 1px solid #DDDDDD !important;">
                    <a target="_blank" title="JavaScript跨浏览器的添加删除事件绑定函数" style="text-decoration: none !important; cursor: pointer !important;" href="http://app.wumii.com/ext/redirect?url=http%3A%2F%2Fjs8.in%2F408.html&from=http%3A%2F%2Fjs8.in%2F934.html">
                        <img style="margin: 0 !important; padding: 2px !important; border: 1px solid #DDDDDD !important; width: 96px !important; height: 96px !important;" src="http://static.wumii.com/site_images/2011/11/17/10978769.bmp" width="96px" height="96px" /><br />
                        <font size="-1" color="#333333" style="display: block !important; line-height: 15px !important; width: 102px !important; font: 12px/15px arial !important; height: 60px !important; margin: 3px 0 0 0 !important; padding: 0 !important; overflow: hidden !important;">JavaScript跨浏览器的添加删除事件绑定函数</font>
                    </a>
                </td>
        </tr>
    
    <tr>
        <td colspan="4" align="right">
            <a style="text-decoration: none !important;" href="http://www.wumii.com/widget/relatedItems" target="_blank" title="无觅相关文章插件">
                <font size="-1" color="#bbbbbb" style="display: block !important; font-family: arial !important; padding: 5px 0 !important; font-size: 12px !important; color: #bbb !important;">无觅</font>
            </a>
        </td>
    </tr>
</table>]]></description>
			<content:encoded><![CDATA[<p>IE中的<strong>contains</strong>方法可以判断A元素是否包含B元素，如果包含则返回true，否则返回false，在开发中会在事件代理处理上面用到。W3C的方法是<strong>compareDocumentPosition</strong>，所以综上来说：JS通过contains和compareDocumentPosition方法来确定DOM节点间的关系,判断一个元素(对象)是否为另一个元素的子元素。<br />
IE的contains方法很简单，但是W3C的<code>DOMElement.contains(DOMNode)</code>方法会返回却是一个数值。</p>
<h2>DOMElement.contains(DOMNode)</h2>
<p>link：<a target="_blank" target="_blank" href="https://developer.mozilla.org/En/DOM/Node.compareDocumentPosition">https://developer.mozilla.org/En/DOM/Node.compareDocumentPosition</a>。</p>
<p><code>DOMElement.contains(DOMNode)</code>返回的不是一个布尔值，而是一个很奇怪的数值，它是通过如下方式累加计算出来的：</p>
<table class="filament_table" cellspacing="0" width="80%" rules="cols" border="1">
<colgroup>
<col class="grey" width="20%">
<col class="yellow" width="20%">
<col class="grey">
      </colgroup>
<thead>
<tr>
<th>Bits</th>
<th>Number</th>
<th>Meaning</th>
</tr>
</thead>
<tbody>
<tr>
<td>000000</td>
<td>0</td>
<td>元素一致</td>
</tr>
<tr>
<td>000001</td>
<td>1</td>
<td>节点在不同的文档（或者一个在文档之外）</td>
</tr>
<tr>
<td>000010</td>
<td>2</td>
<td>节点 B 在节点 A 之前</td>
</tr>
<tr>
<td>000100</td>
<td>4</td>
<td>节点 A 在节点 B 之前 </td>
</tr>
<tr>
<td>001000</td>
<td>8</td>
<td>节点 B 包含节点 A</td>
</tr>
<tr>
<td>010000</td>
<td>16</td>
<td>节点 A 包含节点 B</td>
</tr>
<tr>
<td>100000 </td>
<td>32</td>
<td>浏览器的私有使用 </td>
</tr>
</tbody>
</table>
<p><span id="more-934"></span><br />
综上，来个@司徒正美 大大的方案：</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #003366; font-weight: bold;">var</span> contains  <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span>root<span style="color: #339933;">,</span> el<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
	 <span style="color: #000066; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>root.<span style="color: #660066;">compareDocumentPosition</span><span style="color: #009900;">&#41;</span>
		 <span style="color: #000066; font-weight: bold;">return</span> root <span style="color: #339933;">===</span> el <span style="color: #339933;">||</span> <span style="color: #339933;">!!</span><span style="color: #009900;">&#40;</span>root.<span style="color: #660066;">compareDocumentPosition</span><span style="color: #009900;">&#40;</span>el<span style="color: #009900;">&#41;</span> <span style="color: #339933;">&amp;</span> <span style="color: #CC0000;">16</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	 <span style="color: #000066; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>root.<span style="color: #660066;">contains</span> <span style="color: #339933;">&amp;&amp;</span> el.<span style="color: #660066;">nodeType</span> <span style="color: #339933;">===</span> <span style="color: #CC0000;">1</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
		 <span style="color: #000066; font-weight: bold;">return</span> root.<span style="color: #660066;">contains</span><span style="color: #009900;">&#40;</span>el<span style="color: #009900;">&#41;</span> <span style="color: #339933;">&amp;&amp;</span> root <span style="color: #339933;">!==</span> el<span style="color: #339933;">;</span>
	 <span style="color: #009900;">&#125;</span>
	 <span style="color: #000066; font-weight: bold;">while</span> <span style="color: #009900;">&#40;</span><span style="color: #009900;">&#40;</span>el <span style="color: #339933;">=</span> el.<span style="color: #660066;">parentNode</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span>
		 <span style="color: #000066; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>el <span style="color: #339933;">===</span> root<span style="color: #009900;">&#41;</span> <span style="color: #000066; font-weight: bold;">return</span> <span style="color: #003366; font-weight: bold;">true</span><span style="color: #339933;">;</span>
	 <span style="color: #000066; font-weight: bold;">return</span> <span style="color: #003366; font-weight: bold;">false</span><span style="color: #339933;">;</span>
 <span style="color: #009900;">&#125;</span></pre></div></div>

<div class="copyright">
<strong>声明：</strong>文章未声明为原创文章，本文链接 <a href="http://js8.in/934.html" title="javascript contains方法来判断元素包含关系">http://js8.in/934.html</a>. 转载请注明转自<a href="http://js8.in" title="前端开发博客"> JS8.IN ™</a></span></span></div>
<h3 class="box-title">随机文章</h3>
<ul class="box_random">
<li><a href="http://js8.in/374.html" title="发布WordPress来访者天气预报插件" rel="bookmark inlinks">发布WordPress来访者天气预报插件</a></li>
<li><a href="http://js8.in/594.html" title="JS的Image对象可用于检测图片类型是否合法" rel="bookmark inlinks">JS的Image对象可用于检测图片类型是否合法</a></li>
<li><a href="http://js8.in/342.html" title="php、js两种不同方式根据关键词返回经纬度接口【基于Google map API】" rel="bookmark inlinks">php、js两种不同方式根据关键词返回经纬度接口【基于Google map API】</a></li>
<li><a href="http://js8.in/272.html" title="普通话考试！~" rel="bookmark inlinks">普通话考试！~</a></li>
<li><a href="http://js8.in/289.html" title="用批处理说中文！" rel="bookmark inlinks">用批处理说中文！</a></li>
<li><a href="http://js8.in/538.html" title="javascript在光标位置插入内容" rel="bookmark inlinks">javascript在光标位置插入内容</a></li>
<li><a href="http://js8.in/378.html" title="樱花草，假如爱有天意" rel="bookmark inlinks">樱花草，假如爱有天意</a></li>
<li><a href="http://js8.in/467.html" title="Javascript设置光标位置到结尾并显示出来" rel="bookmark inlinks">Javascript设置光标位置到结尾并显示出来</a></li>
</ul>
<hr />
<p><small>© 三水清 for <a href="http://js8.in">三水清</a>, 2012. |
<a href="http://js8.in/934.html#comments">One comment</a> |在微博关注我：<a href="//weibo.com/sanshuiqing" target="_blank" title="关注断桥残雪的新浪微博">@清-三水清</a>
<br/>收藏到：
<a rel="nofollow" href="http://share.renren.com/share/buttonshare.do?link=%posturl%&title=%posttitle%" title="收藏本文到人人网" target="_blank">人人网</a> | <a rel="nofollow" href="http://www.douban.com/recommend/?url=%posturl%&title=%posttitle%" title="收藏本文到豆瓣" target="_blank">豆瓣</a> | <a rel="nofollow" href="http://www.kaixin001.com/repaste/share.php?rtitle=%posttitle%&rurl=%posturl%" title="收藏本文到开心网" target="_blank">开心网</a> | <a rel="nofollow" href="http://shuqian.qq.com/post?title=%posttitle%&%20uri=%posturl%" title="收藏本文到QQ书签" target="_blank">QQ书签</a> | <a rel="nofollow" href="http://v.t.sina.com.cn/share/share.php?url=%posturl%&title=%posttitle%" title="收藏本文到新浪微博" target="_blank">新浪微博</a> | <a rel="nofollow" href="http://v.t.qq.com/share/share.php?title=%posttitle%&url=%posturl%&site=http://www.kaixin100.info" title="收藏本文到腾讯微博" target="_blank">腾讯微博</a>
<br/>
Post tags: <a href="http://js8.in/tag/contains" rel="tag">contains</a>, <a href="http://js8.in/tag/javascript" rel="tag">javascript</a><br/>
</small></p><table class="wumii-related-items" cellspacing="0" cellpadding="3" border="0"  style="clear: both;">
    
    <tr>
        <td colspan="4"><b><font size="-1"  style="display: block !important; padding: 20px 0 5px !important;">猜你喜欢：</font></b></td>
    </tr>
    
        <tr>
                <td width="102" valign="top" style="padding: 5px !important; margin: 0 !important;">
                    <a target="_blank" title="Javascript事件触发列表与详解" style="text-decoration: none !important; cursor: pointer !important;" href="http://app.wumii.com/ext/redirect?url=http%3A%2F%2Fjs8.in%2F480.html&from=http%3A%2F%2Fjs8.in%2F934.html">
                        <img style="margin: 0 !important; padding: 2px !important; border: 1px solid #DDDDDD !important; width: 96px !important; height: 96px !important;" src="http://static.wumii.com/site_images/2011/11/17/10982510.bmp" width="96px" height="96px" /><br />
                        <font size="-1" color="#333333" style="display: block !important; line-height: 15px !important; width: 102px !important; font: 12px/15px arial !important; height: 60px !important; margin: 3px 0 0 0 !important; padding: 0 !important; overflow: hidden !important;">Javascript事件触发列表与详解</font>
                    </a>
                </td>
                <td width="102" valign="top" style="padding: 5px !important; margin: 0 !important; border-left: 1px solid #DDDDDD !important;">
                    <a target="_blank" title="javascript获取光标位置以及设置光标位置" style="text-decoration: none !important; cursor: pointer !important;" href="http://app.wumii.com/ext/redirect?url=http%3A%2F%2Fjs8.in%2F466.html&from=http%3A%2F%2Fjs8.in%2F934.html">
                        <img style="margin: 0 !important; padding: 2px !important; border: 1px solid #DDDDDD !important; width: 96px !important; height: 96px !important;" src="http://static.wumii.com/site_images/2011/11/17/10979320.jpg" width="96px" height="96px" /><br />
                        <font size="-1" color="#333333" style="display: block !important; line-height: 15px !important; width: 102px !important; font: 12px/15px arial !important; height: 60px !important; margin: 3px 0 0 0 !important; padding: 0 !important; overflow: hidden !important;">javascript获取光标位置以及设置光标位置</font>
                    </a>
                </td>
                <td width="102" valign="top" style="padding: 5px !important; margin: 0 !important; border-left: 1px solid #DDDDDD !important;">
                    <a target="_blank" title="非字母javascript" style="text-decoration: none !important; cursor: pointer !important;" href="http://app.wumii.com/ext/redirect?url=http%3A%2F%2Fjs8.in%2F918.html&from=http%3A%2F%2Fjs8.in%2F934.html">
                        <img style="margin: 0 !important; padding: 2px !important; border: 1px solid #DDDDDD !important; width: 96px !important; height: 96px !important;" src="http://static.wumii.com/site_images/2011/11/30/11698517.jpg" width="96px" height="96px" /><br />
                        <font size="-1" color="#333333" style="display: block !important; line-height: 15px !important; width: 102px !important; font: 12px/15px arial !important; height: 60px !important; margin: 3px 0 0 0 !important; padding: 0 !important; overflow: hidden !important;">非字母javascript</font>
                    </a>
                </td>
                <td width="102" valign="top" style="padding: 5px !important; margin: 0 !important; border-left: 1px solid #DDDDDD !important;">
                    <a target="_blank" title="JavaScript跨浏览器的添加删除事件绑定函数" style="text-decoration: none !important; cursor: pointer !important;" href="http://app.wumii.com/ext/redirect?url=http%3A%2F%2Fjs8.in%2F408.html&from=http%3A%2F%2Fjs8.in%2F934.html">
                        <img style="margin: 0 !important; padding: 2px !important; border: 1px solid #DDDDDD !important; width: 96px !important; height: 96px !important;" src="http://static.wumii.com/site_images/2011/11/17/10978769.bmp" width="96px" height="96px" /><br />
                        <font size="-1" color="#333333" style="display: block !important; line-height: 15px !important; width: 102px !important; font: 12px/15px arial !important; height: 60px !important; margin: 3px 0 0 0 !important; padding: 0 !important; overflow: hidden !important;">JavaScript跨浏览器的添加删除事件绑定函数</font>
                    </a>
                </td>
        </tr>
    
    <tr>
        <td colspan="4" align="right">
            <a style="text-decoration: none !important;" href="http://www.wumii.com/widget/relatedItems" target="_blank" title="无觅相关文章插件">
                <font size="-1" color="#bbbbbb" style="display: block !important; font-family: arial !important; padding: 5px 0 !important; font-size: 12px !important; color: #bbb !important;">无觅</font>
            </a>
        </td>
    </tr>
</table>]]></content:encoded>
			<wfw:commentRss>http://js8.in/934.html/feed</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>使用webbench做压力测试</title>
		<link>http://js8.in/930.html</link>
		<comments>http://js8.in/930.html#comments</comments>
		<pubDate>Wed, 04 Jan 2012 07:37:38 +0000</pubDate>
		<dc:creator>三水清</dc:creator>
				<category><![CDATA[网络技术]]></category>
		<category><![CDATA[linux]]></category>
		<category><![CDATA[webbench]]></category>
		<category><![CDATA[压力测试]]></category>

		<guid isPermaLink="false">http://js8.in/?p=930</guid>
		<description><![CDATA[元旦假期帮朋友折腾VPS，安装了centOS和lnmp，网站部好了，而且定时任务也加上了，觉得应该做个压力测试，之前用过apache自带的ab，不过今天使用的是webbench做压力测试。备份下安装测试过程。
首先我们先来安装webbench吧, 为了测试准确，请将 webbench 安装在别的linux服务器上, 因为webbench 做压力测试时，自身也会消耗CPU和内存资源, 否则, 很可能把自己服务器搞挂掉。于是我切换到了ubuntu系统做webbench测试。
安装webbench
安装过程比较简单，如果你的机子之前安装过一些常用软件直接使用下面的命令就可以了：
wget http://home.tiscali.cz/~cz210552/distfiles/webbench-1.5.tar.gz
tar zxvf webbench-1.5.tar.gz
cd webbench-1.5
make &#038;&#038; make install
webbench安装报错
没有安装ctags
如果没有安装 ctags make 编译会报错：/bin/sh: ctags: command not found
这时当然是要安装ctags啦，于是：
apt-get install ctags
搞定
没有安装gcc
这时候可能会报错：
cc: Command not found
这时需要gcc：
apt-get install gcc
其他报错
如果出现下面的错误：
cannot create regular file `/usr/local/man/man1&#8242;: No such file or directory

这时需要创建/usr/local/man/man1文件来解决：
mkdir -m 644 -p /usr/local/man/man1
使用webbench做压力测试
经过上面的折腾，webbench终于安装好了，下面要做的就是做个压力测试了，在shell里面输入下面的命令：
webbench -c 500 -t 30 http://127.0.0.1/test.jpg
参数说明：-c表示并发数，-t表示时间(秒)
最后就会出现详细的测试信息了：
Webbench &#8211; Simple Web Benchmark 1.5
Copyright (c) Radim Kolar [...]<table class="wumii-related-items" cellspacing="0" cellpadding="3" border="0"  style="clear: both;">
    
    <tr>
        <td colspan="4"><b><font size="-1"  style="display: block !important; padding: 20px 0 5px !important;">猜你喜欢：</font></b></td>
    </tr>
    
        <tr>
                <td width="102" valign="top" style="padding: 5px !important; margin: 0 !important;">
                    <a target="_blank" title="linux安装PHP加速器eAccelerator" style="text-decoration: none !important; cursor: pointer !important;" href="http://app.wumii.com/ext/redirect?url=http%3A%2F%2Fjs8.in%2F888.html&from=http%3A%2F%2Fjs8.in%2F930.html">
                        <img style="margin: 0 !important; padding: 2px !important; border: 1px solid #DDDDDD !important; width: 96px !important; height: 96px !important;" src="http://static.wumii.com/site_images/2011/09/15/12184400.jpg" width="96px" height="96px" /><br />
                        <font size="-1" color="#333333" style="display: block !important; line-height: 15px !important; width: 102px !important; font: 12px/15px arial !important; height: 60px !important; margin: 3px 0 0 0 !important; padding: 0 !important; overflow: hidden !important;">linux安装PHP加速器eAccelerator</font>
                    </a>
                </td>
                <td width="102" valign="top" style="padding: 5px !important; margin: 0 !important; border-left: 1px solid #DDDDDD !important;">
                    <a target="_blank" title="jQuery1.4正式版新功能及性能测试" style="text-decoration: none !important; cursor: pointer !important;" href="http://app.wumii.com/ext/redirect?url=http%3A%2F%2Fjs8.in%2F450.html&from=http%3A%2F%2Fjs8.in%2F930.html">
                        <img style="margin: 0 !important; padding: 2px !important; border: 1px solid #DDDDDD !important; width: 96px !important; height: 96px !important;" src="http://static.wumii.com/site_images/2011/11/18/11026546.jpg" width="96px" height="96px" /><br />
                        <font size="-1" color="#333333" style="display: block !important; line-height: 15px !important; width: 102px !important; font: 12px/15px arial !important; height: 60px !important; margin: 3px 0 0 0 !important; padding: 0 !important; overflow: hidden !important;">jQuery1.4正式版新功能及性能测试</font>
                    </a>
                </td>
                <td width="102" valign="top" style="padding: 5px !important; margin: 0 !important; border-left: 1px solid #DDDDDD !important;">
                    <a target="_blank" title="Ubuntu安装Samba实现跟windows文件共享" style="text-decoration: none !important; cursor: pointer !important;" href="http://app.wumii.com/ext/redirect?url=http%3A%2F%2Fjs8.in%2F526.html&from=http%3A%2F%2Fjs8.in%2F930.html">
                        <img style="margin: 0 !important; padding: 2px !important; border: 1px solid #DDDDDD !important; width: 96px !important; height: 96px !important;" src="http://static.wumii.com/site_images/2011/11/17/10979469.jpg" width="96px" height="96px" /><br />
                        <font size="-1" color="#333333" style="display: block !important; line-height: 15px !important; width: 102px !important; font: 12px/15px arial !important; height: 60px !important; margin: 3px 0 0 0 !important; padding: 0 !important; overflow: hidden !important;">Ubuntu安装Samba实现跟windows文件共享</font>
                    </a>
                </td>
                <td width="102" valign="top" style="padding: 5px !important; margin: 0 !important; border-left: 1px solid #DDDDDD !important;">
                    <a target="_blank" title="使用windows7的virtual PC打造原装IE6、IE7、IE8测试环境" style="text-decoration: none !important; cursor: pointer !important;" href="http://app.wumii.com/ext/redirect?url=http%3A%2F%2Fjs8.in%2F688.html&from=http%3A%2F%2Fjs8.in%2F930.html">
                        <img style="margin: 0 !important; padding: 2px !important; border: 1px solid #DDDDDD !important; width: 96px !important; height: 96px !important;" src="http://static.wumii.com/site_images/2011/11/17/10978881.png" width="96px" height="96px" /><br />
                        <font size="-1" color="#333333" style="display: block !important; line-height: 15px !important; width: 102px !important; font: 12px/15px arial !important; height: 60px !important; margin: 3px 0 0 0 !important; padding: 0 !important; overflow: hidden !important;">使用windows7的virtual PC打造原装IE6、IE7、IE8测试环境</font>
                    </a>
                </td>
        </tr>
    
    <tr>
        <td colspan="4" align="right">
            <a style="text-decoration: none !important;" href="http://www.wumii.com/widget/relatedItems" target="_blank" title="无觅相关文章插件">
                <font size="-1" color="#bbbbbb" style="display: block !important; font-family: arial !important; padding: 5px 0 !important; font-size: 12px !important; color: #bbb !important;">无觅</font>
            </a>
        </td>
    </tr>
</table>]]></description>
			<content:encoded><![CDATA[<p>元旦假期帮朋友折腾VPS，安装了centOS和lnmp，网站部好了，而且定时任务也加上了，觉得应该做个压力测试，之前用过apache自带的ab，不过今天使用的是<strong>webbench</strong>做压力测试。备份下安装测试过程。<br />
首先我们先来安装webbench吧, 为了测试准确，请将 webbench 安装在别的linux服务器上, 因为webbench 做压力测试时，自身也会消耗CPU和内存资源, 否则, 很可能把自己服务器搞挂掉。于是我切换到了ubuntu系统做<strong>webbench测试</strong>。</p>
<h2>安装webbench</h2>
<p>安装过程比较简单，如果你的机子之前安装过一些常用软件直接使用下面的命令就可以了：</p>
<blockquote><p>wget http://home.tiscali.cz/~cz210552/distfiles/webbench-1.5.tar.gz<br />
tar zxvf webbench-1.5.tar.gz<br />
cd webbench-1.5<br />
make &#038;&#038; make install</p></blockquote>
<h2>webbench安装报错</h2>
<h3>没有安装ctags</h3>
<p>如果没有安装 ctags make 编译会报错：<code>/bin/sh: ctags: command not found</code><br />
这时当然是要安装ctags啦，于是：</p>
<blockquote><p>apt-get install ctags</p></blockquote>
<p>搞定</p>
<h3>没有安装gcc</h3>
<p>这时候可能会报错：</p>
<blockquote><p>cc: Command not found</p></blockquote>
<p>这时需要gcc：</p>
<blockquote><p>apt-get install gcc</p></blockquote>
<h3>其他报错</h3>
<p>如果出现下面的错误：</p>
<blockquote><p>cannot create regular file `/usr/local/man/man1&#8242;: No such file or directory</p></blockquote>
<p><span id="more-930"></span><br />
这时需要创建<code>/usr/local/man/man1</code>文件来解决：</p>
<blockquote><p>mkdir -m 644 -p /usr/local/man/man1</p></blockquote>
<h2>使用webbench做压力测试</h2>
<p>经过上面的折腾，webbench终于安装好了，下面要做的就是做个<strong>压力测试</strong>了，在shell里面输入下面的命令：</p>
<blockquote><p>webbench -c 500 -t 30 http://127.0.0.1/test.jpg</p></blockquote>
<p>参数说明：-c表示并发数，-t表示时间(秒)</p>
<p>最后就会出现详细的测试信息了：</p>
<blockquote><p>Webbench &#8211; Simple Web Benchmark 1.5<br />
Copyright (c) Radim Kolar 1997-2004, GPL Open Source Software.</p>
<p>Benchmarking: GET http://127.0.0.1/test.jpg<br />
500 clients, running 30 sec.</p>
<p>Speed=3230 pages/min, 11614212 bytes/sec.<br />
Requests: 1615 susceed, 0 failed.</p></blockquote>
<div class="copyright">
<strong>声明：</strong>文章未声明为原创文章，本文链接 <a href="http://js8.in/930.html" title="使用webbench做压力测试">http://js8.in/930.html</a>. 转载请注明转自<a href="http://js8.in" title="前端开发博客"> JS8.IN ™</a></span></span></div>
<h3 class="box-title">随机文章</h3>
<ul class="box_random">
<li><a href="http://js8.in/293.html" title="【续】教你偷老师的课件甚至考试试题~" rel="bookmark inlinks">【续】教你偷老师的课件甚至考试试题~</a></li>
<li><a href="http://js8.in/606.html" title="解决IE6不支持max-height的bug" rel="bookmark inlinks">解决IE6不支持max-height的bug</a></li>
<li><a href="http://js8.in/506.html" title="最新版wBox 解决IE6 背景太小bug" rel="bookmark inlinks">最新版wBox 解决IE6 背景太小bug</a></li>
<li><a href="http://js8.in/382.html" title="主流浏览器的CSS Hack方法整理" rel="bookmark inlinks">主流浏览器的CSS Hack方法整理</a></li>
<li><a href="http://js8.in/674.html" title="使用xdebug调试PHP 找出PHP程序的瓶颈" rel="bookmark inlinks">使用xdebug调试PHP 找出PHP程序的瓶颈</a></li>
<li><a href="http://js8.in/51.html" title="08.11.18" rel="bookmark inlinks">08.11.18</a></li>
<li><a href="http://js8.in/240.html" title="是不是应该出售2fool.cn的域名" rel="bookmark inlinks">是不是应该出售2fool.cn的域名</a></li>
<li><a href="http://js8.in/951.html" title="【PPT分享】XSS注入和防范" rel="bookmark inlinks">【PPT分享】XSS注入和防范</a></li>
</ul>
<hr />
<p><small>© 三水清 for <a href="http://js8.in">三水清</a>, 2012. |
<a href="http://js8.in/930.html#comments">One comment</a> |在微博关注我：<a href="//weibo.com/sanshuiqing" target="_blank" title="关注断桥残雪的新浪微博">@清-三水清</a>
<br/>收藏到：
<a rel="nofollow" href="http://share.renren.com/share/buttonshare.do?link=%posturl%&title=%posttitle%" title="收藏本文到人人网" target="_blank">人人网</a> | <a rel="nofollow" href="http://www.douban.com/recommend/?url=%posturl%&title=%posttitle%" title="收藏本文到豆瓣" target="_blank">豆瓣</a> | <a rel="nofollow" href="http://www.kaixin001.com/repaste/share.php?rtitle=%posttitle%&rurl=%posturl%" title="收藏本文到开心网" target="_blank">开心网</a> | <a rel="nofollow" href="http://shuqian.qq.com/post?title=%posttitle%&%20uri=%posturl%" title="收藏本文到QQ书签" target="_blank">QQ书签</a> | <a rel="nofollow" href="http://v.t.sina.com.cn/share/share.php?url=%posturl%&title=%posttitle%" title="收藏本文到新浪微博" target="_blank">新浪微博</a> | <a rel="nofollow" href="http://v.t.qq.com/share/share.php?title=%posttitle%&url=%posturl%&site=http://www.kaixin100.info" title="收藏本文到腾讯微博" target="_blank">腾讯微博</a>
<br/>
Post tags: <a href="http://js8.in/tag/linux" rel="tag">linux</a>, <a href="http://js8.in/tag/webbench" rel="tag">webbench</a>, <a href="http://js8.in/tag/%e5%8e%8b%e5%8a%9b%e6%b5%8b%e8%af%95" rel="tag">压力测试</a><br/>
</small></p><table class="wumii-related-items" cellspacing="0" cellpadding="3" border="0"  style="clear: both;">
    
    <tr>
        <td colspan="4"><b><font size="-1"  style="display: block !important; padding: 20px 0 5px !important;">猜你喜欢：</font></b></td>
    </tr>
    
        <tr>
                <td width="102" valign="top" style="padding: 5px !important; margin: 0 !important;">
                    <a target="_blank" title="linux安装PHP加速器eAccelerator" style="text-decoration: none !important; cursor: pointer !important;" href="http://app.wumii.com/ext/redirect?url=http%3A%2F%2Fjs8.in%2F888.html&from=http%3A%2F%2Fjs8.in%2F930.html">
                        <img style="margin: 0 !important; padding: 2px !important; border: 1px solid #DDDDDD !important; width: 96px !important; height: 96px !important;" src="http://static.wumii.com/site_images/2011/09/15/12184400.jpg" width="96px" height="96px" /><br />
                        <font size="-1" color="#333333" style="display: block !important; line-height: 15px !important; width: 102px !important; font: 12px/15px arial !important; height: 60px !important; margin: 3px 0 0 0 !important; padding: 0 !important; overflow: hidden !important;">linux安装PHP加速器eAccelerator</font>
                    </a>
                </td>
                <td width="102" valign="top" style="padding: 5px !important; margin: 0 !important; border-left: 1px solid #DDDDDD !important;">
                    <a target="_blank" title="jQuery1.4正式版新功能及性能测试" style="text-decoration: none !important; cursor: pointer !important;" href="http://app.wumii.com/ext/redirect?url=http%3A%2F%2Fjs8.in%2F450.html&from=http%3A%2F%2Fjs8.in%2F930.html">
                        <img style="margin: 0 !important; padding: 2px !important; border: 1px solid #DDDDDD !important; width: 96px !important; height: 96px !important;" src="http://static.wumii.com/site_images/2011/11/18/11026546.jpg" width="96px" height="96px" /><br />
                        <font size="-1" color="#333333" style="display: block !important; line-height: 15px !important; width: 102px !important; font: 12px/15px arial !important; height: 60px !important; margin: 3px 0 0 0 !important; padding: 0 !important; overflow: hidden !important;">jQuery1.4正式版新功能及性能测试</font>
                    </a>
                </td>
                <td width="102" valign="top" style="padding: 5px !important; margin: 0 !important; border-left: 1px solid #DDDDDD !important;">
                    <a target="_blank" title="Ubuntu安装Samba实现跟windows文件共享" style="text-decoration: none !important; cursor: pointer !important;" href="http://app.wumii.com/ext/redirect?url=http%3A%2F%2Fjs8.in%2F526.html&from=http%3A%2F%2Fjs8.in%2F930.html">
                        <img style="margin: 0 !important; padding: 2px !important; border: 1px solid #DDDDDD !important; width: 96px !important; height: 96px !important;" src="http://static.wumii.com/site_images/2011/11/17/10979469.jpg" width="96px" height="96px" /><br />
                        <font size="-1" color="#333333" style="display: block !important; line-height: 15px !important; width: 102px !important; font: 12px/15px arial !important; height: 60px !important; margin: 3px 0 0 0 !important; padding: 0 !important; overflow: hidden !important;">Ubuntu安装Samba实现跟windows文件共享</font>
                    </a>
                </td>
                <td width="102" valign="top" style="padding: 5px !important; margin: 0 !important; border-left: 1px solid #DDDDDD !important;">
                    <a target="_blank" title="使用windows7的virtual PC打造原装IE6、IE7、IE8测试环境" style="text-decoration: none !important; cursor: pointer !important;" href="http://app.wumii.com/ext/redirect?url=http%3A%2F%2Fjs8.in%2F688.html&from=http%3A%2F%2Fjs8.in%2F930.html">
                        <img style="margin: 0 !important; padding: 2px !important; border: 1px solid #DDDDDD !important; width: 96px !important; height: 96px !important;" src="http://static.wumii.com/site_images/2011/11/17/10978881.png" width="96px" height="96px" /><br />
                        <font size="-1" color="#333333" style="display: block !important; line-height: 15px !important; width: 102px !important; font: 12px/15px arial !important; height: 60px !important; margin: 3px 0 0 0 !important; padding: 0 !important; overflow: hidden !important;">使用windows7的virtual PC打造原装IE6、IE7、IE8测试环境</font>
                    </a>
                </td>
        </tr>
    
    <tr>
        <td colspan="4" align="right">
            <a style="text-decoration: none !important;" href="http://www.wumii.com/widget/relatedItems" target="_blank" title="无觅相关文章插件">
                <font size="-1" color="#bbbbbb" style="display: block !important; font-family: arial !important; padding: 5px 0 !important; font-size: 12px !important; color: #bbb !important;">无觅</font>
            </a>
        </td>
    </tr>
</table>]]></content:encoded>
			<wfw:commentRss>http://js8.in/930.html/feed</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>非字母javascript</title>
		<link>http://js8.in/918.html</link>
		<comments>http://js8.in/918.html#comments</comments>
		<pubDate>Wed, 30 Nov 2011 02:17:03 +0000</pubDate>
		<dc:creator>三水清</dc:creator>
				<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[javascript]]></category>

		<guid isPermaLink="false">http://js8.in/?p=918</guid>
		<description><![CDATA[你尝试过写javascript不用字母和数字吗？最近准备个xss的分享，记起了之前看到过老外一篇文章，内容是关于non-alpha javascript的，拿到代码分析下。
先看这段猥琐的javascript代码：

_=+&#91;&#93;;$=_++;__=&#40;_&#60;&#60;_&#41;;___=&#40;_&#60;&#60;_&#41;+_;____=__+__;_____=__+___;$$=&#40;&#123;&#125;+&#34;&#34;&#41;&#91;_____&#93;+&#40;&#123;&#125;+&#34;&#34;&#41;&#91;_&#93;+&#40;&#123;&#125;&#91;$&#93;+&#34;&#34;&#41;&#91;_&#93;+&#40;&#40;$!=$&#41;+&#34;&#34;&#41;&#91;___&#93;+&#40;&#40;$==$&#41;+&#34;&#34;&#41;&#91;$&#93;+&#40;&#40;$==$&#41;+&#34;&#34;&#41;&#91;_&#93;+&#40;&#40;$==$&#41;+&#34;&#34;&#41;&#91;__&#93;+&#40;&#123;&#125;+&#34;&#34;&#41;&#91;_____&#93;+&#40;&#40;$==$&#41;+&#34;&#34;&#41;&#91;$&#93;+&#40;&#123;&#125;+&#34;&#34;&#41;&#91;_&#93;+&#40;&#40;$==$&#41;+&#34;&#34;&#41;&#91;_&#93;;$$$=&#40;&#40;$!=$&#41;+&#34;&#34;&#41;&#91;_&#93;+&#40;&#40;$!=$&#41;+&#34;&#34;&#41;&#91;__&#93;+&#40;&#40;$==$&#41;+&#34;&#34;&#41;&#91;___&#93;+&#40;&#40;$==$&#41;+&#34;&#34;&#41;&#91;_&#93;+&#40;&#40;$==$&#41;+&#34;&#34;&#41;&#91;$&#93;;$_$=&#40;&#123;&#125;+&#34;&#34;&#41;&#91;_____&#93;+&#40;&#123;&#125;+&#34;&#34;&#41;&#91;_&#93;+&#40;&#123;&#125;+&#34;&#34;&#41;&#91;_&#93;+&#40;&#40;$!=$&#41;+&#34;&#34;&#41;&#91;__&#93;+&#40;&#123;&#125;+&#34;&#34;&#41;&#91;__+_____&#93;+&#40;&#123;&#125;+&#34;&#34;&#41;&#91;_____&#93;+ &#40;&#123;&#125;+&#34;&#34;&#41;&#91;_&#93;+&#40;&#123;&#125;&#91;$&#93;+&#34;&#34;&#41;&#91;__&#93;+&#40;&#40;$==$&#41;+&#34;&#34;&#41;&#91;___&#93;; &#40;$&#41;&#91;$$&#93;&#91;$$&#93;&#40;$$$+&#34;('&#34;+$_$+&#34;')&#34;&#41;&#40;&#41;;

看到这里你肯定抓狂了，但是这段代码是可以运行的，运行的结果是 alert('cool code'); 。
javascript分析
这段代码能够运行，原因是javascript是弱类型的脚本语言，而且语法相对松散。例如下面的javascript是正确的，而且是有出乎意料结果的：


true+true;//2
undefined+''//'undefined'
&#40;true+&#34;&#34;&#41;&#91;0&#93;;//'t'
&#91;&#93;=='';//true
''==0;//true
typeof &#40;+''&#41;;//number,0
&#40;&#123;&#125;+''&#41;;//&#34;[object Object]&#34;
&#40;&#123;&#125;&#91;0&#93;&#41;;//undefined

所以我们想得到一个0就可以使用:

_= +&#91;&#93;;
_= +'';

下一步通过位运算，++等运算可以得到0~9所有数字。
因为0就是false，则!0就是true，({}[0]);可以得到undefined，({}+'')可以得到字符串：[object Object]，字符串中的字符，可以组成新的字符串，于是通过组合，我们就得到了："constructor"。
javascript中的点(.)运算符和[]的作用都是一样的，只不过[]可以接收传入变量、字符串，所以我们可以得到一个Function对象，即：

&#40;0&#41;&#91;'constructor'&#93;&#91;'constructor'&#93;;

另外我们也知道，下面的代码是运行的：

Function&#40;'alert(1);'&#41;&#40;&#41;;

所以，我想剩下的你就懂了……

声明：文章未声明为原创文章，本文链接 http://js8.in/918.html. 转载请注明转自 JS8.IN ™
随机文章

利用GControl和GLayer对象在地图上显示panoramio图片
前端开发优化总结
Ubuntu安装NVidia驱动
病毒清除啦~可是似乎xp中访问博客还是很慢！
关于最近局域网受到Arp欺骗攻击
悼念地震，网站变灰CSS代码
在Express和Socket.IO中使用session
jQuery+google weather API轻松实现天气地图（一）


    

© 三水清 for 三水清, 2011. &#124;
5 comments &#124;在微博关注我：@清-三水清
收藏到：
人人网 &#124; 豆瓣 &#124; 开心网 &#124; QQ书签 &#124; 新浪微博 &#124; 腾讯微博

Post tags: javascript
<table class="wumii-related-items" cellspacing="0" cellpadding="3" border="0"  style="clear: both;">
    
    <tr>
        <td colspan="4"><b><font size="-1"  style="display: block !important; padding: 20px 0 5px !important;">猜你喜欢：</font></b></td>
    </tr>
    
        <tr>
                <td width="102" valign="top" style="padding: 5px !important; margin: 0 !important;">
                    <a target="_blank" title="Javascript设置光标位置到结尾并显示出来" style="text-decoration: none !important; cursor: pointer !important;" href="http://app.wumii.com/ext/redirect?url=http%3A%2F%2Fjs8.in%2F467.html&from=http%3A%2F%2Fjs8.in%2F918.html">
                        <img style="margin: 0 !important; padding: 2px !important; border: 1px solid #DDDDDD !important; width: 96px !important; height: 96px !important;" src="http://static.wumii.com/site_images/2011/11/18/11027176.jpg" width="96px" height="96px" /><br />
                        <font size="-1" color="#333333" style="display: block !important; line-height: 15px !important; width: 102px !important; font: 12px/15px arial !important; height: 60px !important; margin: 3px 0 0 0 !important; padding: 0 !important; overflow: hidden !important;">Javascript设置光标位置到结尾并显示出来</font>
                    </a>
                </td>
                <td width="102" valign="top" style="padding: 5px !important; margin: 0 !important; border-left: 1px solid #DDDDDD !important;">
                    <a target="_blank" title="Javascript事件触发列表与详解" style="text-decoration: none !important; cursor: pointer !important;" href="http://app.wumii.com/ext/redirect?url=http%3A%2F%2Fjs8.in%2F480.html&from=http%3A%2F%2Fjs8.in%2F918.html">
                        <img style="margin: 0 !important; padding: 2px !important; border: 1px solid #DDDDDD !important; width: 96px !important; height: 96px !important;" src="http://static.wumii.com/site_images/2011/11/17/10982510.bmp" width="96px" height="96px" /><br />
                        <font size="-1" color="#333333" style="display: block !important; line-height: 15px !important; width: 102px !important; font: 12px/15px arial !important; height: 60px !important; margin: 3px 0 0 0 !important; padding: 0 !important; overflow: hidden !important;">Javascript事件触发列表与详解</font>
                    </a>
                </td>
                <td width="102" valign="top" style="padding: 5px !important; margin: 0 !important; border-left: 1px solid #DDDDDD !important;">
                    <a target="_blank" title="Javascript正则表达式详解" style="text-decoration: none !important; cursor: pointer !important;" href="http://app.wumii.com/ext/redirect?url=http%3A%2F%2Fjs8.in%2F473.html&from=http%3A%2F%2Fjs8.in%2F918.html">
                        <img style="margin: 0 !important; padding: 2px !important; border: 1px solid #DDDDDD !important; width: 96px !important; height: 96px !important;" src="http://static.wumii.com/site_images/2012/02/06/14873015.jpg" width="96px" height="96px" /><br />
                        <font size="-1" color="#333333" style="display: block !important; line-height: 15px !important; width: 102px !important; font: 12px/15px arial !important; height: 60px !important; margin: 3px 0 0 0 !important; padding: 0 !important; overflow: hidden !important;">Javascript正则表达式详解</font>
                    </a>
                </td>
                <td width="102" valign="top" style="padding: 5px !important; margin: 0 !important; border-left: 1px solid #DDDDDD !important;">
                    <a target="_blank" title="JavaScript跨浏览器的添加删除事件绑定函数" style="text-decoration: none !important; cursor: pointer !important;" href="http://app.wumii.com/ext/redirect?url=http%3A%2F%2Fjs8.in%2F408.html&from=http%3A%2F%2Fjs8.in%2F918.html">
                        <img style="margin: 0 !important; padding: 2px !important; border: 1px solid #DDDDDD !important; width: 96px !important; height: 96px !important;" src="http://static.wumii.com/site_images/2011/11/17/10978769.bmp" width="96px" height="96px" /><br />
                        <font size="-1" color="#333333" style="display: block !important; line-height: 15px !important; width: 102px !important; font: 12px/15px arial !important; height: 60px !important; margin: 3px 0 0 0 !important; padding: 0 !important; overflow: hidden !important;">JavaScript跨浏览器的添加删除事件绑定函数</font>
                    </a>
                </td>
        </tr>
    
    <tr>
        <td colspan="4" align="right">
            <a style="text-decoration: none !important;" href="http://www.wumii.com/widget/relatedItems" target="_blank" title="无觅相关文章插件">
                <font size="-1" color="#bbbbbb" style="display: block !important; font-family: arial !important; padding: 5px 0 !important; font-size: 12px !important; color: #bbb !important;">无觅</font>
            </a>
        </td>
    </tr>
</table>]]></description>
			<content:encoded><![CDATA[<p>你尝试过写javascript不用字母和数字吗？最近准备个xss的分享，记起了之前看到过老外一篇文章，内容是关于non-alpha javascript的，拿到代码分析下。<br />
先看这段猥琐的javascript代码：</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;">_<span style="color: #339933;">=+</span><span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>$<span style="color: #339933;">=</span>_<span style="color: #339933;">++;</span>__<span style="color: #339933;">=</span><span style="color: #009900;">&#40;</span>_<span style="color: #339933;">&lt;&lt;</span>_<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>___<span style="color: #339933;">=</span><span style="color: #009900;">&#40;</span>_<span style="color: #339933;">&lt;&lt;</span>_<span style="color: #009900;">&#41;</span><span style="color: #339933;">+</span>_<span style="color: #339933;">;</span>____<span style="color: #339933;">=</span>__<span style="color: #339933;">+</span>__<span style="color: #339933;">;</span>_____<span style="color: #339933;">=</span>__<span style="color: #339933;">+</span>___<span style="color: #339933;">;</span>$$<span style="color: #339933;">=</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#123;</span><span style="color: #009900;">&#125;</span><span style="color: #339933;">+</span><span style="color: #3366CC;">&quot;&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#91;</span>_____<span style="color: #009900;">&#93;</span><span style="color: #339933;">+</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#123;</span><span style="color: #009900;">&#125;</span><span style="color: #339933;">+</span><span style="color: #3366CC;">&quot;&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#91;</span>_<span style="color: #009900;">&#93;</span><span style="color: #339933;">+</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#123;</span><span style="color: #009900;">&#125;</span><span style="color: #009900;">&#91;</span>$<span style="color: #009900;">&#93;</span><span style="color: #339933;">+</span><span style="color: #3366CC;">&quot;&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#91;</span>_<span style="color: #009900;">&#93;</span><span style="color: #339933;">+</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#40;</span>$<span style="color: #339933;">!=</span>$<span style="color: #009900;">&#41;</span><span style="color: #339933;">+</span><span style="color: #3366CC;">&quot;&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#91;</span>___<span style="color: #009900;">&#93;</span><span style="color: #339933;">+</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#40;</span>$<span style="color: #339933;">==</span>$<span style="color: #009900;">&#41;</span><span style="color: #339933;">+</span><span style="color: #3366CC;">&quot;&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#91;</span>$<span style="color: #009900;">&#93;</span><span style="color: #339933;">+</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#40;</span>$<span style="color: #339933;">==</span>$<span style="color: #009900;">&#41;</span><span style="color: #339933;">+</span><span style="color: #3366CC;">&quot;&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#91;</span>_<span style="color: #009900;">&#93;</span><span style="color: #339933;">+</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#40;</span>$<span style="color: #339933;">==</span>$<span style="color: #009900;">&#41;</span><span style="color: #339933;">+</span><span style="color: #3366CC;">&quot;&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#91;</span>__<span style="color: #009900;">&#93;</span><span style="color: #339933;">+</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#123;</span><span style="color: #009900;">&#125;</span><span style="color: #339933;">+</span><span style="color: #3366CC;">&quot;&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#91;</span>_____<span style="color: #009900;">&#93;</span><span style="color: #339933;">+</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#40;</span>$<span style="color: #339933;">==</span>$<span style="color: #009900;">&#41;</span><span style="color: #339933;">+</span><span style="color: #3366CC;">&quot;&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#91;</span>$<span style="color: #009900;">&#93;</span><span style="color: #339933;">+</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#123;</span><span style="color: #009900;">&#125;</span><span style="color: #339933;">+</span><span style="color: #3366CC;">&quot;&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#91;</span>_<span style="color: #009900;">&#93;</span><span style="color: #339933;">+</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#40;</span>$<span style="color: #339933;">==</span>$<span style="color: #009900;">&#41;</span><span style="color: #339933;">+</span><span style="color: #3366CC;">&quot;&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#91;</span>_<span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>$$$<span style="color: #339933;">=</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#40;</span>$<span style="color: #339933;">!=</span>$<span style="color: #009900;">&#41;</span><span style="color: #339933;">+</span><span style="color: #3366CC;">&quot;&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#91;</span>_<span style="color: #009900;">&#93;</span><span style="color: #339933;">+</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#40;</span>$<span style="color: #339933;">!=</span>$<span style="color: #009900;">&#41;</span><span style="color: #339933;">+</span><span style="color: #3366CC;">&quot;&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#91;</span>__<span style="color: #009900;">&#93;</span><span style="color: #339933;">+</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#40;</span>$<span style="color: #339933;">==</span>$<span style="color: #009900;">&#41;</span><span style="color: #339933;">+</span><span style="color: #3366CC;">&quot;&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#91;</span>___<span style="color: #009900;">&#93;</span><span style="color: #339933;">+</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#40;</span>$<span style="color: #339933;">==</span>$<span style="color: #009900;">&#41;</span><span style="color: #339933;">+</span><span style="color: #3366CC;">&quot;&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#91;</span>_<span style="color: #009900;">&#93;</span><span style="color: #339933;">+</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#40;</span>$<span style="color: #339933;">==</span>$<span style="color: #009900;">&#41;</span><span style="color: #339933;">+</span><span style="color: #3366CC;">&quot;&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#91;</span>$<span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>$_$<span style="color: #339933;">=</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#123;</span><span style="color: #009900;">&#125;</span><span style="color: #339933;">+</span><span style="color: #3366CC;">&quot;&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#91;</span>_____<span style="color: #009900;">&#93;</span><span style="color: #339933;">+</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#123;</span><span style="color: #009900;">&#125;</span><span style="color: #339933;">+</span><span style="color: #3366CC;">&quot;&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#91;</span>_<span style="color: #009900;">&#93;</span><span style="color: #339933;">+</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#123;</span><span style="color: #009900;">&#125;</span><span style="color: #339933;">+</span><span style="color: #3366CC;">&quot;&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#91;</span>_<span style="color: #009900;">&#93;</span><span style="color: #339933;">+</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#40;</span>$<span style="color: #339933;">!=</span>$<span style="color: #009900;">&#41;</span><span style="color: #339933;">+</span><span style="color: #3366CC;">&quot;&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#91;</span>__<span style="color: #009900;">&#93;</span><span style="color: #339933;">+</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#123;</span><span style="color: #009900;">&#125;</span><span style="color: #339933;">+</span><span style="color: #3366CC;">&quot;&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#91;</span>__<span style="color: #339933;">+</span>_____<span style="color: #009900;">&#93;</span><span style="color: #339933;">+</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#123;</span><span style="color: #009900;">&#125;</span><span style="color: #339933;">+</span><span style="color: #3366CC;">&quot;&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#91;</span>_____<span style="color: #009900;">&#93;</span><span style="color: #339933;">+</span> <span style="color: #009900;">&#40;</span><span style="color: #009900;">&#123;</span><span style="color: #009900;">&#125;</span><span style="color: #339933;">+</span><span style="color: #3366CC;">&quot;&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#91;</span>_<span style="color: #009900;">&#93;</span><span style="color: #339933;">+</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#123;</span><span style="color: #009900;">&#125;</span><span style="color: #009900;">&#91;</span>$<span style="color: #009900;">&#93;</span><span style="color: #339933;">+</span><span style="color: #3366CC;">&quot;&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#91;</span>__<span style="color: #009900;">&#93;</span><span style="color: #339933;">+</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#40;</span>$<span style="color: #339933;">==</span>$<span style="color: #009900;">&#41;</span><span style="color: #339933;">+</span><span style="color: #3366CC;">&quot;&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#91;</span>___<span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span> <span style="color: #009900;">&#40;</span>$<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#91;</span>$$<span style="color: #009900;">&#93;</span><span style="color: #009900;">&#91;</span>$$<span style="color: #009900;">&#93;</span><span style="color: #009900;">&#40;</span>$$$<span style="color: #339933;">+</span><span style="color: #3366CC;">&quot;('&quot;</span><span style="color: #339933;">+</span>$_$<span style="color: #339933;">+</span><span style="color: #3366CC;">&quot;')&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p>看到这里你肯定抓狂了，但是这段代码是可以运行的，运行的结果是 <code>alert('cool code');</code> 。</p>
<h2>javascript分析</h2>
<p>这段代码能够运行，原因是javascript是弱类型的脚本语言，而且语法相对松散。例如下面的javascript是正确的，而且是有出乎意料结果的：<br />
<span id="more-918"></span></p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #003366; font-weight: bold;">true</span><span style="color: #339933;">+</span><span style="color: #003366; font-weight: bold;">true</span><span style="color: #339933;">;</span><span style="color: #006600; font-style: italic;">//2</span>
undefined<span style="color: #339933;">+</span><span style="color: #3366CC;">''</span><span style="color: #006600; font-style: italic;">//'undefined'</span>
<span style="color: #009900;">&#40;</span><span style="color: #003366; font-weight: bold;">true</span><span style="color: #339933;">+</span><span style="color: #3366CC;">&quot;&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#91;</span><span style="color: #CC0000;">0</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span><span style="color: #006600; font-style: italic;">//'t'</span>
<span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">==</span><span style="color: #3366CC;">''</span><span style="color: #339933;">;</span><span style="color: #006600; font-style: italic;">//true</span>
<span style="color: #3366CC;">''</span><span style="color: #339933;">==</span><span style="color: #CC0000;">0</span><span style="color: #339933;">;</span><span style="color: #006600; font-style: italic;">//true</span>
<span style="color: #000066; font-weight: bold;">typeof</span> <span style="color: #009900;">&#40;</span><span style="color: #339933;">+</span><span style="color: #3366CC;">''</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><span style="color: #006600; font-style: italic;">//number,0</span>
<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#123;</span><span style="color: #009900;">&#125;</span><span style="color: #339933;">+</span><span style="color: #3366CC;">''</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><span style="color: #006600; font-style: italic;">//&quot;[object Object]&quot;</span>
<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#123;</span><span style="color: #009900;">&#125;</span><span style="color: #009900;">&#91;</span><span style="color: #CC0000;">0</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><span style="color: #006600; font-style: italic;">//undefined</span></pre></div></div>

<p>所以我们想得到一个0就可以使用:</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;">_<span style="color: #339933;">=</span> <span style="color: #339933;">+</span><span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
_<span style="color: #339933;">=</span> <span style="color: #339933;">+</span><span style="color: #3366CC;">''</span><span style="color: #339933;">;</span></pre></div></div>

<p>下一步通过<a href="http://js8.in/906.html" title="javascript 位运算符" target="_blank">位运算</a>，++等运算可以得到0~9所有数字。</p>
<p>因为0就是false，则!0就是true，<code>({}[0]);</code>可以得到undefined，<code>({}+'')</code>可以得到字符串：[object Object]，字符串中的字符，可以组成新的字符串，于是通过组合，我们就得到了：<code>"constructor"</code>。</p>
<p>javascript中的点(.)运算符和[]的作用都是一样的，只不过[]可以接收传入变量、字符串，所以我们可以得到一个Function对象，即：</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #009900;">&#40;</span><span style="color: #CC0000;">0</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#91;</span><span style="color: #3366CC;">'constructor'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#91;</span><span style="color: #3366CC;">'constructor'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span></pre></div></div>

<p>另外我们也知道，下面的代码是运行的：</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #003366; font-weight: bold;">Function</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'alert(1);'</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p>所以，我想剩下的你就懂了……
<div class="copyright">
<strong>声明：</strong>文章未声明为原创文章，本文链接 <a href="http://js8.in/918.html" title="非字母javascript">http://js8.in/918.html</a>. 转载请注明转自<a href="http://js8.in" title="前端开发博客"> JS8.IN ™</a></span></span></div>
<h3 class="box-title">随机文章</h3>
<ul class="box_random">
<li><a href="http://js8.in/642.html" title="使用mysqldump、into outfile和load data进行数据库导入导出备份" rel="bookmark inlinks">使用mysqldump、into outfile和load data进行数据库导入导出备份</a></li>
<li><a href="http://js8.in/544.html" title="最新版WINDOWS 7 SP1下载地址出现" rel="bookmark inlinks">最新版WINDOWS 7 SP1下载地址出现</a></li>
<li><a href="http://js8.in/492.html" title="十大Google Buzz的使用技巧" rel="bookmark inlinks">十大Google Buzz的使用技巧</a></li>
<li><a href="http://js8.in/477.html" title="Less—让CSS如此简单" rel="bookmark inlinks">Less—让CSS如此简单</a></li>
<li><a href="http://js8.in/622.html" title="IE中flash遮挡div现象的解决方案" rel="bookmark inlinks">IE中flash遮挡div现象的解决方案</a></li>
<li><a href="http://js8.in/700.html" title="新浪微博jsSDK操作指南" rel="bookmark inlinks">新浪微博jsSDK操作指南</a></li>
<li><a href="http://js8.in/885.html" title="检查nginx配置，重载配置以及重启的方法" rel="bookmark inlinks">检查nginx配置，重载配置以及重启的方法</a></li>
<li><a href="http://js8.in/692.html" title="新浪微博应用：微博送大礼" rel="bookmark inlinks">新浪微博应用：微博送大礼</a></li>
</ul>
<p style="margin:0;padding:0;height:1px;overflow:hidden;">
    <script type="text/javascript"><!--
        var wumiiSitePrefix = "http://js8.in";
        var wumiiEnableCustomPos = false;
        var wumiiParams = "&#038;num=4&#038;mode=3&#038;displayInFeed=1&#038;version=1.0.5.5&#038;pf=WordPress2.8.6";
    //--></script></p>
<hr />
<p><small>© 三水清 for <a href="http://js8.in">三水清</a>, 2011. |
<a href="http://js8.in/918.html#comments">5 comments</a> |在微博关注我：<a href="//weibo.com/sanshuiqing" target="_blank" title="关注断桥残雪的新浪微博">@清-三水清</a>
<br/>收藏到：
<a rel="nofollow" href="http://share.renren.com/share/buttonshare.do?link=%posturl%&title=%posttitle%" title="收藏本文到人人网" target="_blank">人人网</a> | <a rel="nofollow" href="http://www.douban.com/recommend/?url=%posturl%&title=%posttitle%" title="收藏本文到豆瓣" target="_blank">豆瓣</a> | <a rel="nofollow" href="http://www.kaixin001.com/repaste/share.php?rtitle=%posttitle%&rurl=%posturl%" title="收藏本文到开心网" target="_blank">开心网</a> | <a rel="nofollow" href="http://shuqian.qq.com/post?title=%posttitle%&%20uri=%posturl%" title="收藏本文到QQ书签" target="_blank">QQ书签</a> | <a rel="nofollow" href="http://v.t.sina.com.cn/share/share.php?url=%posturl%&title=%posttitle%" title="收藏本文到新浪微博" target="_blank">新浪微博</a> | <a rel="nofollow" href="http://v.t.qq.com/share/share.php?title=%posttitle%&url=%posturl%&site=http://www.kaixin100.info" title="收藏本文到腾讯微博" target="_blank">腾讯微博</a>
<br/>
Post tags: <a href="http://js8.in/tag/javascript" rel="tag">javascript</a><br/>
</small></p><table class="wumii-related-items" cellspacing="0" cellpadding="3" border="0"  style="clear: both;">
    
    <tr>
        <td colspan="4"><b><font size="-1"  style="display: block !important; padding: 20px 0 5px !important;">猜你喜欢：</font></b></td>
    </tr>
    
        <tr>
                <td width="102" valign="top" style="padding: 5px !important; margin: 0 !important;">
                    <a target="_blank" title="Javascript设置光标位置到结尾并显示出来" style="text-decoration: none !important; cursor: pointer !important;" href="http://app.wumii.com/ext/redirect?url=http%3A%2F%2Fjs8.in%2F467.html&from=http%3A%2F%2Fjs8.in%2F918.html">
                        <img style="margin: 0 !important; padding: 2px !important; border: 1px solid #DDDDDD !important; width: 96px !important; height: 96px !important;" src="http://static.wumii.com/site_images/2011/11/18/11027176.jpg" width="96px" height="96px" /><br />
                        <font size="-1" color="#333333" style="display: block !important; line-height: 15px !important; width: 102px !important; font: 12px/15px arial !important; height: 60px !important; margin: 3px 0 0 0 !important; padding: 0 !important; overflow: hidden !important;">Javascript设置光标位置到结尾并显示出来</font>
                    </a>
                </td>
                <td width="102" valign="top" style="padding: 5px !important; margin: 0 !important; border-left: 1px solid #DDDDDD !important;">
                    <a target="_blank" title="Javascript事件触发列表与详解" style="text-decoration: none !important; cursor: pointer !important;" href="http://app.wumii.com/ext/redirect?url=http%3A%2F%2Fjs8.in%2F480.html&from=http%3A%2F%2Fjs8.in%2F918.html">
                        <img style="margin: 0 !important; padding: 2px !important; border: 1px solid #DDDDDD !important; width: 96px !important; height: 96px !important;" src="http://static.wumii.com/site_images/2011/11/17/10982510.bmp" width="96px" height="96px" /><br />
                        <font size="-1" color="#333333" style="display: block !important; line-height: 15px !important; width: 102px !important; font: 12px/15px arial !important; height: 60px !important; margin: 3px 0 0 0 !important; padding: 0 !important; overflow: hidden !important;">Javascript事件触发列表与详解</font>
                    </a>
                </td>
                <td width="102" valign="top" style="padding: 5px !important; margin: 0 !important; border-left: 1px solid #DDDDDD !important;">
                    <a target="_blank" title="Javascript正则表达式详解" style="text-decoration: none !important; cursor: pointer !important;" href="http://app.wumii.com/ext/redirect?url=http%3A%2F%2Fjs8.in%2F473.html&from=http%3A%2F%2Fjs8.in%2F918.html">
                        <img style="margin: 0 !important; padding: 2px !important; border: 1px solid #DDDDDD !important; width: 96px !important; height: 96px !important;" src="http://static.wumii.com/site_images/2012/02/06/14873015.jpg" width="96px" height="96px" /><br />
                        <font size="-1" color="#333333" style="display: block !important; line-height: 15px !important; width: 102px !important; font: 12px/15px arial !important; height: 60px !important; margin: 3px 0 0 0 !important; padding: 0 !important; overflow: hidden !important;">Javascript正则表达式详解</font>
                    </a>
                </td>
                <td width="102" valign="top" style="padding: 5px !important; margin: 0 !important; border-left: 1px solid #DDDDDD !important;">
                    <a target="_blank" title="JavaScript跨浏览器的添加删除事件绑定函数" style="text-decoration: none !important; cursor: pointer !important;" href="http://app.wumii.com/ext/redirect?url=http%3A%2F%2Fjs8.in%2F408.html&from=http%3A%2F%2Fjs8.in%2F918.html">
                        <img style="margin: 0 !important; padding: 2px !important; border: 1px solid #DDDDDD !important; width: 96px !important; height: 96px !important;" src="http://static.wumii.com/site_images/2011/11/17/10978769.bmp" width="96px" height="96px" /><br />
                        <font size="-1" color="#333333" style="display: block !important; line-height: 15px !important; width: 102px !important; font: 12px/15px arial !important; height: 60px !important; margin: 3px 0 0 0 !important; padding: 0 !important; overflow: hidden !important;">JavaScript跨浏览器的添加删除事件绑定函数</font>
                    </a>
                </td>
        </tr>
    
    <tr>
        <td colspan="4" align="right">
            <a style="text-decoration: none !important;" href="http://www.wumii.com/widget/relatedItems" target="_blank" title="无觅相关文章插件">
                <font size="-1" color="#bbbbbb" style="display: block !important; font-family: arial !important; padding: 5px 0 !important; font-size: 12px !important; color: #bbb !important;">无觅</font>
            </a>
        </td>
    </tr>
</table>]]></content:encoded>
			<wfw:commentRss>http://js8.in/918.html/feed</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
	</channel>
</rss>

