<?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>Becomin&#039; Charles &#187; jQuery</title>
	<atom:link href="http://sexywp.com/tags/jquery/feed" rel="self" type="application/rss+xml" />
	<link>http://sexywp.com</link>
	<description>Building another myself~~</description>
	<lastBuildDate>Fri, 27 Jan 2012 16:00:02 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>jQuery里面用到“打包盒”</title>
		<link>http://sexywp.com/jquery-wrappers.htm</link>
		<comments>http://sexywp.com/jquery-wrappers.htm#comments</comments>
		<pubDate>Sat, 22 Oct 2011 17:45:43 +0000</pubDate>
		<dc:creator>Charles</dc:creator>
				<category><![CDATA[jQuery]]></category>
		<category><![CDATA[code reading]]></category>

		<guid isPermaLink="false">http://sexywp.com/?p=463</guid>
		<description><![CDATA[想学学怎么写jQuery的插件，结果发现举步维艰，于是想通过研究插件代码的案例，来积累经验，结果看到第一行，我就郁闷了，天下间最郁闷的事情莫过于你出门去约会，结果刚打开门，就摔个狗吃屎，现在我就那个感觉。看代码：

&#160;//第一种“包装盒”

&#160;(function($){

<span class="readmore"><a href="http://sexywp.com/jquery-wrappers.htm" title="jQuery里面用到“打包盒”">Keep Reading --- 1034 words totally</a></span><table class="wumii-related-items" cellspacing="0" cellpadding="2" border="0" width="100%" style="clear: both;">
    
    <tr>
        <td ><b><font size="-1"  style="display: block !important; padding: 20px 0 5px !important;">您可能也喜欢：</font></b></td>
    </tr>
    
            <tr>
                <td style="margin: 0 !important; padding: 0 !important; line-height: 20px !important;">
                    <img border="0" src="http://static.wumii.com/images/widget/widget_solidPoint.gif">
                    <a target="_blank" style="text-decoration: none !important;" href="http://app.wumii.com/ext/redirect.htm?url=http%3A%2F%2Fsexywp.com%2Fshare-this-jquery.htm&from=http%3A%2F%2Fsexywp.com%2Fjquery-wrappers.htm">
                        <font size="-1" color="#333333" style="line-height: 1.65em; font-size: 12px !important;">WordPress插件修改：Share This (jQuery)</font>
                    </a>
                </td>
            </tr>
            <tr>
                <td style="margin: 0 !important; padding: 0 !important; line-height: 20px !important;">
                    <img border="0" src="http://static.wumii.com/images/widget/widget_solidPoint.gif">
                    <a target="_blank" style="text-decoration: none !important;" href="http://app.wumii.com/ext/redirect.htm?url=http%3A%2F%2Fsexywp.com%2Fprogress-enhancement-of-comment-form.htm&from=http%3A%2F%2Fsexywp.com%2Fjquery-wrappers.htm">
                        <font size="-1" color="#333333" style="line-height: 1.65em; font-size: 12px !important;">也说用jQuery改进WP评论表单</font>
                    </a>
                </td>
            </tr>
            <tr>
                <td style="margin: 0 !important; padding: 0 !important; line-height: 20px !important;">
                    <img border="0" src="http://static.wumii.com/images/widget/widget_solidPoint.gif">
                    <a target="_blank" style="text-decoration: none !important;" href="http://app.wumii.com/ext/redirect.htm?url=http%3A%2F%2Fsexywp.com%2Fthickbox-tips.htm&from=http%3A%2F%2Fsexywp.com%2Fjquery-wrappers.htm">
                        <font size="-1" color="#333333" style="line-height: 1.65em; font-size: 12px !important;">[心得]：在thickbox退出时执行动作</font>
                    </a>
                </td>
            </tr>
            <tr>
                <td style="margin: 0 !important; padding: 0 !important; line-height: 20px !important;">
                    <img border="0" src="http://static.wumii.com/images/widget/widget_solidPoint.gif">
                    <a target="_blank" style="text-decoration: none !important;" href="http://app.wumii.com/ext/redirect.htm?url=http%3A%2F%2Fsexywp.com%2Finside-wordpress-07.htm&from=http%3A%2F%2Fsexywp.com%2Fjquery-wrappers.htm">
                        <font size="-1" color="#333333" style="line-height: 1.65em; font-size: 12px !important;">WordPress到底在整啥？—(07)</font>
                    </a>
                </td>
            </tr>
            <tr>
                <td style="margin: 0 !important; padding: 0 !important; line-height: 20px !important;">
                    <img border="0" src="http://static.wumii.com/images/widget/widget_solidPoint.gif">
                    <a target="_blank" style="text-decoration: none !important;" href="http://app.wumii.com/ext/redirect.htm?url=http%3A%2F%2Fsexywp.com%2Finside-wordpress-08.htm&from=http%3A%2F%2Fsexywp.com%2Fjquery-wrappers.htm">
                        <font size="-1" color="#333333" style="line-height: 1.65em; font-size: 12px !important;">WordPress到底在整啥？—(08)</font>
                    </a>
                </td>
            </tr>
    
    <tr>
        <td  align="right">
            <a style="text-decoration: none !important;" href="http://www.wumii.com/widget/relatedItems.htm" 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>想学学怎么写jQuery的插件，结果发现举步维艰，于是想通过研究插件代码的案例，来积累经验，结果看到第一行，我就郁闷了，天下间最郁闷的事情莫过于你出门去约会，结果刚打开门，就摔个狗吃屎，现在我就那个感觉。看代码：</p>
<div class="hl-surround"><div class="hl-main"><ol class="hl-main ln-show" title="Double click to hide line number." ondblclick = "linenumber(this)"><li>&nbsp;<span style="color: #ffa500;">//</span><span style="color: #ffa500;">第一种“包装盒”</span></li>
<li><span style="color: Gray;">&nbsp;</span><span style="color: Olive;">(</span><span style="color: Green;">function</span><span style="color: Olive;">(</span><span style="color: Gray;">$</span><span style="color: Olive;">)</span><span style="color: Olive;">{</span></li>
<li><span style="color: Gray;">&nbsp;&nbsp; &nbsp; </span><span style="color: #ffa500;">//</span><span style="color: #ffa500;"> to do things here, I like use this way</span></li>
<li><span style="color: Gray;">&nbsp;</span><span style="color: Olive;">}</span><span style="color: Olive;">)</span><span style="color: Olive;">(</span><span style="color: Blue;">jQuery</span><span style="color: Olive;">)</span><span style="color: Gray;">;</span></li>
<li><span style="color: Gray;">&nbsp; </span></li>
<li><span style="color: Gray;">&nbsp;</span><span style="color: #ffa500;">//</span><span style="color: #ffa500;">第二种“包装盒”</span></li>
<li><span style="color: Gray;">&nbsp;</span><span style="color: Olive;">(</span><span style="color: Green;">function</span><span style="color: Olive;">(</span><span style="color: Teal;">window</span><span style="color: Gray;">, </span><span style="color: Blue;">undefined</span><span style="color: Olive;">)</span><span style="color: Olive;">{</span></li>
<li><span style="color: Gray;">&nbsp;&nbsp; &nbsp; </span><span style="color: #ffa500;">//</span><span style="color: #ffa500;"> this is the wrapper of jquery</span></li>
<li><span style="color: Gray;">&nbsp;</span><span style="color: Olive;">}</span><span style="color: Olive;">)</span><span style="color: Olive;">(</span><span style="color: Teal;">window</span><span style="color: Olive;">)</span><span style="color: Gray;">;</span></li>
<li><span style="color: Gray;">&nbsp; </span></li>
<li><span style="color: Gray;">&nbsp;</span><span style="color: #ffa500;">//</span><span style="color: #ffa500;">第三种“包装盒”</span></li>
<li><span style="color: Gray;">&nbsp;</span><span style="color: Olive;">(</span><span style="color: Green;">function</span><span style="color: Olive;">(</span><span style="color: Gray;">$, </span><span style="color: Blue;">undefined</span><span style="color: Olive;">)</span><span style="color: Olive;">{</span></li>
<li><span style="color: Gray;">&nbsp;&nbsp; &nbsp; </span><span style="color: #ffa500;">//</span><span style="color: #ffa500;"> this is the wrapper of jquery ui components</span></li>
<li><span style="color: Gray;">&nbsp;</span><span style="color: Olive;">}</span><span style="color: Olive;">(</span><span style="color: Blue;">jQuery</span><span style="color: Olive;">)</span><span style="color: Olive;">)</span><span style="color: Gray;">;</span></li></ol></div></div>
<p>闭包是个好东西啊，自打初窥门径后，我干什么都喜欢在外面套个闭包，我把这个称为是打包盒，而且这个盒子很神奇，里面看得到外面，但是外面看不到里面。好处很多，比如可以放心大胆地命名变量啊，不用担心污染全局空间，也不用担心被全局空间的其他变量污染，还有像上面片段里，第一种那种写法，可以非常安全地去使用$符号代表的jQuery对象。因为在全局空间里，如果一个页面上引入多个类库的话，$符号很可能代表的不是jQuery对象，而用了第一种写法后，$符号变得很安全了。</p>
<p>翻开jQuery和其各类插件的源代码，你会发现，它们都被安放在一些“打包盒”里面，不禁有种英雄所见略同的感觉，但是不要感觉太好，为什么人家用的，跟我用的不太一样呢？看第二种，是jQuery用的“打包盒”。乍看跟第一种很像，但是那两个形参，简直匪夷所思。第一个是window，这明显是地球人都知道的全局变量啊，第二个是undefined，这更加神了@#$%^&#038;。<a href="http://ued.alipay.com/wd/2010/05/17/using-window-and-undefined-as-parameter-in-closure/">淘宝UED</a>有篇文章解释了这个问题。文章观点大体是，将window由全局变量变为形参，可以在后期代码最小化时候，通过对局部变量名的替换，来大幅度减小代码体积，这算是一个优化吧，undefined那个同理。另一点文中提到的是，undefined可以被重新定义成自定义的值，也即可能被污染，使用这种方式，会得到真正的一个undefined。当然，我的眼光和专业程度也止于此了，但是我还是觉得，还有可能有一些额外的好处，如果看官童鞋你知道，请不吝赐教。</p>
<p>第三种的话，看过了两种，基本上已经有点差不多全懂了，但是仔细一看，还差那么一点的。$形参，和undefined形参不多解释了。请大家关注那个不同点，就是最后一个闭合小括号的位置，发现了吧，最后闭合小括号，为什么是放在最后面了呢？由此我也发现了一个特性，就是在小括号里面的匿名函数，如果在函数结束的大括号后面，直接跟一对小括号的话，会使那个匿名函数立刻执行。如果离开了外面那对小括号，匿名函数是不能生存的，如果是具名函数呢，在闭合大括号后，跟一对小括号，也无法实现对函数的立即调用，反倒会有语法错误。但是还是来看最关键的那个不同，如下：</p>
<div class="hl-surround"><div class="hl-main"><ol class="hl-main ln-show" title="Double click to hide line number." ondblclick = "linenumber(this)"><li>&nbsp;<span style="color: #ffa500;">//</span><span style="color: #ffa500;">写法A</span></li>
<li><span style="color: Gray;">&nbsp;</span><span style="color: Olive;">(</span><span style="color: Green;">function</span><span style="color: Olive;">(</span><span style="color: Gray;">$, </span><span style="color: Blue;">undefined</span><span style="color: Olive;">)</span><span style="color: Olive;">{</span></li>
<li><span style="color: Gray;">&nbsp;&nbsp; &nbsp; </span><span style="color: #ffa500;">//</span><span style="color: #ffa500;"> this is the wrapper of jquery ui components</span></li>
<li><span style="color: Gray;">&nbsp;</span><span style="color: Olive;">}</span><span style="color: Olive;">(</span><span style="color: Blue;">jQuery</span><span style="color: Olive;">)</span><span style="color: Olive;">)</span><span style="color: Gray;">; </span></li>
<li><span style="color: Gray;">&nbsp; </span></li>
<li><span style="color: Gray;">&nbsp;</span><span style="color: #ffa500;">//</span><span style="color: #ffa500;">写法B</span></li>
<li><span style="color: Gray;">&nbsp;</span><span style="color: Olive;">(</span><span style="color: Green;">function</span><span style="color: Olive;">(</span><span style="color: Gray;">$, </span><span style="color: Blue;">undefined</span><span style="color: Olive;">)</span><span style="color: Olive;">{</span></li>
<li><span style="color: Gray;">&nbsp;&nbsp; &nbsp; </span><span style="color: #ffa500;">//</span><span style="color: #ffa500;"> this is the wrapper of jquery ui components</span></li>
<li><span style="color: Gray;">&nbsp;</span><span style="color: Olive;">}</span><span style="color: Olive;">)</span><span style="color: Olive;">(</span><span style="color: Blue;">jQuery</span><span style="color: Olive;">)</span><span style="color: Gray;">; </span><span style="color: #ffa500;">//</span><span style="color: #ffa500;">不用找茬了，这行不一样，看“)”的位置</span></li></ol></div></div>
<p>这两种“包装盒”到底有何不同？第一种比第二种有什么特别的好处么？</p>
<table class="wumii-related-items" cellspacing="0" cellpadding="2" border="0" width="100%" style="clear: both;">
    
    <tr>
        <td ><b><font size="-1"  style="display: block !important; padding: 20px 0 5px !important;">您可能也喜欢：</font></b></td>
    </tr>
    
            <tr>
                <td style="margin: 0 !important; padding: 0 !important; line-height: 20px !important;">
                    <img border="0" src="http://static.wumii.com/images/widget/widget_solidPoint.gif">
                    <a target="_blank" style="text-decoration: none !important;" href="http://app.wumii.com/ext/redirect.htm?url=http%3A%2F%2Fsexywp.com%2Fshare-this-jquery.htm&from=http%3A%2F%2Fsexywp.com%2Fjquery-wrappers.htm">
                        <font size="-1" color="#333333" style="line-height: 1.65em; font-size: 12px !important;">WordPress插件修改：Share This (jQuery)</font>
                    </a>
                </td>
            </tr>
            <tr>
                <td style="margin: 0 !important; padding: 0 !important; line-height: 20px !important;">
                    <img border="0" src="http://static.wumii.com/images/widget/widget_solidPoint.gif">
                    <a target="_blank" style="text-decoration: none !important;" href="http://app.wumii.com/ext/redirect.htm?url=http%3A%2F%2Fsexywp.com%2Fprogress-enhancement-of-comment-form.htm&from=http%3A%2F%2Fsexywp.com%2Fjquery-wrappers.htm">
                        <font size="-1" color="#333333" style="line-height: 1.65em; font-size: 12px !important;">也说用jQuery改进WP评论表单</font>
                    </a>
                </td>
            </tr>
            <tr>
                <td style="margin: 0 !important; padding: 0 !important; line-height: 20px !important;">
                    <img border="0" src="http://static.wumii.com/images/widget/widget_solidPoint.gif">
                    <a target="_blank" style="text-decoration: none !important;" href="http://app.wumii.com/ext/redirect.htm?url=http%3A%2F%2Fsexywp.com%2Fthickbox-tips.htm&from=http%3A%2F%2Fsexywp.com%2Fjquery-wrappers.htm">
                        <font size="-1" color="#333333" style="line-height: 1.65em; font-size: 12px !important;">[心得]：在thickbox退出时执行动作</font>
                    </a>
                </td>
            </tr>
            <tr>
                <td style="margin: 0 !important; padding: 0 !important; line-height: 20px !important;">
                    <img border="0" src="http://static.wumii.com/images/widget/widget_solidPoint.gif">
                    <a target="_blank" style="text-decoration: none !important;" href="http://app.wumii.com/ext/redirect.htm?url=http%3A%2F%2Fsexywp.com%2Finside-wordpress-07.htm&from=http%3A%2F%2Fsexywp.com%2Fjquery-wrappers.htm">
                        <font size="-1" color="#333333" style="line-height: 1.65em; font-size: 12px !important;">WordPress到底在整啥？—(07)</font>
                    </a>
                </td>
            </tr>
            <tr>
                <td style="margin: 0 !important; padding: 0 !important; line-height: 20px !important;">
                    <img border="0" src="http://static.wumii.com/images/widget/widget_solidPoint.gif">
                    <a target="_blank" style="text-decoration: none !important;" href="http://app.wumii.com/ext/redirect.htm?url=http%3A%2F%2Fsexywp.com%2Finside-wordpress-08.htm&from=http%3A%2F%2Fsexywp.com%2Fjquery-wrappers.htm">
                        <font size="-1" color="#333333" style="line-height: 1.65em; font-size: 12px !important;">WordPress到底在整啥？—(08)</font>
                    </a>
                </td>
            </tr>
    
    <tr>
        <td  align="right">
            <a style="text-decoration: none !important;" href="http://www.wumii.com/widget/relatedItems.htm" 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>
	标签：<a href="http://sexywp.com/tags/code-reading" title="code reading" rel="tag">code reading</a>, <a href="http://sexywp.com/tags/jquery" title="jQuery" rel="tag">jQuery</a><br />
]]></content:encoded>
			<wfw:commentRss>http://sexywp.com/jquery-wrappers.htm/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>[心得]：在thickbox退出时执行动作</title>
		<link>http://sexywp.com/thickbox-tips.htm</link>
		<comments>http://sexywp.com/thickbox-tips.htm#comments</comments>
		<pubDate>Tue, 23 Feb 2010 05:01:46 +0000</pubDate>
		<dc:creator>Charles</dc:creator>
				<category><![CDATA[jQuery]]></category>
		<category><![CDATA[code]]></category>
		<category><![CDATA[develop]]></category>
		<category><![CDATA[usage]]></category>

		<guid isPermaLink="false">http://sexywp.com/?p=366</guid>
		<description><![CDATA[thickbox是jQuery的插件，可以在页面上显示一个模拟出来的窗体，可以是对话框，AJAX内容，或者仅仅用来展示图片。其使用非常方便，只要在页面中引入了thickbox.js和thickbox.css，就可以通过设定A，INPUT，AREA元素的href或者alt属性，就可以使得其功能得以实现。具体的文档，可以参见这里。

WordPress在脚本库中添加了thickbox的脚本，调用起来格外地简单。所以我就选用了这个作为WP插件后台管理界面中，用户交互对话框的解决方案。在这里，介绍一点我在开发过程中的经验。如果需要在thickbox弹出窗体退出时执行一些动作，那么比较好的办法是向#TB_Window的unload事件绑定动作，thickbox在退出时会触发该动作，该动作是在tb_remove()函数中触发的。

<span class="readmore"><a href="http://sexywp.com/thickbox-tips.htm" title="[心得]：在thickbox退出时执行动作">Keep Reading --- 380 words totally</a></span><table class="wumii-related-items" cellspacing="0" cellpadding="3" border="0"  style="clear: both;">
    
    <tr>
        <td colspan="5"><b><font size="-1"  style="display: block !important; padding: 20px 0 5px !important;">您可能也喜欢：</font></b></td>
    </tr>
    
        <tr>
                <td width="86" valign="top" style="padding: 5px !important; margin: 0 !important;">
                    <a target="_blank" title="jQuery里面用到“打包盒”" style="text-decoration: none !important; cursor: pointer !important;" href="http://app.wumii.com/ext/redirect.htm?url=http%3A%2F%2Fsexywp.com%2Fjquery-wrappers.htm&from=http%3A%2F%2Fsexywp.com%2Fthickbox-tips.htm">
                        <img style="margin: 0 !important; padding: 2px !important; border: 1px solid #DDDDDD !important; width: 80px !important; height: 80px !important;" src="http://static.wumii.com/images/blogWidget/wordpress_default.gif" width="80px" height="80px" /><br />
                        <font size="-1" color="#333333" style="display: block !important; line-height: 15px !important; width: 86px !important; font: 12px/15px arial !important; height: 45px !important; margin: 3px 0 0 0 !important; padding: 0 !important; overflow: hidden !important;">jQuery里面用到“打包盒”</font>
                    </a>
                </td>
                <td width="86" valign="top" style="padding: 5px !important; margin: 0 !important; border-left: 1px solid #DDDDDD !important;">
                    <a target="_blank" title="使用Google AJAX Libraries API替换WordPress自带的js库" style="text-decoration: none !important; cursor: pointer !important;" href="http://app.wumii.com/ext/redirect.htm?url=http%3A%2F%2Fsexywp.com%2Freplace-the-wp-js-lib-by-googleapi.htm&from=http%3A%2F%2Fsexywp.com%2Fthickbox-tips.htm">
                        <img style="margin: 0 !important; padding: 2px !important; border: 1px solid #DDDDDD !important; width: 80px !important; height: 80px !important;" src="http://static.wumii.com/site_images/2011/05/23/9256004.png" width="80px" height="80px" /><br />
                        <font size="-1" color="#333333" style="display: block !important; line-height: 15px !important; width: 86px !important; font: 12px/15px arial !important; height: 45px !important; margin: 3px 0 0 0 !important; padding: 0 !important; overflow: hidden !important;">使用Google AJAX Libraries API替换WordPress自带的js库</font>
                    </a>
                </td>
                <td width="86" valign="top" style="padding: 5px !important; margin: 0 !important; border-left: 1px solid #DDDDDD !important;">
                    <a target="_blank" title="为何以及如何整合Google搜索到WP博客" style="text-decoration: none !important; cursor: pointer !important;" href="http://app.wumii.com/ext/redirect.htm?url=http%3A%2F%2Fsexywp.com%2Fwhy-and-how-to-integrate-google-to-blog.htm&from=http%3A%2F%2Fsexywp.com%2Fthickbox-tips.htm">
                        <img style="margin: 0 !important; padding: 2px !important; border: 1px solid #DDDDDD !important; width: 80px !important; height: 80px !important;" src="http://static.wumii.com/site_images/2011/05/22/9189497.gif" width="80px" height="80px" /><br />
                        <font size="-1" color="#333333" style="display: block !important; line-height: 15px !important; width: 86px !important; font: 12px/15px arial !important; height: 45px !important; margin: 3px 0 0 0 !important; padding: 0 !important; overflow: hidden !important;">为何以及如何整合Google搜索到WP博客</font>
                    </a>
                </td>
                <td width="86" valign="top" style="padding: 5px !important; margin: 0 !important; border-left: 1px solid #DDDDDD !important;">
                    <a target="_blank" title="Template Tags（模板标签）使用指南" style="text-decoration: none !important; cursor: pointer !important;" href="http://app.wumii.com/ext/redirect.htm?url=http%3A%2F%2Fsexywp.com%2Ftemplate-tags-usage.htm&from=http%3A%2F%2Fsexywp.com%2Fthickbox-tips.htm">
                        <img style="margin: 0 !important; padding: 2px !important; border: 1px solid #DDDDDD !important; width: 80px !important; height: 80px !important;" src="http://static.wumii.com/images/blogWidget/wordpress_default.gif" width="80px" height="80px" /><br />
                        <font size="-1" color="#333333" style="display: block !important; line-height: 15px !important; width: 86px !important; font: 12px/15px arial !important; height: 45px !important; margin: 3px 0 0 0 !important; padding: 0 !important; overflow: hidden !important;">Template Tags（模板标签）使用指南</font>
                    </a>
                </td>
                <td width="86" valign="top" style="padding: 5px !important; margin: 0 !important; border-left: 1px solid #DDDDDD !important;">
                    <a target="_blank" title="WordPress插件修改：Share This (jQuery)" style="text-decoration: none !important; cursor: pointer !important;" href="http://app.wumii.com/ext/redirect.htm?url=http%3A%2F%2Fsexywp.com%2Fshare-this-jquery.htm&from=http%3A%2F%2Fsexywp.com%2Fthickbox-tips.htm">
                        <img style="margin: 0 !important; padding: 2px !important; border: 1px solid #DDDDDD !important; width: 80px !important; height: 80px !important;" src="http://static.wumii.com/images/blogWidget/wordpress_default.gif" width="80px" height="80px" /><br />
                        <font size="-1" color="#333333" style="display: block !important; line-height: 15px !important; width: 86px !important; font: 12px/15px arial !important; height: 45px !important; margin: 3px 0 0 0 !important; padding: 0 !important; overflow: hidden !important;">WordPress插件修改：Share This (jQuery)</font>
                    </a>
                </td>
        </tr>
    
    <tr>
        <td colspan="5" align="right">
            <a style="text-decoration: none !important;" href="http://www.wumii.com/widget/relatedItems.htm" 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>thickbox是jQuery的插件，可以在页面上显示一个模拟出来的窗体，可以是对话框，AJAX内容，或者仅仅用来展示图片。其使用非常方便，只要在页面中引入了thickbox.js和thickbox.<a href="http://sexywp.com/tags/css" class="st_tag internal_tag" rel="tag" title="标签 CSS 下的日志">css</a>，就可以通过设定A，INPUT，AREA元素的href或者alt属性，就可以使得其功能得以实现。具体的文档，可以参见<a href="http://jquery.com/demo/thickbox/">这里</a>。</p>
<p>WordPress在脚本库中添加了thickbox的脚本，调用起来格外地简单。所以我就选用了这个作为WP插件后台管理界面中，用户交互对话框的解决方案。在这里，介绍一点我在开发过程中的经验。如果需要在thickbox弹出窗体退出时执行一些动作，那么比较好的办法是向#TB_Window的unload事件绑定动作，thickbox在退出时会触发该动作，该动作是在tb_remove()函数中触发的。</p>
<p>向这个事件绑定动作的方法有点小窍门，因为页面初始化完成后，文档Dom中并不包含#TB_Window元素，只有在thickbox被触发后，该元素才添加到Dom中。经过阅读源代码后，我发现，可以在触发thickbox的对象的blur事件中，向#TB_Window的unload事件绑定动作。示例代码如下：</p>
<div class="hl-surround"><div class="hl-main"><ol class="hl-main ln-show" title="Double click to hide line number." ondblclick = "linenumber(this)"><li>&nbsp;<span style="color: Olive;">&lt;</span><span style="color: Green;">a</span><span style="color: Gray;"> </span><span style="color: #00008b;">id</span><span style="color: Gray;">=</span><span style="color: #8b0000;">&quot;</span><span style="color: Red;">open-dialog</span><span style="color: #8b0000;">&quot;</span><span style="color: Gray;"> </span><span style="color: #00008b;">href</span><span style="color: Gray;">=</span><span style="color: #8b0000;">&quot;</span><span style="color: Red;">#TB_inline?height=300&amp;width=400&amp;inlineID=dialog</span><span style="color: #8b0000;">&quot;</span><span style="color: Olive;">&gt;</span><span style="color: Gray;">Click Here</span><span style="color: Olive;">&lt;/</span><span style="color: Green;">a</span><span style="color: Olive;">&gt;</span></li></ol></div></div>
<div class="hl-surround"><div class="hl-main"><ol class="hl-main ln-show" title="Double click to hide line number." ondblclick = "linenumber(this)"><li>&nbsp;<span style="color: Gray;">$</span><span style="color: Olive;">(</span><span style="color: #8b0000;">'</span><span style="color: Red;">#open-dialog</span><span style="color: #8b0000;">'</span><span style="color: Olive;">)</span><span style="color: Gray;">.</span><span style="color: Blue;">blur</span><span style="color: Olive;">(</span><span style="color: Green;">function</span><span style="color: Olive;">(</span><span style="color: Olive;">)</span><span style="color: Olive;">{</span></li>
<li><span style="color: Gray;">&nbsp;&nbsp; $</span><span style="color: Olive;">(</span><span style="color: #8b0000;">'</span><span style="color: Red;">#TB_Window</span><span style="color: #8b0000;">'</span><span style="color: Olive;">)</span><span style="color: Gray;">.</span><span style="color: Blue;">unload</span><span style="color: Olive;">(</span><span style="color: Green;">function</span><span style="color: Olive;">(</span><span style="color: Olive;">)</span><span style="color: Olive;">{</span></li>
<li><span style="color: Gray;">&nbsp;&nbsp; &nbsp; </span><span style="color: #ffa500;">//</span><span style="color: #ffa500;">do something here</span></li>
<li><span style="color: Gray;">&nbsp;&nbsp; </span><span style="color: Olive;">}</span><span style="color: Olive;">)</span><span style="color: Gray;">;</span></li>
<li><span style="color: Gray;">&nbsp;</span><span style="color: Olive;">}</span><span style="color: Olive;">)</span><span style="color: Gray;">;</span></li></ol></div></div>
<table class="wumii-related-items" cellspacing="0" cellpadding="3" border="0"  style="clear: both;">
    
    <tr>
        <td colspan="5"><b><font size="-1"  style="display: block !important; padding: 20px 0 5px !important;">您可能也喜欢：</font></b></td>
    </tr>
    
        <tr>
                <td width="86" valign="top" style="padding: 5px !important; margin: 0 !important;">
                    <a target="_blank" title="jQuery里面用到“打包盒”" style="text-decoration: none !important; cursor: pointer !important;" href="http://app.wumii.com/ext/redirect.htm?url=http%3A%2F%2Fsexywp.com%2Fjquery-wrappers.htm&from=http%3A%2F%2Fsexywp.com%2Fthickbox-tips.htm">
                        <img style="margin: 0 !important; padding: 2px !important; border: 1px solid #DDDDDD !important; width: 80px !important; height: 80px !important;" src="http://static.wumii.com/images/blogWidget/wordpress_default.gif" width="80px" height="80px" /><br />
                        <font size="-1" color="#333333" style="display: block !important; line-height: 15px !important; width: 86px !important; font: 12px/15px arial !important; height: 45px !important; margin: 3px 0 0 0 !important; padding: 0 !important; overflow: hidden !important;">jQuery里面用到“打包盒”</font>
                    </a>
                </td>
                <td width="86" valign="top" style="padding: 5px !important; margin: 0 !important; border-left: 1px solid #DDDDDD !important;">
                    <a target="_blank" title="使用Google AJAX Libraries API替换WordPress自带的js库" style="text-decoration: none !important; cursor: pointer !important;" href="http://app.wumii.com/ext/redirect.htm?url=http%3A%2F%2Fsexywp.com%2Freplace-the-wp-js-lib-by-googleapi.htm&from=http%3A%2F%2Fsexywp.com%2Fthickbox-tips.htm">
                        <img style="margin: 0 !important; padding: 2px !important; border: 1px solid #DDDDDD !important; width: 80px !important; height: 80px !important;" src="http://static.wumii.com/site_images/2011/05/23/9256004.png" width="80px" height="80px" /><br />
                        <font size="-1" color="#333333" style="display: block !important; line-height: 15px !important; width: 86px !important; font: 12px/15px arial !important; height: 45px !important; margin: 3px 0 0 0 !important; padding: 0 !important; overflow: hidden !important;">使用Google AJAX Libraries API替换WordPress自带的js库</font>
                    </a>
                </td>
                <td width="86" valign="top" style="padding: 5px !important; margin: 0 !important; border-left: 1px solid #DDDDDD !important;">
                    <a target="_blank" title="为何以及如何整合Google搜索到WP博客" style="text-decoration: none !important; cursor: pointer !important;" href="http://app.wumii.com/ext/redirect.htm?url=http%3A%2F%2Fsexywp.com%2Fwhy-and-how-to-integrate-google-to-blog.htm&from=http%3A%2F%2Fsexywp.com%2Fthickbox-tips.htm">
                        <img style="margin: 0 !important; padding: 2px !important; border: 1px solid #DDDDDD !important; width: 80px !important; height: 80px !important;" src="http://static.wumii.com/site_images/2011/05/22/9189497.gif" width="80px" height="80px" /><br />
                        <font size="-1" color="#333333" style="display: block !important; line-height: 15px !important; width: 86px !important; font: 12px/15px arial !important; height: 45px !important; margin: 3px 0 0 0 !important; padding: 0 !important; overflow: hidden !important;">为何以及如何整合Google搜索到WP博客</font>
                    </a>
                </td>
                <td width="86" valign="top" style="padding: 5px !important; margin: 0 !important; border-left: 1px solid #DDDDDD !important;">
                    <a target="_blank" title="Template Tags（模板标签）使用指南" style="text-decoration: none !important; cursor: pointer !important;" href="http://app.wumii.com/ext/redirect.htm?url=http%3A%2F%2Fsexywp.com%2Ftemplate-tags-usage.htm&from=http%3A%2F%2Fsexywp.com%2Fthickbox-tips.htm">
                        <img style="margin: 0 !important; padding: 2px !important; border: 1px solid #DDDDDD !important; width: 80px !important; height: 80px !important;" src="http://static.wumii.com/images/blogWidget/wordpress_default.gif" width="80px" height="80px" /><br />
                        <font size="-1" color="#333333" style="display: block !important; line-height: 15px !important; width: 86px !important; font: 12px/15px arial !important; height: 45px !important; margin: 3px 0 0 0 !important; padding: 0 !important; overflow: hidden !important;">Template Tags（模板标签）使用指南</font>
                    </a>
                </td>
                <td width="86" valign="top" style="padding: 5px !important; margin: 0 !important; border-left: 1px solid #DDDDDD !important;">
                    <a target="_blank" title="WordPress插件修改：Share This (jQuery)" style="text-decoration: none !important; cursor: pointer !important;" href="http://app.wumii.com/ext/redirect.htm?url=http%3A%2F%2Fsexywp.com%2Fshare-this-jquery.htm&from=http%3A%2F%2Fsexywp.com%2Fthickbox-tips.htm">
                        <img style="margin: 0 !important; padding: 2px !important; border: 1px solid #DDDDDD !important; width: 80px !important; height: 80px !important;" src="http://static.wumii.com/images/blogWidget/wordpress_default.gif" width="80px" height="80px" /><br />
                        <font size="-1" color="#333333" style="display: block !important; line-height: 15px !important; width: 86px !important; font: 12px/15px arial !important; height: 45px !important; margin: 3px 0 0 0 !important; padding: 0 !important; overflow: hidden !important;">WordPress插件修改：Share This (jQuery)</font>
                    </a>
                </td>
        </tr>
    
    <tr>
        <td colspan="5" align="right">
            <a style="text-decoration: none !important;" href="http://www.wumii.com/widget/relatedItems.htm" 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>
	标签：<a href="http://sexywp.com/tags/code" title="code" rel="tag">code</a>, <a href="http://sexywp.com/tags/develop" title="develop" rel="tag">develop</a>, <a href="http://sexywp.com/tags/jquery" title="jQuery" rel="tag">jQuery</a>, <a href="http://sexywp.com/tags/usage" title="usage" rel="tag">usage</a><br />
]]></content:encoded>
			<wfw:commentRss>http://sexywp.com/thickbox-tips.htm/feed</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>也说用jQuery改进WP评论表单</title>
		<link>http://sexywp.com/progress-enhancement-of-comment-form.htm</link>
		<comments>http://sexywp.com/progress-enhancement-of-comment-form.htm#comments</comments>
		<pubDate>Fri, 14 Nov 2008 13:49:28 +0000</pubDate>
		<dc:creator>Charles</dc:creator>
				<category><![CDATA[WordPress]]></category>
		<category><![CDATA[code]]></category>
		<category><![CDATA[DIY]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[jQuery]]></category>
		<category><![CDATA[my works]]></category>

		<guid isPermaLink="false">http://www.charlestang.cn/?p=263</guid>
		<description><![CDATA[浏览WordPress博客的用户如果启用了Cookie，在发表评论后，信息会被记录在Cookie里，这样，下次登录同一个博客发表评论时，WordPress会为用户自动填写评论表单。可以说，这是一个十分贴心的设计。本文中，将介绍如何使用jQuery，来做到更进一步。

如果用户的信息已经存在了，那么就帮他填好，如果已经填好了，就可以把表单也隐藏起来，并且显示一句欢迎语。不得不说，这个想法非常的有趣，所以，我决定自己来做一下。

第一次看到这个功能是在stephen的博客，然后从他的博客，我链接到了xiaorsz写的文章，然后看到了mg12的文章，再然后是xiaorsz使用jQuery的改进版本。

<span class="readmore"><a href="http://sexywp.com/progress-enhancement-of-comment-form.htm" title="也说用jQuery改进WP评论表单">Keep Reading --- 802 words totally</a></span><table class="wumii-related-items" cellspacing="0" cellpadding="2" border="0" width="100%" style="clear: both;">
    
    <tr>
        <td ><b><font size="-1"  style="display: block !important; padding: 20px 0 5px !important;">您可能也喜欢：</font></b></td>
    </tr>
    
            <tr>
                <td style="margin: 0 !important; padding: 0 !important; line-height: 20px !important;">
                    <img border="0" src="http://static.wumii.com/images/widget/widget_solidPoint.gif">
                    <a target="_blank" style="text-decoration: none !important;" href="http://app.wumii.com/ext/redirect.htm?url=http%3A%2F%2Fsexywp.com%2Fshare-this-jquery.htm&from=http%3A%2F%2Fsexywp.com%2Fprogress-enhancement-of-comment-form.htm">
                        <font size="-1" color="#333333" style="line-height: 1.65em; font-size: 12px !important;">WordPress插件修改：Share This (jQuery)</font>
                    </a>
                </td>
            </tr>
            <tr>
                <td style="margin: 0 !important; padding: 0 !important; line-height: 20px !important;">
                    <img border="0" src="http://static.wumii.com/images/widget/widget_solidPoint.gif">
                    <a target="_blank" style="text-decoration: none !important;" href="http://app.wumii.com/ext/redirect.htm?url=http%3A%2F%2Fsexywp.com%2Fjquery-wrappers.htm&from=http%3A%2F%2Fsexywp.com%2Fprogress-enhancement-of-comment-form.htm">
                        <font size="-1" color="#333333" style="line-height: 1.65em; font-size: 12px !important;">jQuery里面用到“打包盒”</font>
                    </a>
                </td>
            </tr>
            <tr>
                <td style="margin: 0 !important; padding: 0 !important; line-height: 20px !important;">
                    <img border="0" src="http://static.wumii.com/images/widget/widget_solidPoint.gif">
                    <a target="_blank" style="text-decoration: none !important;" href="http://app.wumii.com/ext/redirect.htm?url=http%3A%2F%2Fsexywp.com%2Fwp-kit-cn.htm&from=http%3A%2F%2Fsexywp.com%2Fprogress-enhancement-of-comment-form.htm">
                        <font size="-1" color="#333333" style="line-height: 1.65em; font-size: 12px !important;">WordPress插件：WP Kit CN</font>
                    </a>
                </td>
            </tr>
            <tr>
                <td style="margin: 0 !important; padding: 0 !important; line-height: 20px !important;">
                    <img border="0" src="http://static.wumii.com/images/widget/widget_solidPoint.gif">
                    <a target="_blank" style="text-decoration: none !important;" href="http://app.wumii.com/ext/redirect.htm?url=http%3A%2F%2Fsexywp.com%2Fwordpress-theme-googlecode.htm&from=http%3A%2F%2Fsexywp.com%2Fprogress-enhancement-of-comment-form.htm">
                        <font size="-1" color="#333333" style="line-height: 1.65em; font-size: 12px !important;">WordPress主题：GoogleCode</font>
                    </a>
                </td>
            </tr>
            <tr>
                <td style="margin: 0 !important; padding: 0 !important; line-height: 20px !important;">
                    <img border="0" src="http://static.wumii.com/images/widget/widget_solidPoint.gif">
                    <a target="_blank" style="text-decoration: none !important;" href="http://app.wumii.com/ext/redirect.htm?url=http%3A%2F%2Fsexywp.com%2Fhide-the-search-button.htm&from=http%3A%2F%2Fsexywp.com%2Fprogress-enhancement-of-comment-form.htm">
                        <font size="-1" color="#333333" style="line-height: 1.65em; font-size: 12px !important;">隐藏搜索框旁边的按钮</font>
                    </a>
                </td>
            </tr>
    
    <tr>
        <td  align="right">
            <a style="text-decoration: none !important;" href="http://www.wumii.com/widget/relatedItems.htm" 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>浏览WordPress博客的用户如果启用了Cookie，在发表评论后，信息会被记录在Cookie里，这样，下次登录同一个博客发表评论时，WordPress会为用户自动填写评论表单。可以说，这是一个十分贴心的设计。本文中，将介绍如何使用jQuery，来做到更进一步。</p>
<p><span id="more-263"></span>如果用户的信息已经存在了，那么就帮他填好，如果已经填好了，就可以把表单也隐藏起来，并且显示一句欢迎语。不得不说，这个想法非常的有趣，所以，我决定自己来做一下。</p>
<p>第一次看到这个功能是在<a href="http://www.caxblog.com/2008/11/597.html">stephen的博客</a>，然后从他的博客，我链接到了<a href="http://www.xiaorsz.cn/2008/10/hide-input-box-improve-user-experience/">xiaorsz写的文章</a>，然后看到了<a href="http://www.neoease.com/wordpress-guest-post/">mg12的文章</a>，再然后是<a href="http://www.xiaorsz.cn/2008/11/hide-input-box-jquery/">xiaorsz使用jQuery的改进版本</a>。</p>
<p>上述几篇文章已经对这个问题阐述得非常详细了，虽然说实现细节有所不同，但是基本原理是相同的。</p>
<p>1. 首先，读写Cookie这部分工作，WordPress已经帮我们做好了，基本上不用我们操心，也即如果用户发表过评论，则comment_author变量不为空，并且会自动填写到Comment Form的author输入框中。</p>
<p>2. 然后，我们用一段代码来隐藏昵称，邮件，网站三个输入框。</p>
<p>3. 最后，我们加上一句欢迎语，并且加上能够展开输入框的按钮。</p>
<p>我觉得这样一个小任务，使用jQuery来实现，简直再好也不过了，能够非常好的体现出progress enhancement的精神，所以说，我非要亲手实践一下，过过瘾。</p>
<p>我们看到，如果我们什么也不做，就仅有步骤1所表述的功能，自动填写Comment Form这样一个功能本身就是可用的，只不过不是那么漂亮，那么好玩而已！</p>
<p>接着，如果用户浏览器启用了javascript支持，并且，他正确下载了jQuery和页面代码，那么该用户可以得到步骤2，3提供的功能。也就是说，步骤2，3和javascript支持是并存的。</p>
<p>好了，分析结束，讲讲我的实现。因为是增强页面功能，所以，我就不打算去动原来的页面模板文件了。昵称、邮件和网址输入域，各自都有自己的id（分别是author，email和url），对于jQuery来说，这已经非常足够了，所以模板文件没什么需要改动的。只要创建一个js文件，写好上面的功能，链接进去就ok了。</p>
<p>下面是代码：</p>
<div class="hl-surround"><div class="hl-main"><span style="color: Blue;">jQuery</span><span style="color: Olive;">(</span><span style="color: Teal;">document</span><span style="color: Olive;">)</span><span style="color: Gray;">.</span><span style="color: Blue;">ready</span><span style="color: Olive;">(</span><span style="color: Green;">function</span><span style="color: Olive;">(</span><span style="color: Olive;">)</span><span style="color: Olive;">{</span><span style="color: Gray;"><br />&nbsp;&nbsp; &nbsp;</span><span style="color: Green;">var</span><span style="color: Gray;"> $</span><span style="color: Blue;">author</span><span style="color: Gray;"> = </span><span style="color: Blue;">jQuery</span><span style="color: Olive;">(</span><span style="color: #8b0000;">'</span><span style="color: Red;">#author</span><span style="color: #8b0000;">'</span><span style="color: Olive;">)</span><span style="color: Gray;">;<br />&nbsp;&nbsp; &nbsp;</span><span style="color: Green;">var</span><span style="color: Gray;"> $</span><span style="color: Blue;">author_email</span><span style="color: Gray;"> = </span><span style="color: Blue;">jQuery</span><span style="color: Olive;">(</span><span style="color: #8b0000;">'</span><span style="color: Red;">#email</span><span style="color: #8b0000;">'</span><span style="color: Olive;">)</span><span style="color: Gray;">;<br />&nbsp;&nbsp; &nbsp;</span><span style="color: Green;">if</span><span style="color: Gray;"> </span><span style="color: Olive;">(</span><span style="color: Gray;">$</span><span style="color: Blue;">author</span><span style="color: Gray;">.</span><span style="color: Blue;">val</span><span style="color: Olive;">(</span><span style="color: Olive;">)</span><span style="color: Gray;"> != </span><span style="color: #8b0000;">'</span><span style="color: #8b0000;">'</span><span style="color: Gray;"> &amp;&amp; $</span><span style="color: Blue;">author_email</span><span style="color: Gray;">.</span><span style="color: Blue;">val</span><span style="color: Olive;">(</span><span style="color: Olive;">)</span><span style="color: Gray;"> != </span><span style="color: #8b0000;">'</span><span style="color: #8b0000;">'</span><span style="color: Olive;">)</span><span style="color: Gray;"> </span><span style="color: Olive;">{</span><span style="color: Gray;"><br />&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;$</span><span style="color: Blue;">author</span><span style="color: Gray;"> = $</span><span style="color: Blue;">author</span><span style="color: Gray;">.</span><span style="color: Blue;">parent</span><span style="color: Olive;">(</span><span style="color: Olive;">)</span><span style="color: Gray;">.</span><span style="color: Blue;">css</span><span style="color: Olive;">(</span><span style="color: #8b0000;">'</span><span style="color: Red;">display</span><span style="color: #8b0000;">'</span><span style="color: Gray;">,</span><span style="color: #8b0000;">'</span><span style="color: Red;">none</span><span style="color: #8b0000;">'</span><span style="color: Olive;">)</span><span style="color: Gray;">;<br />&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;$</span><span style="color: Blue;">author_email</span><span style="color: Gray;"> = $</span><span style="color: Blue;">author_email</span><span style="color: Gray;">.</span><span style="color: Blue;">parent</span><span style="color: Olive;">(</span><span style="color: Olive;">)</span><span style="color: Gray;">.</span><span style="color: Blue;">css</span><span style="color: Olive;">(</span><span style="color: #8b0000;">'</span><span style="color: Red;">display</span><span style="color: #8b0000;">'</span><span style="color: Gray;">,</span><span style="color: #8b0000;">'</span><span style="color: Red;">none</span><span style="color: #8b0000;">'</span><span style="color: Olive;">)</span><span style="color: Gray;">;<br />&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;</span><span style="color: Green;">var</span><span style="color: Gray;"> $</span><span style="color: Blue;">author_url</span><span style="color: Gray;"> = </span><span style="color: Blue;">jQuery</span><span style="color: Olive;">(</span><span style="color: #8b0000;">'</span><span style="color: Red;">#url</span><span style="color: #8b0000;">'</span><span style="color: Olive;">)</span><span style="color: Gray;">.</span><span style="color: Blue;">parent</span><span style="color: Olive;">(</span><span style="color: Olive;">)</span><span style="color: Gray;">.</span><span style="color: Blue;">css</span><span style="color: Olive;">(</span><span style="color: #8b0000;">'</span><span style="color: Red;">display</span><span style="color: #8b0000;">'</span><span style="color: Gray;">,</span><span style="color: #8b0000;">'</span><span style="color: Red;">none</span><span style="color: #8b0000;">'</span><span style="color: Olive;">)</span><span style="color: Gray;">;<br />&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;$</span><span style="color: Blue;">author</span><span style="color: Gray;">.</span><span style="color: Blue;">before</span><span style="color: Olive;">(</span><span style="color: Blue;">jQuery</span><span style="color: Olive;">(</span><span style="color: #8b0000;">'</span><span style="color: Red;">&lt;div class=&quot;form_line&quot;&gt;Welcom Back! </span><span style="color: #8b0000;">'</span><span style="color: Gray;">+ $</span><span style="color: Blue;">author</span><span style="color: Gray;">.</span><span style="color: Blue;">find</span><span style="color: Olive;">(</span><span style="color: #8b0000;">'</span><span style="color: Red;">#author</span><span style="color: #8b0000;">'</span><span style="color: Olive;">)</span><span style="color: Gray;">.</span><span style="color: Blue;">val</span><span style="color: Olive;">(</span><span style="color: Olive;">)</span><span style="color: Gray;"> +</span><span style="color: #8b0000;">'</span><span style="color: Red;">! &lt;/div&gt;</span><span style="color: #8b0000;">'</span><span style="color: Olive;">)</span><span style="color: Gray;">.</span><span style="color: Blue;">append</span><span style="color: Olive;">(</span><span style="color: Gray;"><br />&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</span><span style="color: Blue;">jQuery</span><span style="color: Olive;">(</span><span style="color: #8b0000;">'</span><span style="color: Red;">&lt;a href=&quot;#&quot;&gt;Change &amp;raquo;&lt;/a&gt;</span><span style="color: #8b0000;">'</span><span style="color: Olive;">)</span><span style="color: Gray;">.</span><span style="color: Blue;">click</span><span style="color: Olive;">(</span><span style="color: Green;">function</span><span style="color: Olive;">(</span><span style="color: Olive;">)</span><span style="color: Olive;">{</span><span style="color: Gray;"><br />&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;$</span><span style="color: Blue;">author</span><span style="color: Gray;">.</span><span style="color: Blue;">css</span><span style="color: Olive;">(</span><span style="color: #8b0000;">'</span><span style="color: Red;">display</span><span style="color: #8b0000;">'</span><span style="color: Gray;">,</span><span style="color: #8b0000;">'</span><span style="color: #8b0000;">'</span><span style="color: Olive;">)</span><span style="color: Gray;">;<br />&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;$</span><span style="color: Blue;">author_email</span><span style="color: Gray;">.</span><span style="color: Blue;">css</span><span style="color: Olive;">(</span><span style="color: #8b0000;">'</span><span style="color: Red;">display</span><span style="color: #8b0000;">'</span><span style="color: Gray;">,</span><span style="color: #8b0000;">'</span><span style="color: #8b0000;">'</span><span style="color: Olive;">)</span><span style="color: Gray;">;<br />&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;$</span><span style="color: Blue;">author_url</span><span style="color: Gray;">.</span><span style="color: Blue;">css</span><span style="color: Olive;">(</span><span style="color: #8b0000;">'</span><span style="color: Red;">display</span><span style="color: #8b0000;">'</span><span style="color: Gray;">,</span><span style="color: #8b0000;">'</span><span style="color: #8b0000;">'</span><span style="color: Olive;">)</span><span style="color: Gray;">;<br />&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</span><span style="color: Blue;">jQuery</span><span style="color: Olive;">(</span><span style="color: Green;">this</span><span style="color: Olive;">)</span><span style="color: Gray;">.</span><span style="color: Blue;">parent</span><span style="color: Olive;">(</span><span style="color: Olive;">)</span><span style="color: Gray;">.</span><span style="color: Blue;">remove</span><span style="color: Olive;">(</span><span style="color: Olive;">)</span><span style="color: Gray;">;<br />&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</span><span style="color: Green;">return</span><span style="color: Gray;"> </span><span style="color: Green;">false</span><span style="color: Gray;">;<br />&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</span><span style="color: Olive;">}</span><span style="color: Olive;">)</span><span style="color: Gray;"><br />&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;</span><span style="color: Olive;">)</span><span style="color: Olive;">)</span><span style="color: Gray;">;<br />&nbsp;&nbsp; &nbsp;</span><span style="color: Olive;">}</span><span style="color: Gray;"><br /></span><span style="color: Olive;">}</span><span style="color: Olive;">)</span><span style="color: Gray;">;</span></div></div>
<table class="wumii-related-items" cellspacing="0" cellpadding="2" border="0" width="100%" style="clear: both;">
    
    <tr>
        <td ><b><font size="-1"  style="display: block !important; padding: 20px 0 5px !important;">您可能也喜欢：</font></b></td>
    </tr>
    
            <tr>
                <td style="margin: 0 !important; padding: 0 !important; line-height: 20px !important;">
                    <img border="0" src="http://static.wumii.com/images/widget/widget_solidPoint.gif">
                    <a target="_blank" style="text-decoration: none !important;" href="http://app.wumii.com/ext/redirect.htm?url=http%3A%2F%2Fsexywp.com%2Fshare-this-jquery.htm&from=http%3A%2F%2Fsexywp.com%2Fprogress-enhancement-of-comment-form.htm">
                        <font size="-1" color="#333333" style="line-height: 1.65em; font-size: 12px !important;">WordPress插件修改：Share This (jQuery)</font>
                    </a>
                </td>
            </tr>
            <tr>
                <td style="margin: 0 !important; padding: 0 !important; line-height: 20px !important;">
                    <img border="0" src="http://static.wumii.com/images/widget/widget_solidPoint.gif">
                    <a target="_blank" style="text-decoration: none !important;" href="http://app.wumii.com/ext/redirect.htm?url=http%3A%2F%2Fsexywp.com%2Fjquery-wrappers.htm&from=http%3A%2F%2Fsexywp.com%2Fprogress-enhancement-of-comment-form.htm">
                        <font size="-1" color="#333333" style="line-height: 1.65em; font-size: 12px !important;">jQuery里面用到“打包盒”</font>
                    </a>
                </td>
            </tr>
            <tr>
                <td style="margin: 0 !important; padding: 0 !important; line-height: 20px !important;">
                    <img border="0" src="http://static.wumii.com/images/widget/widget_solidPoint.gif">
                    <a target="_blank" style="text-decoration: none !important;" href="http://app.wumii.com/ext/redirect.htm?url=http%3A%2F%2Fsexywp.com%2Fwp-kit-cn.htm&from=http%3A%2F%2Fsexywp.com%2Fprogress-enhancement-of-comment-form.htm">
                        <font size="-1" color="#333333" style="line-height: 1.65em; font-size: 12px !important;">WordPress插件：WP Kit CN</font>
                    </a>
                </td>
            </tr>
            <tr>
                <td style="margin: 0 !important; padding: 0 !important; line-height: 20px !important;">
                    <img border="0" src="http://static.wumii.com/images/widget/widget_solidPoint.gif">
                    <a target="_blank" style="text-decoration: none !important;" href="http://app.wumii.com/ext/redirect.htm?url=http%3A%2F%2Fsexywp.com%2Fwordpress-theme-googlecode.htm&from=http%3A%2F%2Fsexywp.com%2Fprogress-enhancement-of-comment-form.htm">
                        <font size="-1" color="#333333" style="line-height: 1.65em; font-size: 12px !important;">WordPress主题：GoogleCode</font>
                    </a>
                </td>
            </tr>
            <tr>
                <td style="margin: 0 !important; padding: 0 !important; line-height: 20px !important;">
                    <img border="0" src="http://static.wumii.com/images/widget/widget_solidPoint.gif">
                    <a target="_blank" style="text-decoration: none !important;" href="http://app.wumii.com/ext/redirect.htm?url=http%3A%2F%2Fsexywp.com%2Fhide-the-search-button.htm&from=http%3A%2F%2Fsexywp.com%2Fprogress-enhancement-of-comment-form.htm">
                        <font size="-1" color="#333333" style="line-height: 1.65em; font-size: 12px !important;">隐藏搜索框旁边的按钮</font>
                    </a>
                </td>
            </tr>
    
    <tr>
        <td  align="right">
            <a style="text-decoration: none !important;" href="http://www.wumii.com/widget/relatedItems.htm" 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>
	标签：<a href="http://sexywp.com/tags/code" title="code" rel="tag">code</a>, <a href="http://sexywp.com/tags/diy" title="DIY" rel="tag">DIY</a>, <a href="http://sexywp.com/tags/javascript" title="javascript" rel="tag">javascript</a>, <a href="http://sexywp.com/tags/jquery" title="jQuery" rel="tag">jQuery</a>, <a href="http://sexywp.com/tags/my-works" title="my works" rel="tag">my works</a>, <a href="http://sexywp.com/tags/wordpress" title="WordPress" rel="tag">WordPress</a><br />
]]></content:encoded>
			<wfw:commentRss>http://sexywp.com/progress-enhancement-of-comment-form.htm/feed</wfw:commentRss>
		<slash:comments>24</slash:comments>
		</item>
		<item>
		<title>无侵入与可用性层</title>
		<link>http://sexywp.com/non-intrusive-and-useability.htm</link>
		<comments>http://sexywp.com/non-intrusive-and-useability.htm#comments</comments>
		<pubDate>Thu, 25 Sep 2008 08:28:21 +0000</pubDate>
		<dc:creator>Charles</dc:creator>
				<category><![CDATA[工作相关]]></category>
		<category><![CDATA[ajax]]></category>
		<category><![CDATA[develop]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[jQuery]]></category>
		<category><![CDATA[opinion]]></category>

		<guid isPermaLink="false">http://www.charlestang.cn/?p=245</guid>
		<description><![CDATA[使用jQuery一段时间的感想

早在使用WP之前的很久，我就听说了jQuery了，那个时候，只是惊叹于jQuery的视觉效果，然后记住了这个名字，但是一直也没有开始学习。直到我开始折腾WP这个程序，模板，插件，我才开始更广泛深入地接触jQuery。

在学习jQuery的过程中，我也看了一些牛人关于js的观点，并且从内心深处对此表示深刻认同。

<span class="readmore"><a href="http://sexywp.com/non-intrusive-and-useability.htm" title="无侵入与可用性层">Keep Reading --- 1279 words totally</a></span><table class="wumii-related-items" cellspacing="0" cellpadding="2" border="0" width="100%" style="clear: both;">
    
    <tr>
        <td ><b><font size="-1"  style="display: block !important; padding: 20px 0 5px !important;">您可能也喜欢：</font></b></td>
    </tr>
    
            <tr>
                <td style="margin: 0 !important; padding: 0 !important; line-height: 20px !important;">
                    <img border="0" src="http://static.wumii.com/images/widget/widget_solidPoint.gif">
                    <a target="_blank" style="text-decoration: none !important;" href="http://app.wumii.com/ext/redirect.htm?url=http%3A%2F%2Fsexywp.com%2Fuse-firephp-in-ajax-development.htm&from=http%3A%2F%2Fsexywp.com%2Fnon-intrusive-and-useability.htm">
                        <font size="-1" color="#333333" style="line-height: 1.65em; font-size: 12px !important;">使用FirePHP辅助AJAX应用开发</font>
                    </a>
                </td>
            </tr>
            <tr>
                <td style="margin: 0 !important; padding: 0 !important; line-height: 20px !important;">
                    <img border="0" src="http://static.wumii.com/images/widget/widget_solidPoint.gif">
                    <a target="_blank" style="text-decoration: none !important;" href="http://app.wumii.com/ext/redirect.htm?url=http%3A%2F%2Fsexywp.com%2Fhow-to-use-ajax-correctly.htm&from=http%3A%2F%2Fsexywp.com%2Fnon-intrusive-and-useability.htm">
                        <font size="-1" color="#333333" style="line-height: 1.65em; font-size: 12px !important;">怎样增加AJAX的可靠性呢？</font>
                    </a>
                </td>
            </tr>
            <tr>
                <td style="margin: 0 !important; padding: 0 !important; line-height: 20px !important;">
                    <img border="0" src="http://static.wumii.com/images/widget/widget_solidPoint.gif">
                    <a target="_blank" style="text-decoration: none !important;" href="http://app.wumii.com/ext/redirect.htm?url=http%3A%2F%2Fsexywp.com%2Fjquery-wrappers.htm&from=http%3A%2F%2Fsexywp.com%2Fnon-intrusive-and-useability.htm">
                        <font size="-1" color="#333333" style="line-height: 1.65em; font-size: 12px !important;">jQuery里面用到“打包盒”</font>
                    </a>
                </td>
            </tr>
            <tr>
                <td style="margin: 0 !important; padding: 0 !important; line-height: 20px !important;">
                    <img border="0" src="http://static.wumii.com/images/widget/widget_solidPoint.gif">
                    <a target="_blank" style="text-decoration: none !important;" href="http://app.wumii.com/ext/redirect.htm?url=http%3A%2F%2Fsexywp.com%2Fwe-should-care-more-about-ieer.htm&from=http%3A%2F%2Fsexywp.com%2Fnon-intrusive-and-useability.htm">
                        <font size="-1" color="#333333" style="line-height: 1.65em; font-size: 12px !important;">我们应该更关心IE的用户</font>
                    </a>
                </td>
            </tr>
            <tr>
                <td style="margin: 0 !important; padding: 0 !important; line-height: 20px !important;">
                    <img border="0" src="http://static.wumii.com/images/widget/widget_solidPoint.gif">
                    <a target="_blank" style="text-decoration: none !important;" href="http://app.wumii.com/ext/redirect.htm?url=http%3A%2F%2Fsexywp.com%2Fprogress-enhancement-of-comment-form.htm&from=http%3A%2F%2Fsexywp.com%2Fnon-intrusive-and-useability.htm">
                        <font size="-1" color="#333333" style="line-height: 1.65em; font-size: 12px !important;">也说用jQuery改进WP评论表单</font>
                    </a>
                </td>
            </tr>
    
    <tr>
        <td  align="right">
            <a style="text-decoration: none !important;" href="http://www.wumii.com/widget/relatedItems.htm" 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[<h3>使用jQuery一段时间的感想</h3>
<p>早在使用WP之前的很久，我就听说了jQuery了，那个时候，只是惊叹于jQuery的视觉效果，然后记住了这个名字，但是一直也没有开始学习。直到我开始折腾WP这个程序，模板，插件，我才开始更广泛深入地接触jQuery。</p>
<p>在学习jQuery的过程中，我也看了一些牛人关于js的观点，并且从内心深处对此表示深刻认同。</p>
<p><span id="more-245"></span></p>
<h3>无侵入</h3>
<p>js代码应该单独的放在一个文件里面，而不应该混杂在html代码中。现在的页面设计也要遵循数据，表现，行为（动作？）分离的原则。html代码就是纯数据，按照数据本身的逻辑关系来组织，而页面外观，则是纯表现，使用css来指定，最后是行为（动作？或者事件响应？），使用js来实现。</p>
<p>三者的分离，有多种好处，更清晰的逻辑结构，更纯粹的数据，更好的可维护性，而且还对搜索引擎非常友好。外部引入的js和css不会对爬虫分析页面内容造成太大的影响。</p>
<p>所以，在编写js的时候，就要竭尽全力地去将js代码与页面完全剥离开来，至少要做到在&lt;body&gt;内部，完全不出现js代码。</p>
<p>这种代码编写方式，就要求我们写js的时候改变一些陋习，并且更加地依赖于文档对象模型DOM。好，说道这里，问题就来了，使用DOM模型的话，遍历DOM树，就是关键了，如果不使用框架的话，就要自己写代码遍历，但是，由于那个恶心的问题，就是浏览器兼容性问题，各个浏览器实现的DOM模型和支持的js语法有着细微的差别，自己遍历DOM会痛苦无比。jQuery在这个方面，做得非常出色，基本上包揽了一切肮脏的工作。让人写起代码来格外愉快。</p>
<p>实在是很喜欢jQ在DOM遍历中的便捷。</p>
<h3>可用性层</h3>
<p>关于可用性层，是又一个现在很流行的概念。在十分关注用户体验的Web 2.0时代，页面可用性，已经成为了考量一个页面的质量的关键标准。</p>
<p>但是js由于其巨大的不稳定性，经常失效；还有就是早先对于js的滥用（如该死的弹出广告，漂浮广告，恶意浏览器插件），使得很多用户对js深具戒心，经常有些极端的用户干脆关闭js，斩草除根。</p>
<p>在这种环境下，js的应用只能在夹缝中艰难求存。于是乎，js成了一个附加的可用性层。“附加”代表可有可无。我现在设计页面，写js，也是在这么一种假设下写的，即“用户可能禁用了js”。追求的效果就是，如果用户没有开启js，那么你能看到全部内容，保证了页面可访问性，牺牲了可用性。而如果开启了js，那么用户将得到更加有趣的体验。</p>
<p>于是乎，我就产生了这么一种感觉，页面上附加的所有js应用，有一种“事务”的特征。我们的术语叫做“transaction”。主要就是其中原子性的特点。如果支持js，那么你觉得这个页面是一个功能丰富的ajax应用，非常炫目。如果不开启js，那么你觉得这是一个普通页面，你甚至没法觉察到这个页面背后其实有着大量的js代码。他们只是简单的被完全的，干干净净的，彻彻底底的拿掉了。</p>
<p>关于这一点，我使用jQ的体验，还是由于jQ那操纵DOM的优秀能力，使得这种理念或者这种理念指导下的开发成为了一件让人愉快的事情。</p>
<h3>总结</h3>
<p>上面两点是我在学习使用jQ的过程中的一些感想，写出来与大家分享一下。我接触Web开发的时间非常短，基本上没有什么经验可以谈的，上面的很多的观点，来自很多我认为牛的人，包括ppk（这个人让我对js的认识更深了一层），以及我订阅的一些牛人的博客里面展示的代码片段所传达的思想。</p>
<table class="wumii-related-items" cellspacing="0" cellpadding="2" border="0" width="100%" style="clear: both;">
    
    <tr>
        <td ><b><font size="-1"  style="display: block !important; padding: 20px 0 5px !important;">您可能也喜欢：</font></b></td>
    </tr>
    
            <tr>
                <td style="margin: 0 !important; padding: 0 !important; line-height: 20px !important;">
                    <img border="0" src="http://static.wumii.com/images/widget/widget_solidPoint.gif">
                    <a target="_blank" style="text-decoration: none !important;" href="http://app.wumii.com/ext/redirect.htm?url=http%3A%2F%2Fsexywp.com%2Fuse-firephp-in-ajax-development.htm&from=http%3A%2F%2Fsexywp.com%2Fnon-intrusive-and-useability.htm">
                        <font size="-1" color="#333333" style="line-height: 1.65em; font-size: 12px !important;">使用FirePHP辅助AJAX应用开发</font>
                    </a>
                </td>
            </tr>
            <tr>
                <td style="margin: 0 !important; padding: 0 !important; line-height: 20px !important;">
                    <img border="0" src="http://static.wumii.com/images/widget/widget_solidPoint.gif">
                    <a target="_blank" style="text-decoration: none !important;" href="http://app.wumii.com/ext/redirect.htm?url=http%3A%2F%2Fsexywp.com%2Fhow-to-use-ajax-correctly.htm&from=http%3A%2F%2Fsexywp.com%2Fnon-intrusive-and-useability.htm">
                        <font size="-1" color="#333333" style="line-height: 1.65em; font-size: 12px !important;">怎样增加AJAX的可靠性呢？</font>
                    </a>
                </td>
            </tr>
            <tr>
                <td style="margin: 0 !important; padding: 0 !important; line-height: 20px !important;">
                    <img border="0" src="http://static.wumii.com/images/widget/widget_solidPoint.gif">
                    <a target="_blank" style="text-decoration: none !important;" href="http://app.wumii.com/ext/redirect.htm?url=http%3A%2F%2Fsexywp.com%2Fjquery-wrappers.htm&from=http%3A%2F%2Fsexywp.com%2Fnon-intrusive-and-useability.htm">
                        <font size="-1" color="#333333" style="line-height: 1.65em; font-size: 12px !important;">jQuery里面用到“打包盒”</font>
                    </a>
                </td>
            </tr>
            <tr>
                <td style="margin: 0 !important; padding: 0 !important; line-height: 20px !important;">
                    <img border="0" src="http://static.wumii.com/images/widget/widget_solidPoint.gif">
                    <a target="_blank" style="text-decoration: none !important;" href="http://app.wumii.com/ext/redirect.htm?url=http%3A%2F%2Fsexywp.com%2Fwe-should-care-more-about-ieer.htm&from=http%3A%2F%2Fsexywp.com%2Fnon-intrusive-and-useability.htm">
                        <font size="-1" color="#333333" style="line-height: 1.65em; font-size: 12px !important;">我们应该更关心IE的用户</font>
                    </a>
                </td>
            </tr>
            <tr>
                <td style="margin: 0 !important; padding: 0 !important; line-height: 20px !important;">
                    <img border="0" src="http://static.wumii.com/images/widget/widget_solidPoint.gif">
                    <a target="_blank" style="text-decoration: none !important;" href="http://app.wumii.com/ext/redirect.htm?url=http%3A%2F%2Fsexywp.com%2Fprogress-enhancement-of-comment-form.htm&from=http%3A%2F%2Fsexywp.com%2Fnon-intrusive-and-useability.htm">
                        <font size="-1" color="#333333" style="line-height: 1.65em; font-size: 12px !important;">也说用jQuery改进WP评论表单</font>
                    </a>
                </td>
            </tr>
    
    <tr>
        <td  align="right">
            <a style="text-decoration: none !important;" href="http://www.wumii.com/widget/relatedItems.htm" 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>
	标签：<a href="http://sexywp.com/tags/ajax" title="ajax" rel="tag">ajax</a>, <a href="http://sexywp.com/tags/develop" title="develop" rel="tag">develop</a>, <a href="http://sexywp.com/tags/javascript" title="javascript" rel="tag">javascript</a>, <a href="http://sexywp.com/tags/jquery" title="jQuery" rel="tag">jQuery</a>, <a href="http://sexywp.com/tags/opinion" title="opinion" rel="tag">opinion</a><br />
]]></content:encoded>
			<wfw:commentRss>http://sexywp.com/non-intrusive-and-useability.htm/feed</wfw:commentRss>
		<slash:comments>28</slash:comments>
		</item>
		<item>
		<title>WordPress插件修改：Share This (jQuery)</title>
		<link>http://sexywp.com/share-this-jquery.htm</link>
		<comments>http://sexywp.com/share-this-jquery.htm#comments</comments>
		<pubDate>Tue, 02 Sep 2008 12:15:49 +0000</pubDate>
		<dc:creator>Charles</dc:creator>
				<category><![CDATA[Plugins]]></category>
		<category><![CDATA[WordPress]]></category>
		<category><![CDATA[jQuery]]></category>
		<category><![CDATA[my works]]></category>
		<category><![CDATA[plugins]]></category>

		<guid isPermaLink="false">http://www.charlestang.cn/?p=230</guid>
		<description><![CDATA[Share This 中文，我很喜欢，看起来效果很好，但是…… 





<span class="readmore"><a href="http://sexywp.com/share-this-jquery.htm" title="WordPress插件修改：Share This (jQuery)">Keep Reading --- 643 words totally</a></span><table class="wumii-related-items" cellspacing="0" cellpadding="3" border="0"  style="clear: both;">
    
    <tr>
        <td colspan="5"><b><font size="-1"  style="display: block !important; padding: 20px 0 5px !important;">您可能也喜欢：</font></b></td>
    </tr>
    
        <tr>
                <td width="86" valign="top" style="padding: 5px !important; margin: 0 !important;">
                    <a target="_blank" title="WordPress插件：选项查看器" style="text-decoration: none !important; cursor: pointer !important;" href="http://app.wumii.com/ext/redirect.htm?url=http%3A%2F%2Fsexywp.com%2Fplugin-options-inspector.htm&from=http%3A%2F%2Fsexywp.com%2Fshare-this-jquery.htm">
                        <img style="margin: 0 !important; padding: 2px !important; border: 1px solid #DDDDDD !important; width: 80px !important; height: 80px !important;" src="http://static.wumii.com/site_images/2011/05/31/10319696.png" width="80px" height="80px" /><br />
                        <font size="-1" color="#333333" style="display: block !important; line-height: 15px !important; width: 86px !important; font: 12px/15px arial !important; height: 45px !important; margin: 3px 0 0 0 !important; padding: 0 !important; overflow: hidden !important;">WordPress插件：选项查看器</font>
                    </a>
                </td>
                <td width="86" valign="top" style="padding: 5px !important; margin: 0 !important; border-left: 1px solid #DDDDDD !important;">
                    <a target="_blank" title="WordPress插件介绍：cformsII 及其汉化包" style="text-decoration: none !important; cursor: pointer !important;" href="http://app.wumii.com/ext/redirect.htm?url=http%3A%2F%2Fsexywp.com%2Fwp-plugins-cformsii-intro.htm&from=http%3A%2F%2Fsexywp.com%2Fshare-this-jquery.htm">
                        <img style="margin: 0 !important; padding: 2px !important; border: 1px solid #DDDDDD !important; width: 80px !important; height: 80px !important;" src="http://static.wumii.com/images/blogWidget/wordpress_default.gif" width="80px" height="80px" /><br />
                        <font size="-1" color="#333333" style="display: block !important; line-height: 15px !important; width: 86px !important; font: 12px/15px arial !important; height: 45px !important; margin: 3px 0 0 0 !important; padding: 0 !important; overflow: hidden !important;">WordPress插件介绍：cformsII 及其汉化包</font>
                    </a>
                </td>
                <td width="86" valign="top" style="padding: 5px !important; margin: 0 !important; border-left: 1px solid #DDDDDD !important;">
                    <a target="_blank" title="WordPress Plugin：Flash MP3 Player" style="text-decoration: none !important; cursor: pointer !important;" href="http://app.wumii.com/ext/redirect.htm?url=http%3A%2F%2Fsexywp.com%2Fflash-player-widget.htm&from=http%3A%2F%2Fsexywp.com%2Fshare-this-jquery.htm">
                        <img style="margin: 0 !important; padding: 2px !important; border: 1px solid #DDDDDD !important; width: 80px !important; height: 80px !important;" src="http://static.wumii.com/images/blogWidget/wordpress_default.gif" width="80px" height="80px" /><br />
                        <font size="-1" color="#333333" style="display: block !important; line-height: 15px !important; width: 86px !important; font: 12px/15px arial !important; height: 45px !important; margin: 3px 0 0 0 !important; padding: 0 !important; overflow: hidden !important;">WordPress Plugin：Flash MP3 Player</font>
                    </a>
                </td>
                <td width="86" valign="top" style="padding: 5px !important; margin: 0 !important; border-left: 1px solid #DDDDDD !important;">
                    <a target="_blank" title="WordPress主题：GoogleCode" style="text-decoration: none !important; cursor: pointer !important;" href="http://app.wumii.com/ext/redirect.htm?url=http%3A%2F%2Fsexywp.com%2Fwordpress-theme-googlecode.htm&from=http%3A%2F%2Fsexywp.com%2Fshare-this-jquery.htm">
                        <img style="margin: 0 !important; padding: 2px !important; border: 1px solid #DDDDDD !important; width: 80px !important; height: 80px !important;" src="http://static.wumii.com/site_images/2011/05/22/9170670.png" width="80px" height="80px" /><br />
                        <font size="-1" color="#333333" style="display: block !important; line-height: 15px !important; width: 86px !important; font: 12px/15px arial !important; height: 45px !important; margin: 3px 0 0 0 !important; padding: 0 !important; overflow: hidden !important;">WordPress主题：GoogleCode</font>
                    </a>
                </td>
                <td width="86" valign="top" style="padding: 5px !important; margin: 0 !important; border-left: 1px solid #DDDDDD !important;">
                    <a target="_blank" title="WordPress:插件开发API（Plugin API）" style="text-decoration: none !important; cursor: pointer !important;" href="http://app.wumii.com/ext/redirect.htm?url=http%3A%2F%2Fsexywp.com%2Fwordpress-plugin-api.htm&from=http%3A%2F%2Fsexywp.com%2Fshare-this-jquery.htm">
                        <img style="margin: 0 !important; padding: 2px !important; border: 1px solid #DDDDDD !important; width: 80px !important; height: 80px !important;" src="http://static.wumii.com/images/blogWidget/wordpress_default.gif" width="80px" height="80px" /><br />
                        <font size="-1" color="#333333" style="display: block !important; line-height: 15px !important; width: 86px !important; font: 12px/15px arial !important; height: 45px !important; margin: 3px 0 0 0 !important; padding: 0 !important; overflow: hidden !important;">WordPress:插件开发API（Plugin API）</font>
                    </a>
                </td>
        </tr>
    
    <tr>
        <td colspan="5" align="right">
            <a style="text-decoration: none !important;" href="http://www.wumii.com/widget/relatedItems.htm" 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 href="http://www.happinesz.cn/archives/328/">Share This 中文</a>，我很喜欢，看起来效果很好，但是…… </p>
<p><span id="more-230"></span></p>
<blockquote>
<p>建议牛人出来重写<a href="http://happinesz.cn">sofish</a>改过的那个Share This。</p>
<p><a href="http://alexking.org">Alex King</a>大大写的<a href="http://alexking.org/projects/wordpress">Share this</a>基本上没有照顾到中文用户。</p>
<p>后来，经过sofish改写，我们有了非常适合中文博客使用的Share this 中文。</p>
<p>但是，这个插件有三大缺憾：</p>
<p>1. 这么简单的功能，居然动用了prototype，此类库尺寸达128k。</p>
<p>2. 在hook使用方面，没有进行优化，如果一般用户不知道，安装了这个插件会在每一个页面都引用一个prototype进来，汗 ，实际上只需要在single页面引入，更人性化的做法是根据用户的需求来引入js文件和css文件。</p>
<p>3. 完全应该改个名字重新发布，这并不是说对原作者不尊重，而是现在这个插件的代码看起来和原来的已经差别较大了，而且此插件进入官方目录，使用的是GPL协议，我们可以另立门户，这样使用此插件的用户就不必要收到升级的困扰，上次我误点了升级，直接跳到Alex King的版本上了。</p>
<p>希望能有人接手这个工作！</p>
<p>最后还是要谢谢写出这个插件的Alex King和修改它的sofish。</p></blockquote>
<p>上面是我在论坛发的帖子，没有人响应我，囧……</p>
<p>其实，说的就是一直以来我想做的事情。</p>
<p>实在不能忍了，于是自己动手了，囧！</p>
<p>那个插件的sofish版本还有一个问题的，当时<a href="http://www.caxblog.com" title="stephen">stephen</a>跟我提出过的，就是点击一个搜藏链接的时候，应该采用打开新页面更加符合中国人的习惯。这次我也一并给改了。</p>
<p>好，我就不多说了，把我改的版本放出来给大家分享下吧。</p>
<p>http://www.box.net/shared/naa6u9oi2j</p>
<p>建议：模板里已经使用了jQuery的人推荐用这个版本。</p>
<p>另外：jQuery也不是必须的，因为基本上没有用到相关度的什么特性，所以，建议使用纯js重写，囧！</p>
<p>有学习js的，jQuery的同学愿意尝试下么？</p>
<p>Updated:2008年9月2日21:28:37</p>
<p>调用方法没有变化，大家去sofish的那个页面看看调用方法吧，我懒得写了 <img src='http://sexywp.com/cc/wp-includes/images/smilies/icon_mrgreen.gif' alt=':mrgreen:' class='wp-smiley' /> </p>
<table class="wumii-related-items" cellspacing="0" cellpadding="3" border="0"  style="clear: both;">
    
    <tr>
        <td colspan="5"><b><font size="-1"  style="display: block !important; padding: 20px 0 5px !important;">您可能也喜欢：</font></b></td>
    </tr>
    
        <tr>
                <td width="86" valign="top" style="padding: 5px !important; margin: 0 !important;">
                    <a target="_blank" title="WordPress插件：选项查看器" style="text-decoration: none !important; cursor: pointer !important;" href="http://app.wumii.com/ext/redirect.htm?url=http%3A%2F%2Fsexywp.com%2Fplugin-options-inspector.htm&from=http%3A%2F%2Fsexywp.com%2Fshare-this-jquery.htm">
                        <img style="margin: 0 !important; padding: 2px !important; border: 1px solid #DDDDDD !important; width: 80px !important; height: 80px !important;" src="http://static.wumii.com/site_images/2011/05/31/10319696.png" width="80px" height="80px" /><br />
                        <font size="-1" color="#333333" style="display: block !important; line-height: 15px !important; width: 86px !important; font: 12px/15px arial !important; height: 45px !important; margin: 3px 0 0 0 !important; padding: 0 !important; overflow: hidden !important;">WordPress插件：选项查看器</font>
                    </a>
                </td>
                <td width="86" valign="top" style="padding: 5px !important; margin: 0 !important; border-left: 1px solid #DDDDDD !important;">
                    <a target="_blank" title="WordPress插件介绍：cformsII 及其汉化包" style="text-decoration: none !important; cursor: pointer !important;" href="http://app.wumii.com/ext/redirect.htm?url=http%3A%2F%2Fsexywp.com%2Fwp-plugins-cformsii-intro.htm&from=http%3A%2F%2Fsexywp.com%2Fshare-this-jquery.htm">
                        <img style="margin: 0 !important; padding: 2px !important; border: 1px solid #DDDDDD !important; width: 80px !important; height: 80px !important;" src="http://static.wumii.com/images/blogWidget/wordpress_default.gif" width="80px" height="80px" /><br />
                        <font size="-1" color="#333333" style="display: block !important; line-height: 15px !important; width: 86px !important; font: 12px/15px arial !important; height: 45px !important; margin: 3px 0 0 0 !important; padding: 0 !important; overflow: hidden !important;">WordPress插件介绍：cformsII 及其汉化包</font>
                    </a>
                </td>
                <td width="86" valign="top" style="padding: 5px !important; margin: 0 !important; border-left: 1px solid #DDDDDD !important;">
                    <a target="_blank" title="WordPress Plugin：Flash MP3 Player" style="text-decoration: none !important; cursor: pointer !important;" href="http://app.wumii.com/ext/redirect.htm?url=http%3A%2F%2Fsexywp.com%2Fflash-player-widget.htm&from=http%3A%2F%2Fsexywp.com%2Fshare-this-jquery.htm">
                        <img style="margin: 0 !important; padding: 2px !important; border: 1px solid #DDDDDD !important; width: 80px !important; height: 80px !important;" src="http://static.wumii.com/images/blogWidget/wordpress_default.gif" width="80px" height="80px" /><br />
                        <font size="-1" color="#333333" style="display: block !important; line-height: 15px !important; width: 86px !important; font: 12px/15px arial !important; height: 45px !important; margin: 3px 0 0 0 !important; padding: 0 !important; overflow: hidden !important;">WordPress Plugin：Flash MP3 Player</font>
                    </a>
                </td>
                <td width="86" valign="top" style="padding: 5px !important; margin: 0 !important; border-left: 1px solid #DDDDDD !important;">
                    <a target="_blank" title="WordPress主题：GoogleCode" style="text-decoration: none !important; cursor: pointer !important;" href="http://app.wumii.com/ext/redirect.htm?url=http%3A%2F%2Fsexywp.com%2Fwordpress-theme-googlecode.htm&from=http%3A%2F%2Fsexywp.com%2Fshare-this-jquery.htm">
                        <img style="margin: 0 !important; padding: 2px !important; border: 1px solid #DDDDDD !important; width: 80px !important; height: 80px !important;" src="http://static.wumii.com/site_images/2011/05/22/9170670.png" width="80px" height="80px" /><br />
                        <font size="-1" color="#333333" style="display: block !important; line-height: 15px !important; width: 86px !important; font: 12px/15px arial !important; height: 45px !important; margin: 3px 0 0 0 !important; padding: 0 !important; overflow: hidden !important;">WordPress主题：GoogleCode</font>
                    </a>
                </td>
                <td width="86" valign="top" style="padding: 5px !important; margin: 0 !important; border-left: 1px solid #DDDDDD !important;">
                    <a target="_blank" title="WordPress:插件开发API（Plugin API）" style="text-decoration: none !important; cursor: pointer !important;" href="http://app.wumii.com/ext/redirect.htm?url=http%3A%2F%2Fsexywp.com%2Fwordpress-plugin-api.htm&from=http%3A%2F%2Fsexywp.com%2Fshare-this-jquery.htm">
                        <img style="margin: 0 !important; padding: 2px !important; border: 1px solid #DDDDDD !important; width: 80px !important; height: 80px !important;" src="http://static.wumii.com/images/blogWidget/wordpress_default.gif" width="80px" height="80px" /><br />
                        <font size="-1" color="#333333" style="display: block !important; line-height: 15px !important; width: 86px !important; font: 12px/15px arial !important; height: 45px !important; margin: 3px 0 0 0 !important; padding: 0 !important; overflow: hidden !important;">WordPress:插件开发API（Plugin API）</font>
                    </a>
                </td>
        </tr>
    
    <tr>
        <td colspan="5" align="right">
            <a style="text-decoration: none !important;" href="http://www.wumii.com/widget/relatedItems.htm" 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>
	标签：<a href="http://sexywp.com/tags/jquery" title="jQuery" rel="tag">jQuery</a>, <a href="http://sexywp.com/tags/my-works" title="my works" rel="tag">my works</a>, <a href="http://sexywp.com/tags/plugins" title="plugins" rel="tag">plugins</a>, <a href="http://sexywp.com/tags/wordpress" title="WordPress" rel="tag">WordPress</a><br />
]]></content:encoded>
			<wfw:commentRss>http://sexywp.com/share-this-jquery.htm/feed</wfw:commentRss>
		<slash:comments>49</slash:comments>
		</item>
		<item>
		<title>怎样增加AJAX的可靠性呢？</title>
		<link>http://sexywp.com/how-to-use-ajax-correctly.htm</link>
		<comments>http://sexywp.com/how-to-use-ajax-correctly.htm#comments</comments>
		<pubDate>Sat, 14 Jun 2008 08:19:20 +0000</pubDate>
		<dc:creator>Charles</dc:creator>
				<category><![CDATA[日　　记]]></category>
		<category><![CDATA[ajax]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[jQuery]]></category>

		<guid isPermaLink="false">http://www.charlestang.cn/?p=93</guid>
		<description><![CDATA[本篇文章不是我的经验介绍，而是我的疑问。我写在这里，希望高手看到了能指点一二，而同样迷惑的人看到了，能参与讨论。

我没有系统地学过javascript，也没有系统地学习过ajax，我只是在兴趣的驱使下，在学习一些jQuery的使用。所以，我几乎对任何问题都很迷惑，而在这些问题中，我最迷惑的就是ajax的可靠性问题。



<span class="readmore"><a href="http://sexywp.com/how-to-use-ajax-correctly.htm" title="怎样增加AJAX的可靠性呢？">Keep Reading --- 784 words totally</a></span><table class="wumii-related-items" cellspacing="0" cellpadding="2" border="0" width="100%" style="clear: both;">
    
    <tr>
        <td ><b><font size="-1"  style="display: block !important; padding: 20px 0 5px !important;">您可能也喜欢：</font></b></td>
    </tr>
    
            <tr>
                <td style="margin: 0 !important; padding: 0 !important; line-height: 20px !important;">
                    <img border="0" src="http://static.wumii.com/images/widget/widget_solidPoint.gif">
                    <a target="_blank" style="text-decoration: none !important;" href="http://app.wumii.com/ext/redirect.htm?url=http%3A%2F%2Fsexywp.com%2Fuse-firephp-in-ajax-development.htm&from=http%3A%2F%2Fsexywp.com%2Fhow-to-use-ajax-correctly.htm">
                        <font size="-1" color="#333333" style="line-height: 1.65em; font-size: 12px !important;">使用FirePHP辅助AJAX应用开发</font>
                    </a>
                </td>
            </tr>
            <tr>
                <td style="margin: 0 !important; padding: 0 !important; line-height: 20px !important;">
                    <img border="0" src="http://static.wumii.com/images/widget/widget_solidPoint.gif">
                    <a target="_blank" style="text-decoration: none !important;" href="http://app.wumii.com/ext/redirect.htm?url=http%3A%2F%2Fsexywp.com%2Fnon-intrusive-and-useability.htm&from=http%3A%2F%2Fsexywp.com%2Fhow-to-use-ajax-correctly.htm">
                        <font size="-1" color="#333333" style="line-height: 1.65em; font-size: 12px !important;">无侵入与可用性层</font>
                    </a>
                </td>
            </tr>
            <tr>
                <td style="margin: 0 !important; padding: 0 !important; line-height: 20px !important;">
                    <img border="0" src="http://static.wumii.com/images/widget/widget_solidPoint.gif">
                    <a target="_blank" style="text-decoration: none !important;" href="http://app.wumii.com/ext/redirect.htm?url=http%3A%2F%2Fsexywp.com%2Fjquery-wrappers.htm&from=http%3A%2F%2Fsexywp.com%2Fhow-to-use-ajax-correctly.htm">
                        <font size="-1" color="#333333" style="line-height: 1.65em; font-size: 12px !important;">jQuery里面用到“打包盒”</font>
                    </a>
                </td>
            </tr>
            <tr>
                <td style="margin: 0 !important; padding: 0 !important; line-height: 20px !important;">
                    <img border="0" src="http://static.wumii.com/images/widget/widget_solidPoint.gif">
                    <a target="_blank" style="text-decoration: none !important;" href="http://app.wumii.com/ext/redirect.htm?url=http%3A%2F%2Fsexywp.com%2Fprogress-enhancement-of-comment-form.htm&from=http%3A%2F%2Fsexywp.com%2Fhow-to-use-ajax-correctly.htm">
                        <font size="-1" color="#333333" style="line-height: 1.65em; font-size: 12px !important;">也说用jQuery改进WP评论表单</font>
                    </a>
                </td>
            </tr>
            <tr>
                <td style="margin: 0 !important; padding: 0 !important; line-height: 20px !important;">
                    <img border="0" src="http://static.wumii.com/images/widget/widget_solidPoint.gif">
                    <a target="_blank" style="text-decoration: none !important;" href="http://app.wumii.com/ext/redirect.htm?url=http%3A%2F%2Fsexywp.com%2Fshare-this-jquery.htm&from=http%3A%2F%2Fsexywp.com%2Fhow-to-use-ajax-correctly.htm">
                        <font size="-1" color="#333333" style="line-height: 1.65em; font-size: 12px !important;">WordPress插件修改：Share This (jQuery)</font>
                    </a>
                </td>
            </tr>
    
    <tr>
        <td  align="right">
            <a style="text-decoration: none !important;" href="http://www.wumii.com/widget/relatedItems.htm" 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>本篇文章不是我的经验介绍，而是我的疑问。我写在这里，希望高手看到了能指点一二，而同样迷惑的人看到了，能参与讨论。</p>
<p>我没有系统地学过javascript，也没有系统地学习过ajax，我只是在兴趣的驱使下，在学习一些jQuery的使用。所以，我几乎对任何问题都很迷惑，而在这些问题中，我最迷惑的就是ajax的可靠性问题。<br />
<span id="more-93"></span></p>
<p>我说的可靠性问题不是指安全问题，而是说，怎么确保一个页面以设计师希望的那种模样出现在用户的面前。就比如我的页面上使用了Ajax加载了部分内容，但是，是否每个人都能正确地看到我的完整页面呢？这个问题，我是回答不了的。其实，我自己使用IE7浏览器，就总是不能看到我自己的页面正确地全部加载。那么，在真正的商用应用中，这种可靠性是怎么被保证的呢？或者说极大程度的保证。</p>
<p>重试机制，如果ajax加载的内容失效，那么应该捕获这个错误，然后进行重试。我在网上看到过关于这个的介绍。但是，我的疑问是，重试多少次呢？5次？10次？不停地重试？要知道，一次ajax加载失败的原因是多种多样的，有可能是刚巧这个时候网络不畅，有可能这个地方的网络总是不畅，比如我自己所在的地方，还有可能是碰巧超时……有些情况，重试个一两次就能解决，但是也不知道到底是几次，还有些地方是根本解决不了的。怎样区分对待这些情况，给用户最好的体验呢？</p>
<p>如果禁止javascript，又怎样保证用户的体验不会太差呢？这又是一个难题，对待这个问题，我目前的看法是，这个问题最后再去考虑，其实大多数用户都是启用了javascript的，虽说现在很多网页的流氓软件都是在看网页的时候用js干坏事的，但是javascript只是被坏人利用了，没必要一棍子打死，我想大多数用户也应该不愿意看到一个因为缺少了js而变得枯燥乏味的互联网。所幸的是，很多杀毒软件，防流氓软件的出现，都有了区别对待的机制，一般都允许打开js，而在危险的时候预警。不过，这个社会总是少不了“别里科夫”的，对于技术和时间都实在有限的我，只有最后再去关心他们的感受啦……</p>
<table class="wumii-related-items" cellspacing="0" cellpadding="2" border="0" width="100%" style="clear: both;">
    
    <tr>
        <td ><b><font size="-1"  style="display: block !important; padding: 20px 0 5px !important;">您可能也喜欢：</font></b></td>
    </tr>
    
            <tr>
                <td style="margin: 0 !important; padding: 0 !important; line-height: 20px !important;">
                    <img border="0" src="http://static.wumii.com/images/widget/widget_solidPoint.gif">
                    <a target="_blank" style="text-decoration: none !important;" href="http://app.wumii.com/ext/redirect.htm?url=http%3A%2F%2Fsexywp.com%2Fuse-firephp-in-ajax-development.htm&from=http%3A%2F%2Fsexywp.com%2Fhow-to-use-ajax-correctly.htm">
                        <font size="-1" color="#333333" style="line-height: 1.65em; font-size: 12px !important;">使用FirePHP辅助AJAX应用开发</font>
                    </a>
                </td>
            </tr>
            <tr>
                <td style="margin: 0 !important; padding: 0 !important; line-height: 20px !important;">
                    <img border="0" src="http://static.wumii.com/images/widget/widget_solidPoint.gif">
                    <a target="_blank" style="text-decoration: none !important;" href="http://app.wumii.com/ext/redirect.htm?url=http%3A%2F%2Fsexywp.com%2Fnon-intrusive-and-useability.htm&from=http%3A%2F%2Fsexywp.com%2Fhow-to-use-ajax-correctly.htm">
                        <font size="-1" color="#333333" style="line-height: 1.65em; font-size: 12px !important;">无侵入与可用性层</font>
                    </a>
                </td>
            </tr>
            <tr>
                <td style="margin: 0 !important; padding: 0 !important; line-height: 20px !important;">
                    <img border="0" src="http://static.wumii.com/images/widget/widget_solidPoint.gif">
                    <a target="_blank" style="text-decoration: none !important;" href="http://app.wumii.com/ext/redirect.htm?url=http%3A%2F%2Fsexywp.com%2Fjquery-wrappers.htm&from=http%3A%2F%2Fsexywp.com%2Fhow-to-use-ajax-correctly.htm">
                        <font size="-1" color="#333333" style="line-height: 1.65em; font-size: 12px !important;">jQuery里面用到“打包盒”</font>
                    </a>
                </td>
            </tr>
            <tr>
                <td style="margin: 0 !important; padding: 0 !important; line-height: 20px !important;">
                    <img border="0" src="http://static.wumii.com/images/widget/widget_solidPoint.gif">
                    <a target="_blank" style="text-decoration: none !important;" href="http://app.wumii.com/ext/redirect.htm?url=http%3A%2F%2Fsexywp.com%2Fprogress-enhancement-of-comment-form.htm&from=http%3A%2F%2Fsexywp.com%2Fhow-to-use-ajax-correctly.htm">
                        <font size="-1" color="#333333" style="line-height: 1.65em; font-size: 12px !important;">也说用jQuery改进WP评论表单</font>
                    </a>
                </td>
            </tr>
            <tr>
                <td style="margin: 0 !important; padding: 0 !important; line-height: 20px !important;">
                    <img border="0" src="http://static.wumii.com/images/widget/widget_solidPoint.gif">
                    <a target="_blank" style="text-decoration: none !important;" href="http://app.wumii.com/ext/redirect.htm?url=http%3A%2F%2Fsexywp.com%2Fshare-this-jquery.htm&from=http%3A%2F%2Fsexywp.com%2Fhow-to-use-ajax-correctly.htm">
                        <font size="-1" color="#333333" style="line-height: 1.65em; font-size: 12px !important;">WordPress插件修改：Share This (jQuery)</font>
                    </a>
                </td>
            </tr>
    
    <tr>
        <td  align="right">
            <a style="text-decoration: none !important;" href="http://www.wumii.com/widget/relatedItems.htm" 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>
	标签：<a href="http://sexywp.com/tags/ajax" title="ajax" rel="tag">ajax</a>, <a href="http://sexywp.com/tags/javascript" title="javascript" rel="tag">javascript</a>, <a href="http://sexywp.com/tags/jquery" title="jQuery" rel="tag">jQuery</a><br />
]]></content:encoded>
			<wfw:commentRss>http://sexywp.com/how-to-use-ajax-correctly.htm/feed</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
		<item>
		<title>IE7不支持focus伪类的解决办法</title>
		<link>http://sexywp.com/ie7-donnot-support-focus.htm</link>
		<comments>http://sexywp.com/ie7-donnot-support-focus.htm#comments</comments>
		<pubDate>Mon, 21 Apr 2008 07:51:24 +0000</pubDate>
		<dc:creator>Charles</dc:creator>
				<category><![CDATA[工作相关]]></category>
		<category><![CDATA[CSS]]></category>
		<category><![CDATA[DIY]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[jQuery]]></category>

		<guid isPermaLink="false">http://www.charlestang.cn/?p=59</guid>
		<description><![CDATA[我目前使用的主题是我自己从5U移植到K2的一个Style，黑色背景。在ffx下面工作正常，但是到了IE7里面，帖子页的留言输入框的背景色就不会因为获得焦点而改变。因此，造成了在IE7下发表留言时，输入框颜色和文字颜色对比度过低而看不清楚。

看了一下CSS文件，发现使用focus伪类来实现当获得焦点时改变背景色的功能，但是，在IE7下面，没有任何效果。网上搜索了一些办法，我觉得可行，正好K2里面也包含了jQuery，可以好好利用一下。

最后，我使用了：

<span class="readmore"><a href="http://sexywp.com/ie7-donnot-support-focus.htm" title="IE7不支持focus伪类的解决办法">Keep Reading --- 266 words totally</a></span><table class="wumii-related-items" cellspacing="0" cellpadding="2" border="0" width="100%" style="clear: both;">
    
    <tr>
        <td ><b><font size="-1"  style="display: block !important; padding: 20px 0 5px !important;">您可能也喜欢：</font></b></td>
    </tr>
    
            <tr>
                <td style="margin: 0 !important; padding: 0 !important; line-height: 20px !important;">
                    <img border="0" src="http://static.wumii.com/images/widget/widget_solidPoint.gif">
                    <a target="_blank" style="text-decoration: none !important;" href="http://app.wumii.com/ext/redirect.htm?url=http%3A%2F%2Fsexywp.com%2Fprogress-enhancement-of-comment-form.htm&from=http%3A%2F%2Fsexywp.com%2Fie7-donnot-support-focus.htm">
                        <font size="-1" color="#333333" style="line-height: 1.65em; font-size: 12px !important;">也说用jQuery改进WP评论表单</font>
                    </a>
                </td>
            </tr>
            <tr>
                <td style="margin: 0 !important; padding: 0 !important; line-height: 20px !important;">
                    <img border="0" src="http://static.wumii.com/images/widget/widget_solidPoint.gif">
                    <a target="_blank" style="text-decoration: none !important;" href="http://app.wumii.com/ext/redirect.htm?url=http%3A%2F%2Fsexywp.com%2Fnon-intrusive-and-useability.htm&from=http%3A%2F%2Fsexywp.com%2Fie7-donnot-support-focus.htm">
                        <font size="-1" color="#333333" style="line-height: 1.65em; font-size: 12px !important;">无侵入与可用性层</font>
                    </a>
                </td>
            </tr>
            <tr>
                <td style="margin: 0 !important; padding: 0 !important; line-height: 20px !important;">
                    <img border="0" src="http://static.wumii.com/images/widget/widget_solidPoint.gif">
                    <a target="_blank" style="text-decoration: none !important;" href="http://app.wumii.com/ext/redirect.htm?url=http%3A%2F%2Fsexywp.com%2Fjquery-wrappers.htm&from=http%3A%2F%2Fsexywp.com%2Fie7-donnot-support-focus.htm">
                        <font size="-1" color="#333333" style="line-height: 1.65em; font-size: 12px !important;">jQuery里面用到“打包盒”</font>
                    </a>
                </td>
            </tr>
            <tr>
                <td style="margin: 0 !important; padding: 0 !important; line-height: 20px !important;">
                    <img border="0" src="http://static.wumii.com/images/widget/widget_solidPoint.gif">
                    <a target="_blank" style="text-decoration: none !important;" href="http://app.wumii.com/ext/redirect.htm?url=http%3A%2F%2Fsexywp.com%2Fshare-this-jquery.htm&from=http%3A%2F%2Fsexywp.com%2Fie7-donnot-support-focus.htm">
                        <font size="-1" color="#333333" style="line-height: 1.65em; font-size: 12px !important;">WordPress插件修改：Share This (jQuery)</font>
                    </a>
                </td>
            </tr>
            <tr>
                <td style="margin: 0 !important; padding: 0 !important; line-height: 20px !important;">
                    <img border="0" src="http://static.wumii.com/images/widget/widget_solidPoint.gif">
                    <a target="_blank" style="text-decoration: none !important;" href="http://app.wumii.com/ext/redirect.htm?url=http%3A%2F%2Fsexywp.com%2F%25E6%2580%258E%25E4%25B9%2588%25E8%25A7%2589%25E5%25BE%2597python%25E8%25BF%2599%25E4%25B9%2588%25E6%25B7%25B7%25E4%25B9%25B1%25E5%2591%25A2.htm&from=http%3A%2F%2Fsexywp.com%2Fie7-donnot-support-focus.htm">
                        <font size="-1" color="#333333" style="line-height: 1.65em; font-size: 12px !important;">怎么觉得Python这么混乱呢</font>
                    </a>
                </td>
            </tr>
    
    <tr>
        <td  align="right">
            <a style="text-decoration: none !important;" href="http://www.wumii.com/widget/relatedItems.htm" 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>我目前使用的主题是我自己从5U移植到K2的一个Style，黑色背景。在ffx下面工作正常，但是到了IE7里面，帖子页的留言输入框的背景色就不会因为获得焦点而改变。因此，造成了在IE7下发表留言时，输入框颜色和文字颜色对比度过低而看不清楚。</p>
<p>看了一下CSS文件，发现使用focus伪类来实现当获得焦点时改变背景色的功能，但是，在IE7下面，没有任何效果。网上搜索了一些办法，我觉得可行，正好K2里面也包含了jQuery，可以好好利用一下。</p>
<p>最后，我使用了：</p>
<p> <a href="http://sexywp.com/tags/jquery" class="st_tag internal_tag" rel="tag" title="标签 jQuery 下的日志">jQuery</a>("textarea").focus(function(){<br />
jQuery("textarea").<a href="http://sexywp.com/tags/css" class="st_tag internal_tag" rel="tag" title="标签 CSS 下的日志">css</a>("background","white");<br />
});<br />
jQuery("textarea").blur(function(){<br />
jQuery("textarea").css("background","#666");<br />
});</p>
<p>这样四行代码，实现了当获得焦点时候改变背景色的功能。不禁感慨jQuery的强大，以后还要多学学，关键时刻可以拿来救急，呵呵。</p>
<table class="wumii-related-items" cellspacing="0" cellpadding="2" border="0" width="100%" style="clear: both;">
    
    <tr>
        <td ><b><font size="-1"  style="display: block !important; padding: 20px 0 5px !important;">您可能也喜欢：</font></b></td>
    </tr>
    
            <tr>
                <td style="margin: 0 !important; padding: 0 !important; line-height: 20px !important;">
                    <img border="0" src="http://static.wumii.com/images/widget/widget_solidPoint.gif">
                    <a target="_blank" style="text-decoration: none !important;" href="http://app.wumii.com/ext/redirect.htm?url=http%3A%2F%2Fsexywp.com%2Fprogress-enhancement-of-comment-form.htm&from=http%3A%2F%2Fsexywp.com%2Fie7-donnot-support-focus.htm">
                        <font size="-1" color="#333333" style="line-height: 1.65em; font-size: 12px !important;">也说用jQuery改进WP评论表单</font>
                    </a>
                </td>
            </tr>
            <tr>
                <td style="margin: 0 !important; padding: 0 !important; line-height: 20px !important;">
                    <img border="0" src="http://static.wumii.com/images/widget/widget_solidPoint.gif">
                    <a target="_blank" style="text-decoration: none !important;" href="http://app.wumii.com/ext/redirect.htm?url=http%3A%2F%2Fsexywp.com%2Fnon-intrusive-and-useability.htm&from=http%3A%2F%2Fsexywp.com%2Fie7-donnot-support-focus.htm">
                        <font size="-1" color="#333333" style="line-height: 1.65em; font-size: 12px !important;">无侵入与可用性层</font>
                    </a>
                </td>
            </tr>
            <tr>
                <td style="margin: 0 !important; padding: 0 !important; line-height: 20px !important;">
                    <img border="0" src="http://static.wumii.com/images/widget/widget_solidPoint.gif">
                    <a target="_blank" style="text-decoration: none !important;" href="http://app.wumii.com/ext/redirect.htm?url=http%3A%2F%2Fsexywp.com%2Fjquery-wrappers.htm&from=http%3A%2F%2Fsexywp.com%2Fie7-donnot-support-focus.htm">
                        <font size="-1" color="#333333" style="line-height: 1.65em; font-size: 12px !important;">jQuery里面用到“打包盒”</font>
                    </a>
                </td>
            </tr>
            <tr>
                <td style="margin: 0 !important; padding: 0 !important; line-height: 20px !important;">
                    <img border="0" src="http://static.wumii.com/images/widget/widget_solidPoint.gif">
                    <a target="_blank" style="text-decoration: none !important;" href="http://app.wumii.com/ext/redirect.htm?url=http%3A%2F%2Fsexywp.com%2Fshare-this-jquery.htm&from=http%3A%2F%2Fsexywp.com%2Fie7-donnot-support-focus.htm">
                        <font size="-1" color="#333333" style="line-height: 1.65em; font-size: 12px !important;">WordPress插件修改：Share This (jQuery)</font>
                    </a>
                </td>
            </tr>
            <tr>
                <td style="margin: 0 !important; padding: 0 !important; line-height: 20px !important;">
                    <img border="0" src="http://static.wumii.com/images/widget/widget_solidPoint.gif">
                    <a target="_blank" style="text-decoration: none !important;" href="http://app.wumii.com/ext/redirect.htm?url=http%3A%2F%2Fsexywp.com%2F%25E6%2580%258E%25E4%25B9%2588%25E8%25A7%2589%25E5%25BE%2597python%25E8%25BF%2599%25E4%25B9%2588%25E6%25B7%25B7%25E4%25B9%25B1%25E5%2591%25A2.htm&from=http%3A%2F%2Fsexywp.com%2Fie7-donnot-support-focus.htm">
                        <font size="-1" color="#333333" style="line-height: 1.65em; font-size: 12px !important;">怎么觉得Python这么混乱呢</font>
                    </a>
                </td>
            </tr>
    
    <tr>
        <td  align="right">
            <a style="text-decoration: none !important;" href="http://www.wumii.com/widget/relatedItems.htm" 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>
	标签：<a href="http://sexywp.com/tags/css" title="CSS" rel="tag">CSS</a>, <a href="http://sexywp.com/tags/diy" title="DIY" rel="tag">DIY</a>, <a href="http://sexywp.com/tags/javascript" title="javascript" rel="tag">javascript</a>, <a href="http://sexywp.com/tags/jquery" title="jQuery" rel="tag">jQuery</a><br />
]]></content:encoded>
			<wfw:commentRss>http://sexywp.com/ie7-donnot-support-focus.htm/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>隐藏搜索框旁边的按钮</title>
		<link>http://sexywp.com/hide-the-search-button.htm</link>
		<comments>http://sexywp.com/hide-the-search-button.htm#comments</comments>
		<pubDate>Mon, 10 Mar 2008 02:32:52 +0000</pubDate>
		<dc:creator>Charles</dc:creator>
				<category><![CDATA[WordPress]]></category>
		<category><![CDATA[DIY]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[jQuery]]></category>
		<category><![CDATA[SandBox]]></category>

		<guid isPermaLink="false">http://www.charlestang.cn/hide-the-search-button.htm</guid>
		<description><![CDATA[用惯了K2，很喜欢K2的Live Search，真是相当酷的功能呢，但是以我现在的实例，实在是没有办法模仿出来啊。就算是从K2抄过来，也觉得好难啊，至少不是一朝一夕能办到的。

所以，至少（我总是舍难求易）我要模仿个样子过来，(*^__^*) 嘻嘻……

侧边栏的Search框，是WordPress里面自带的，怎么才能把那个按钮给隐藏掉呢？

<span class="readmore"><a href="http://sexywp.com/hide-the-search-button.htm" title="隐藏搜索框旁边的按钮">Keep Reading --- 456 words totally</a></span><table class="wumii-related-items" cellspacing="0" cellpadding="2" border="0" width="100%" style="clear: both;">
    
    <tr>
        <td ><b><font size="-1"  style="display: block !important; padding: 20px 0 5px !important;">您可能也喜欢：</font></b></td>
    </tr>
    
            <tr>
                <td style="margin: 0 !important; padding: 0 !important; line-height: 20px !important;">
                    <img border="0" src="http://static.wumii.com/images/widget/widget_solidPoint.gif">
                    <a target="_blank" style="text-decoration: none !important;" href="http://app.wumii.com/ext/redirect.htm?url=http%3A%2F%2Fsexywp.com%2Fsomething-about-sandbox.htm&from=http%3A%2F%2Fsexywp.com%2Fhide-the-search-button.htm">
                        <font size="-1" color="#333333" style="line-height: 1.65em; font-size: 12px !important;">SandBox 何去何从？</font>
                    </a>
                </td>
            </tr>
            <tr>
                <td style="margin: 0 !important; padding: 0 !important; line-height: 20px !important;">
                    <img border="0" src="http://static.wumii.com/images/widget/widget_solidPoint.gif">
                    <a target="_blank" style="text-decoration: none !important;" href="http://app.wumii.com/ext/redirect.htm?url=http%3A%2F%2Fsexywp.com%2Fremove-author-from-body-class.htm&from=http%3A%2F%2Fsexywp.com%2Fhide-the-search-button.htm">
                        <font size="-1" color="#333333" style="line-height: 1.65em; font-size: 12px !important;">修正SandBox的Author页面错误</font>
                    </a>
                </td>
            </tr>
            <tr>
                <td style="margin: 0 !important; padding: 0 !important; line-height: 20px !important;">
                    <img border="0" src="http://static.wumii.com/images/widget/widget_solidPoint.gif">
                    <a target="_blank" style="text-decoration: none !important;" href="http://app.wumii.com/ext/redirect.htm?url=http%3A%2F%2Fsexywp.com%2Fadd-home-and-admin-to-navigator.htm&from=http%3A%2F%2Fsexywp.com%2Fhide-the-search-button.htm">
                        <font size="-1" color="#333333" style="line-height: 1.65em; font-size: 12px !important;">在SandBox的导航中添加“首页”和“网站管理”</font>
                    </a>
                </td>
            </tr>
            <tr>
                <td style="margin: 0 !important; padding: 0 !important; line-height: 20px !important;">
                    <img border="0" src="http://static.wumii.com/images/widget/widget_solidPoint.gif">
                    <a target="_blank" style="text-decoration: none !important;" href="http://app.wumii.com/ext/redirect.htm?url=http%3A%2F%2Fsexywp.com%2Fshare-this-jquery.htm&from=http%3A%2F%2Fsexywp.com%2Fhide-the-search-button.htm">
                        <font size="-1" color="#333333" style="line-height: 1.65em; font-size: 12px !important;">WordPress插件修改：Share This (jQuery)</font>
                    </a>
                </td>
            </tr>
            <tr>
                <td style="margin: 0 !important; padding: 0 !important; line-height: 20px !important;">
                    <img border="0" src="http://static.wumii.com/images/widget/widget_solidPoint.gif">
                    <a target="_blank" style="text-decoration: none !important;" href="http://app.wumii.com/ext/redirect.htm?url=http%3A%2F%2Fsexywp.com%2Fprogress-enhancement-of-comment-form.htm&from=http%3A%2F%2Fsexywp.com%2Fhide-the-search-button.htm">
                        <font size="-1" color="#333333" style="line-height: 1.65em; font-size: 12px !important;">也说用jQuery改进WP评论表单</font>
                    </a>
                </td>
            </tr>
    
    <tr>
        <td  align="right">
            <a style="text-decoration: none !important;" href="http://www.wumii.com/widget/relatedItems.htm" 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>用惯了K2，很喜欢K2的Live Search，真是相当酷的功能呢，但是以我现在的实例，实在是没有办法模仿出来啊。就算是从K2抄过来，也觉得好难啊，至少不是一朝一夕能办到的。</p>
<p>所以，至少（我总是舍难求易）我要模仿个样子过来，(*^__^*) 嘻嘻……</p>
<p>侧边栏的Search框，是WordPress里面自带的，怎么才能把那个按钮给隐藏掉呢？</p>
<p>嘿嘿，我去参考了K2的代码。说实在的，一开始，还真的没有找到。后来经过多种手段（我偷师有多种办法，以后慢慢介绍，哈哈）分析，终于发现，原来K2使用的是javascript脚本代码做到的这个事情。</p>
<p>毫不留情地偷过来，啦啦啦~~~</p>
<p>首先，我编辑了一段代码，存成了js文件。如下：</p>
<div class="hl-title">&#19979;&#36733;: <a href="http://sexywp.com/wp-content/plugins/coolcode/coolcode.php?p=12&amp;download=customutils.js">customutils.js</a></div><div class="hl-surround"><div class="hl-main"><ol class="hl-main ln-show" title="Double click to hide line number." ondblclick = "linenumber(this)"><li>&nbsp;<span style="color: Blue;">jQuery</span><span style="color: Olive;">(</span><span style="color: Teal;">document</span><span style="color: Olive;">)</span><span style="color: Gray;">.</span><span style="color: Blue;">ready</span><span style="color: Olive;">(</span><span style="color: Green;">function</span><span style="color: Olive;">(</span><span style="color: Olive;">)</span><span style="color: Olive;">{</span></li>
<li><span style="color: Gray;">&nbsp;&nbsp; &nbsp; </span><span style="color: #ffa500;">//</span><span style="color: #ffa500;">提示文字</span></li>
<li><span style="color: Gray;">&nbsp;&nbsp; &nbsp; </span><span style="color: Green;">var</span><span style="color: Gray;">&nbsp;</span><span style="color: Blue;">searchPrompt</span><span style="color: Gray;"> = </span><span style="color: #8b0000;">&quot;</span><span style="color: Red;">Search...</span><span style="color: #8b0000;">&quot;</span><span style="color: Gray;">;</span></li>
<li><span style="color: Gray;">&nbsp;&nbsp; &nbsp; </span><span style="color: #ffa500;">//</span><span style="color: #ffa500;">搜索按钮</span></li>
<li><span style="color: Gray;">&nbsp;&nbsp; &nbsp; </span><span style="color: Green;">var</span><span style="color: Gray;">&nbsp;</span><span style="color: Blue;">submitButton</span><span style="color: Gray;"> = </span><span style="color: Blue;">jQuery</span><span style="color: Olive;">(</span><span style="color: #8b0000;">'</span><span style="color: Red;">#searchform input[@type=submit]</span><span style="color: #8b0000;">'</span><span style="color: Olive;">)</span><span style="color: Gray;">;</span></li>
<li><span style="color: Gray;">&nbsp;&nbsp; &nbsp; </span><span style="color: #ffa500;">//</span><span style="color: #ffa500;">搜索输入框</span></li>
<li><span style="color: Gray;">&nbsp;&nbsp; &nbsp; </span><span style="color: Green;">var</span><span style="color: Gray;">&nbsp;</span><span style="color: Blue;">inputAera</span><span style="color: Gray;"> = </span><span style="color: Blue;">jQuery</span><span style="color: Olive;">(</span><span style="color: #8b0000;">'</span><span style="color: Red;">input#s</span><span style="color: #8b0000;">'</span><span style="color: Olive;">)</span><span style="color: Gray;">;</span></li>
<li><span style="color: Gray;">&nbsp; </span></li>
<li><span style="color: Gray;">&nbsp;&nbsp; &nbsp; </span><span style="color: #ffa500;">//</span><span style="color: #ffa500;">隐藏搜索按钮</span></li>
<li><span style="color: Gray;">&nbsp;&nbsp; &nbsp; </span><span style="color: Blue;">submitButton</span><span style="color: Gray;">.</span><span style="color: Blue;">hide</span><span style="color: Olive;">(</span><span style="color: Olive;">)</span><span style="color: Gray;">;</span></li>
<li><span style="color: Gray;">&nbsp;&nbsp; &nbsp; </span><span style="color: #ffa500;">//</span><span style="color: #ffa500;">设定搜索框内提示文字</span></li>
<li><span style="color: Gray;">&nbsp;&nbsp; &nbsp; </span><span style="color: Blue;">inputAera</span><span style="color: Gray;">.</span><span style="color: Blue;">val</span><span style="color: Olive;">(</span><span style="color: Blue;">searchPrompt</span><span style="color: Olive;">)</span><span style="color: Gray;">;</span></li>
<li><span style="color: Gray;">&nbsp; </span></li>
<li><span style="color: Gray;">&nbsp;&nbsp; &nbsp; </span><span style="color: #ffa500;">//</span><span style="color: #ffa500;">设定搜索框的行为</span></li>
<li><span style="color: Gray;">&nbsp;&nbsp; &nbsp; </span><span style="color: Blue;">inputAera</span><span style="color: Gray;">.</span><span style="color: Blue;">focus</span><span style="color: Olive;">(</span><span style="color: Green;">function</span><span style="color: Olive;">(</span><span style="color: Olive;">)</span><span style="color: Gray;">&nbsp;</span><span style="color: Olive;">{</span></li>
<li><span style="color: Gray;">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; </span><span style="color: Green;">if</span><span style="color: Gray;">&nbsp;</span><span style="color: Olive;">(</span><span style="color: Blue;">inputAera</span><span style="color: Gray;">.</span><span style="color: Blue;">val</span><span style="color: Olive;">(</span><span style="color: Olive;">)</span><span style="color: Gray;"> == </span><span style="color: Blue;">searchPrompt</span><span style="color: Olive;">)</span><span style="color: Gray;"> </span><span style="color: Olive;">{</span></li>
<li><span style="color: Gray;">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span style="color: Blue;">inputAera</span><span style="color: Gray;">.</span><span style="color: Blue;">val</span><span style="color: Olive;">(</span><span style="color: #8b0000;">'</span><span style="color: #8b0000;">'</span><span style="color: Olive;">)</span><span style="color: Gray;">;</span></li>
<li><span style="color: Gray;">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; </span><span style="color: Olive;">}</span></li>
<li><span style="color: Gray;">&nbsp;&nbsp; &nbsp; </span><span style="color: Olive;">}</span><span style="color: Olive;">)</span></li>
<li><span style="color: Gray;">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; .</span><span style="color: Blue;">blur</span><span style="color: Olive;">(</span><span style="color: Green;">function</span><span style="color: Olive;">(</span><span style="color: Olive;">)</span><span style="color: Gray;">&nbsp;</span><span style="color: Olive;">{</span></li>
<li><span style="color: Gray;">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; </span><span style="color: Green;">if</span><span style="color: Gray;">&nbsp;</span><span style="color: Olive;">(</span><span style="color: Blue;">inputAera</span><span style="color: Gray;">.</span><span style="color: Blue;">val</span><span style="color: Olive;">(</span><span style="color: Olive;">)</span><span style="color: Gray;"> == </span><span style="color: #8b0000;">'</span><span style="color: #8b0000;">'</span><span style="color: Olive;">)</span><span style="color: Gray;"> </span><span style="color: Olive;">{</span></li>
<li><span style="color: Gray;">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span style="color: Blue;">inputAera</span><span style="color: Gray;">.</span><span style="color: Blue;">val</span><span style="color: Olive;">(</span><span style="color: Blue;">searchPrompt</span><span style="color: Olive;">)</span><span style="color: Gray;">;</span></li>
<li><span style="color: Gray;">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; </span><span style="color: Olive;">}</span></li>
<li><span style="color: Gray;">&nbsp;&nbsp; &nbsp; </span><span style="color: Olive;">}</span><span style="color: Olive;">)</span></li>
<li><span style="color: Gray;">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; .</span><span style="color: Blue;">keyup</span><span style="color: Olive;">(</span><span style="color: Green;">function</span><span style="color: Olive;">(</span><span style="color: Blue;">event</span><span style="color: Olive;">)</span><span style="color: Gray;">&nbsp;</span><span style="color: Olive;">{</span></li>
<li><span style="color: Gray;">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span style="color: Green;">var</span><span style="color: Gray;">&nbsp;</span><span style="color: Blue;">code</span><span style="color: Gray;"> = </span><span style="color: Blue;">event</span><span style="color: Gray;">.</span><span style="color: Blue;">keyCode</span><span style="color: Gray;">;</span></li>
<li><span style="color: Gray;">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span style="color: Green;">if</span><span style="color: Gray;">&nbsp;</span><span style="color: Olive;">(</span><span style="color: Blue;">inputAera</span><span style="color: Gray;">.</span><span style="color: Blue;">val</span><span style="color: Olive;">(</span><span style="color: Olive;">)</span><span style="color: Gray;"> == </span><span style="color: #8b0000;">'</span><span style="color: #8b0000;">'</span><span style="color: Olive;">)</span><span style="color: Gray;"> </span><span style="color: Olive;">{</span></li>
<li><span style="color: Gray;">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span style="color: Green;">return</span><span style="color: Gray;">&nbsp;</span><span style="color: Green;">false</span><span style="color: Gray;">;</span></li>
<li><span style="color: Gray;">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span style="color: Olive;">}</span><span style="color: Gray;">&nbsp;</span><span style="color: Green;">else</span><span style="color: Gray;"> </span><span style="color: Green;">if</span><span style="color: Gray;"> </span><span style="color: Olive;">(</span><span style="color: Blue;">code</span><span style="color: Gray;"> == </span><span style="color: Maroon;">27</span><span style="color: Olive;">)</span><span style="color: Gray;"> </span><span style="color: Olive;">{</span></li>
<li><span style="color: Gray;">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span style="color: Blue;">inputAera</span><span style="color: Gray;">.</span><span style="color: Blue;">val</span><span style="color: Olive;">(</span><span style="color: #8b0000;">'</span><span style="color: #8b0000;">'</span><span style="color: Olive;">)</span><span style="color: Gray;">;</span></li>
<li><span style="color: Gray;">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span style="color: Olive;">}</span><span style="color: Gray;">&nbsp;</span><span style="color: Green;">else</span><span style="color: Gray;"> </span><span style="color: Green;">if</span><span style="color: Gray;"> </span><span style="color: Olive;">(</span><span style="color: Blue;">code</span><span style="color: Gray;"> != </span><span style="color: Maroon;">13</span><span style="color: Olive;">)</span><span style="color: Gray;"> </span><span style="color: Olive;">{</span></li>
<li><span style="color: Gray;">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span style="color: #ffa500;">//</span><span style="color: #ffa500;">原来是Live Search，也就是每键入一个</span></li>
<li><span style="color: Gray;">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span style="color: #ffa500;">//</span><span style="color: #ffa500;">字符，只要间歇超过2秒，就会启动搜索了</span></li>
<li><span style="color: Gray;">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; </span><span style="color: Olive;">}</span></li>
<li><span style="color: Gray;">&nbsp;&nbsp; &nbsp; </span><span style="color: Olive;">}</span><span style="color: Olive;">)</span><span style="color: Gray;">;</span></li>
<li><span style="color: Gray;">&nbsp;</span><span style="color: Olive;">}</span><span style="color: Olive;">)</span><span style="color: Gray;">;</span></li></ol></div></div>
<p>有了这段代码，就可以使有“搜索”两个字的按钮给隐藏掉了。<br />
然后要做的就是把这段代码插入到模板主题中。<br />
打开index.php，找到：</p>
<div class="hl-surround"><div class="hl-main"><span style="color: Olive;">&lt;/</span><span style="color: Green;">head</span><span style="color: Olive;">&gt;</span></div></div>
<p>在前面加上：</p>
<div class="hl-surround"><div class="hl-main"><span style="color: Olive;">&lt;</span><span style="color: Green;">script</span><span style="color: Gray;"> </span><span style="color: #00008b;">type</span><span style="color: Gray;">=</span><span style="color: #8b0000;">&quot;</span><span style="color: Red;">text/javascript</span><span style="color: #8b0000;">&quot;</span><span style="color: Gray;"> </span><span style="color: #00008b;">src</span><span style="color: Gray;">=</span><span style="color: #8b0000;">&quot;</span><span style="color: Red;">&lt;?php bloginfo('template_url');?&gt;/customutils.js</span><span style="color: #8b0000;">&quot;</span><span style="color: Olive;">&gt;</span><span style="color: Olive;">&lt;/</span><span style="color: Green;">script</span><span style="color: Olive;">&gt;</span></div></div>
<p>好了，现在试试看吧，什么不行？使用多种手段（靠！又是这个……）发现，原来没有jQuery对象。只好又去下载了压缩版的jQuery.js（这是什么东东？我以后的文章会说的啦~），然后再加上一句：</p>
<div class="hl-surround"><div class="hl-main"><span style="color: Olive;">&lt;</span><span style="color: Green;">script</span><span style="color: Gray;"> </span><span style="color: #00008b;">type</span><span style="color: Gray;">=</span><span style="color: #8b0000;">&quot;</span><span style="color: Red;">text/javascript</span><span style="color: #8b0000;">&quot;</span><span style="color: Gray;"> </span><span style="color: #00008b;">src</span><span style="color: Gray;">=</span><span style="color: #8b0000;">&quot;</span><span style="color: Red;">&lt;?php bloginfo('template_url');?&gt;/jquery.js</span><span style="color: #8b0000;">&quot;</span><span style="color: Olive;">&gt;</span><span style="color: Olive;">&lt;/</span><span style="color: Green;">script</span><span style="color: Olive;">&gt;</span></div></div>
<p>好了，这下大功告成了。<br />
（我是基于SandBox1.3改的，实际上，要根据自己模板的不同，来决定是否加入jQuery，有的模板可能本来就有了。）</p>
<table class="wumii-related-items" cellspacing="0" cellpadding="2" border="0" width="100%" style="clear: both;">
    
    <tr>
        <td ><b><font size="-1"  style="display: block !important; padding: 20px 0 5px !important;">您可能也喜欢：</font></b></td>
    </tr>
    
            <tr>
                <td style="margin: 0 !important; padding: 0 !important; line-height: 20px !important;">
                    <img border="0" src="http://static.wumii.com/images/widget/widget_solidPoint.gif">
                    <a target="_blank" style="text-decoration: none !important;" href="http://app.wumii.com/ext/redirect.htm?url=http%3A%2F%2Fsexywp.com%2Fsomething-about-sandbox.htm&from=http%3A%2F%2Fsexywp.com%2Fhide-the-search-button.htm">
                        <font size="-1" color="#333333" style="line-height: 1.65em; font-size: 12px !important;">SandBox 何去何从？</font>
                    </a>
                </td>
            </tr>
            <tr>
                <td style="margin: 0 !important; padding: 0 !important; line-height: 20px !important;">
                    <img border="0" src="http://static.wumii.com/images/widget/widget_solidPoint.gif">
                    <a target="_blank" style="text-decoration: none !important;" href="http://app.wumii.com/ext/redirect.htm?url=http%3A%2F%2Fsexywp.com%2Fremove-author-from-body-class.htm&from=http%3A%2F%2Fsexywp.com%2Fhide-the-search-button.htm">
                        <font size="-1" color="#333333" style="line-height: 1.65em; font-size: 12px !important;">修正SandBox的Author页面错误</font>
                    </a>
                </td>
            </tr>
            <tr>
                <td style="margin: 0 !important; padding: 0 !important; line-height: 20px !important;">
                    <img border="0" src="http://static.wumii.com/images/widget/widget_solidPoint.gif">
                    <a target="_blank" style="text-decoration: none !important;" href="http://app.wumii.com/ext/redirect.htm?url=http%3A%2F%2Fsexywp.com%2Fadd-home-and-admin-to-navigator.htm&from=http%3A%2F%2Fsexywp.com%2Fhide-the-search-button.htm">
                        <font size="-1" color="#333333" style="line-height: 1.65em; font-size: 12px !important;">在SandBox的导航中添加“首页”和“网站管理”</font>
                    </a>
                </td>
            </tr>
            <tr>
                <td style="margin: 0 !important; padding: 0 !important; line-height: 20px !important;">
                    <img border="0" src="http://static.wumii.com/images/widget/widget_solidPoint.gif">
                    <a target="_blank" style="text-decoration: none !important;" href="http://app.wumii.com/ext/redirect.htm?url=http%3A%2F%2Fsexywp.com%2Fshare-this-jquery.htm&from=http%3A%2F%2Fsexywp.com%2Fhide-the-search-button.htm">
                        <font size="-1" color="#333333" style="line-height: 1.65em; font-size: 12px !important;">WordPress插件修改：Share This (jQuery)</font>
                    </a>
                </td>
            </tr>
            <tr>
                <td style="margin: 0 !important; padding: 0 !important; line-height: 20px !important;">
                    <img border="0" src="http://static.wumii.com/images/widget/widget_solidPoint.gif">
                    <a target="_blank" style="text-decoration: none !important;" href="http://app.wumii.com/ext/redirect.htm?url=http%3A%2F%2Fsexywp.com%2Fprogress-enhancement-of-comment-form.htm&from=http%3A%2F%2Fsexywp.com%2Fhide-the-search-button.htm">
                        <font size="-1" color="#333333" style="line-height: 1.65em; font-size: 12px !important;">也说用jQuery改进WP评论表单</font>
                    </a>
                </td>
            </tr>
    
    <tr>
        <td  align="right">
            <a style="text-decoration: none !important;" href="http://www.wumii.com/widget/relatedItems.htm" 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>
	标签：<a href="http://sexywp.com/tags/diy" title="DIY" rel="tag">DIY</a>, <a href="http://sexywp.com/tags/javascript" title="javascript" rel="tag">javascript</a>, <a href="http://sexywp.com/tags/jquery" title="jQuery" rel="tag">jQuery</a>, <a href="http://sexywp.com/tags/sandbox" title="SandBox" rel="tag">SandBox</a>, <a href="http://sexywp.com/tags/wordpress" title="WordPress" rel="tag">WordPress</a><br />
]]></content:encoded>
			<wfw:commentRss>http://sexywp.com/hide-the-search-button.htm/feed</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
	</channel>
</rss>

