<?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>Life Studio &#187; JS</title>
	<atom:link href="http://wange.im/tag/js/feed" rel="self" type="application/rss+xml" />
	<link>http://wange.im</link>
	<description>My Life, My Studio...</description>
	<lastBuildDate>Fri, 20 Jan 2012 01:49:17 +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>WordPress 将选中文字转发到微博</title>
		<link>http://wange.im/wordpress-share-selected-text-to-weibo.html</link>
		<comments>http://wange.im/wordpress-share-selected-text-to-weibo.html#comments</comments>
		<pubDate>Sat, 29 Oct 2011 23:19:45 +0000</pubDate>
		<dc:creator>万戈</dc:creator>
				<category><![CDATA[电脑网络]]></category>
		<category><![CDATA[JS]]></category>
		<category><![CDATA[QQ]]></category>
		<category><![CDATA[WordPress]]></category>
		<category><![CDATA[微博]]></category>
		<category><![CDATA[新浪]]></category>
		<category><![CDATA[腾讯]]></category>

		<guid isPermaLink="false">http://wange.im/?p=5152</guid>
		<description><![CDATA[最近在看腾讯新闻的时候，无意中发现，当我选中新闻中的文字的时候，鼠标右上角会显示一个“转播至微博”的按钮，点击后就会将选中的文字转发到微博上。这是一个很不错的用户体验，如果能把它引入到 WordPress 博客中，那不是很好吗？ 为此我还特地去注册了一个腾讯微博开放平台的开发者，当我开始阅读开发文档的时候，才发现，他妹的，腾讯官方已经推出一个相同功能的应用，叫作 “Q-Share”，再翻阅了一下其他资料，原来已经有前辈写出了 js 页面文字选中后分享到新浪微博的方法，那我就省力多了，两者结合一下，把新浪微博和腾讯微博两个按钮都加上了，然后闲的蛋疼的我又把它翻译成了 jQuery 的方法。 效果的话就可以看本站了，选中任何文字，就会在右上角显示两个微博按钮，点击试试吧。 实现的方法也很简单，只需要两步： 1、引入 jQuery，相信大多数 WordPress 博客都已经引入了 jQuery，那就可以直接进行第二步了。 2、在页面底部，或者更确切的说，在引入 jQuery 库的后面加上这样一段 JS，你就可以看到和本站一样的效果了。 var miniBlogShare = function() {     //指定位置驻入节点     $('&#60;img id="imgSinaShare" class="img_share" title="将选中内容分享到新浪微博" src="http://wange.im/wp-content/themes/wange/images/sina_share.gif" /&#62;&#60;img id="imgQqShare" class="img_share" title="将选中内容分享到腾讯微博" src="http://wange.im/wp-content/themes/wange/images/tt_share.png" /&#62;').appendTo('body');         //默认样式     $('.img_share').css({         display : 'none',         position : 'absolute',         cursor : [...]]]></description>
			<content:encoded><![CDATA[<p>最近在看腾讯新闻的时候，无意中发现，当我选中新闻中的文字的时候，鼠标右上角会显示一个“转播至微博”的按钮，点击后就会将选中的文字转发到微博上。这是一个很不错的用户体验，如果能把它引入到 WordPress 博客中，那不是很好吗？</p>
<p>为此我还特地去注册了一个腾讯微博开放平台的开发者，当我开始阅读开发文档的时候，才发现，他妹的，腾讯官方已经推出一个相同功能的应用，叫作 “Q-Share”，再翻阅了一下其他资料，原来已经有前辈写出了 <a title="页面选中文字分享到新浪微博实例页面" href="http://www.zhangxinxu.com/study/201102/text-selected-share-sina-miniblog.html" rel="external nofollow" target="_blank">js 页面文字选中后分享到新浪微博</a>的方法，那我就省力多了，两者结合一下，把新浪微博和腾讯微博两个按钮都加上了，然后闲的蛋疼的我又把它翻译成了 jQuery 的方法。</p>
<p>效果的话就可以看本站了，选中任何文字，就会在右上角显示两个微博按钮，点击试试吧。</p>
<p>实现的方法也很简单，只需要两步：</p>
<p>1、引入 jQuery，相信大多数 WordPress 博客都已经引入了 jQuery，那就可以直接进行第二步了。</p>
<p>2、在页面底部，或者更确切的说，在引入 jQuery 库的后面加上这样一段 JS，你就可以看到和本站一样的效果了。</p>
<div class="source" style="font-family: 'Courier New','Consolas','Lucida Console'; color: #000000;"><span style="color: #000080; font-weight: bold;">var</span> <span style="color: #000000;">miniBlogShare</span> <span style="color: #000000;">=</span> <span style="color: #000080; font-weight: bold;">function</span>() <span style="color: #000000;">{</span><br />
    <span style="font-style: italic; color: #008800;">//指定位置驻入节点</span><br />
    <span style="color: #000000;">$</span>(<span style="color: #0000ff;">'&lt;img id="imgSinaShare" class="img_share" title="将选中内容分享到新浪微博" src="http://wange.im/wp-content/themes/wange/images/sina_share.gif" /&gt;&lt;img id="imgQqShare" class="img_share" title="将选中内容分享到腾讯微博" src="http://wange.im/wp-content/themes/wange/images/tt_share.png" /&gt;'</span><span style="color: #000000;">).</span><span style="color: #000000;">appendTo</span>(<span style="color: #0000ff;">'body'</span>);<br />
   <br />
    <span style="font-style: italic; color: #008800;">//默认样式</span><br />
    <span style="color: #000000;">$</span>(<span style="color: #0000ff;">'.img_share'</span><span style="color: #000000;">).</span><span style="color: #000000;">css</span><span style="color: #000000;">({</span><br />
        <span style="color: #000000;">display</span> <span style="color: #000000;">:</span> <span style="color: #0000ff;">'none'</span><span style="color: #000000;">,</span><br />
        <span style="color: #000000;">position</span> <span style="color: #000000;">:</span> <span style="color: #0000ff;">'absolute'</span><span style="color: #000000;">,</span><br />
        <span style="color: #000000;">cursor</span> <span style="color: #000000;">:</span> <span style="color: #0000ff;">'pointer'</span><br />
    <span style="color: #000000;">});</span><br />
   <br />
    <span style="font-style: italic; color: #008800;">//选中文字</span><br />
    <span style="color: #000080; font-weight: bold;">var</span> <span style="color: #000000;">funGetSelectTxt</span> <span style="color: #000000;">=</span> <span style="color: #000080; font-weight: bold;">function</span>() <span style="color: #000000;">{</span><br />
        <span style="color: #000080; font-weight: bold;">var</span> <span style="color: #000000;">txt</span> <span style="color: #000000;">=</span> <span style="color: #0000ff;">''</span>;<br />
        <span style="color: #000080; font-weight: bold;">if</span>(<span style="color: #000000;">document</span><span style="color: #000000;">.</span><span style="color: #000000;">selection</span>) <span style="color: #000000;">{</span><br />
            <span style="color: #000000;">txt</span> <span style="color: #000000;">=</span> <span style="color: #000000;">document</span><span style="color: #000000;">.</span><span style="color: #000000;">selection</span><span style="color: #000000;">.</span><span style="color: #000000;">createRange</span><span style="color: #000000;">().</span><span style="color: #000000;">text</span>;<br />
        <span style="color: #000000;">}</span> <span style="color: #000080; font-weight: bold;">else</span> <span style="color: #000000;">{</span><br />
            <span style="color: #000000;">txt</span> <span style="color: #000000;">=</span> <span style="color: #000000;">document</span><span style="color: #000000;">.</span><span style="color: #000000;">getSelection</span>();<br />
        <span style="color: #000000;">}</span><br />
        <span style="color: #000080; font-weight: bold;">return</span> <span style="color: #000000;">txt</span><span style="color: #000000;">.</span><span style="color: #000000;">toString</span>();<br />
    <span style="color: #000000;">};</span><br />
   <br />
    <span style="font-style: italic; color: #008800;">//选中文字后显示微博图标</span><br />
    <span style="color: #000000;">$</span>(<span style="color: #0000ff;">'html,body'</span><span style="color: #000000;">).</span><span style="color: #000000;">mouseup</span>(<span style="color: #000080; font-weight: bold;">function</span>(<span style="color: #000000;">e</span>) <span style="color: #000000;">{</span><br />
        <span style="color: #000080; font-weight: bold;">if</span> (<span style="color: #000000;">e</span><span style="color: #000000;">.</span><span style="color: #000000;">target</span><span style="color: #000000;">.</span><span style="color: #000000;">id</span> <span style="color: #000000;">==</span> <span style="color: #0000ff;">'imgSinaShare'</span> || <span style="color: #000000;">e</span><span style="color: #000000;">.</span><span style="color: #000000;">target</span><span style="color: #000000;">.</span><span style="color: #000000;">id</span> <span style="color: #000000;">==</span> <span style="color: #0000ff;">'imgQqShare'</span>) <span style="color: #000000;">{</span><br />
            <span style="color: #000080; font-weight: bold;">return</span><br />
        <span style="color: #000000;">}</span><br />
        <span style="color: #000000;">e</span> <span style="color: #000000;">=</span> <span style="color: #000000;">e</span> || <span style="color: #000000;">window</span><span style="color: #000000;">.</span><span style="color: #000000;">event</span>;<br />
        <span style="color: #000080; font-weight: bold;">var</span> <span style="color: #000000;">txt</span> <span style="color: #000000;">=</span> <span style="color: #000000;">funGetSelectTxt</span><span style="color: #000000;">(),</span><br />
            <span style="color: #000000;">sh</span> <span style="color: #000000;">=</span> <span style="color: #000000;">window</span><span style="color: #000000;">.</span><span style="color: #000000;">pageYOffset</span> || <span style="color: #000000;">document</span><span style="color: #000000;">.</span><span style="color: #000000;">documentElement</span><span style="color: #000000;">.</span><span style="color: #000000;">scrollTop</span> || <span style="color: #000000;">document</span><span style="color: #000000;">.</span><span style="color: #000000;">body</span><span style="color: #000000;">.</span><span style="color: #000000;">scrollTop</span> || <span style="color: #0000ff;">0</span><span style="color: #000000;">,</span><br />
            <span style="color: #000000;">left</span> <span style="color: #000000;">=</span> (<span style="color: #000000;">e</span><span style="color: #000000;">.</span><span style="color: #000000;">clientX</span> <span style="color: #000000;">-</span> <span style="color: #0000ff;">40</span> <span style="color: #000000;">&lt;</span> <span style="color: #0000ff;">0</span>) <span style="color: #000000;">?</span> <span style="color: #000000;">e</span><span style="color: #000000;">.</span><span style="color: #000000;">clientX</span> <span style="color: #000000;">+</span> <span style="color: #0000ff;">20</span> <span style="color: #000000;">:</span> <span style="color: #000000;">e</span><span style="color: #000000;">.</span><span style="color: #000000;">clientX</span> <span style="color: #000000;">-</span> <span style="color: #0000ff;">40</span><span style="color: #000000;">,</span><br />
            <span style="color: #000000;">top</span> <span style="color: #000000;">=</span> (<span style="color: #000000;">e</span><span style="color: #000000;">.</span><span style="color: #000000;">clientY</span> <span style="color: #000000;">-</span> <span style="color: #0000ff;">40</span> <span style="color: #000000;">&lt;</span> <span style="color: #0000ff;">0</span>) <span style="color: #000000;">?</span> <span style="color: #000000;">e</span><span style="color: #000000;">.</span><span style="color: #000000;">clientY</span> <span style="color: #000000;">+</span> <span style="color: #000000;">sh</span> <span style="color: #000000;">+</span> <span style="color: #0000ff;">20</span> <span style="color: #000000;">:</span> <span style="color: #000000;">e</span><span style="color: #000000;">.</span><span style="color: #000000;">clientY</span> <span style="color: #000000;">+</span> <span style="color: #000000;">sh</span> <span style="color: #000000;">-</span> <span style="color: #0000ff;">40</span>;<br />
        <span style="color: #000080; font-weight: bold;">if</span> (<span style="color: #000000;">txt</span>) <span style="color: #000000;">{</span><br />
            <span style="color: #000000;">$</span>(<span style="color: #0000ff;">'#imgSinaShare'</span><span style="color: #000000;">).</span><span style="color: #000000;">css</span><span style="color: #000000;">({</span><br />
                <span style="color: #000000;">display</span> <span style="color: #000000;">:</span> <span style="color: #0000ff;">'inline'</span><span style="color: #000000;">,</span><br />
                <span style="color: #000000;">left</span> <span style="color: #000000;">:</span> <span style="color: #000000;">left</span><span style="color: #000000;">,</span><br />
                <span style="color: #000000;">top</span> <span style="color: #000000;">:</span> <span style="color: #000000;">top</span><br />
            <span style="color: #000000;">});</span><br />
            <span style="color: #000000;">$</span>(<span style="color: #0000ff;">'#imgQqShare'</span><span style="color: #000000;">).</span><span style="color: #000000;">css</span><span style="color: #000000;">({</span><br />
                <span style="color: #000000;">display</span> <span style="color: #000000;">:</span> <span style="color: #0000ff;">'inline'</span><span style="color: #000000;">,</span><br />
                <span style="color: #000000;">left</span> <span style="color: #000000;">:</span> <span style="color: #000000;">left</span> <span style="color: #000000;">+</span> <span style="color: #0000ff;">30</span><span style="color: #000000;">,</span><br />
                <span style="color: #000000;">top</span> <span style="color: #000000;">:</span> <span style="color: #000000;">top</span><br />
            <span style="color: #000000;">});</span><br />
        <span style="color: #000000;">}</span> <span style="color: #000080; font-weight: bold;">else</span> <span style="color: #000000;">{</span><br />
            <span style="color: #000000;">$</span>(<span style="color: #0000ff;">'#imgSinaShare'</span><span style="color: #000000;">).</span><span style="color: #000000;">css</span>(<span style="color: #0000ff;">'display'</span><span style="color: #000000;">,</span> <span style="color: #0000ff;">'none'</span>);<br />
            <span style="color: #000000;">$</span>(<span style="color: #0000ff;">'#imgQqShare'</span><span style="color: #000000;">).</span><span style="color: #000000;">css</span>(<span style="color: #0000ff;">'display'</span><span style="color: #000000;">,</span> <span style="color: #0000ff;">'none'</span>);<br />
        <span style="color: #000000;">}</span><br />
    <span style="color: #000000;">});</span><br />
   <br />
    <span style="font-style: italic; color: #008800;">//点击新浪微博</span><br />
    <span style="color: #000000;">$</span>(<span style="color: #0000ff;">'#imgSinaShare'</span><span style="color: #000000;">).</span><span style="color: #000000;">click</span>(<span style="color: #000080; font-weight: bold;">function</span>() <span style="color: #000000;">{</span><br />
        <span style="color: #000080; font-weight: bold;">var</span> <span style="color: #000000;">txt</span> <span style="color: #000000;">=</span> <span style="color: #000000;">funGetSelectTxt</span><span style="color: #000000;">(),</span> <span style="color: #000000;">title</span> <span style="color: #000000;">=</span> <span style="color: #000000;">$</span>(<span style="color: #0000ff;">'title'</span><span style="color: #000000;">).</span><span style="color: #000000;">html</span>();<br />
        <span style="color: #000080; font-weight: bold;">if</span> (<span style="color: #000000;">txt</span>) <span style="color: #000000;">{</span><br />
            <span style="color: #000000;">window</span><span style="color: #000000;">.</span><span style="color: #000000;">open</span>(<span style="color: #0000ff;">'http://v.t.sina.com.cn/share/share.php?title='</span> <span style="color: #000000;">+</span> <span style="color: #000000;">txt</span> <span style="color: #000000;">+</span> <span style="color: #0000ff;">' —— 转载自：'</span> <span style="color: #000000;">+</span> <span style="color: #000000;">title</span> <span style="color: #000000;">+</span> <span style="color: #0000ff;">'&amp;url='</span> <span style="color: #000000;">+</span> <span style="color: #000000;">window</span><span style="color: #000000;">.</span><span style="color: #000000;">location</span><span style="color: #000000;">.</span><span style="color: #000000;">href</span>);<br />
        <span style="color: #000000;">}</span><br />
    <span style="color: #000000;">});</span><br />
   <br />
    <span style="font-style: italic; color: #008800;">//点击腾讯微博</span><br />
    <span style="color: #000000;">$</span>(<span style="color: #0000ff;">'#imgQqShare'</span><span style="color: #000000;">).</span><span style="color: #000000;">click</span>(<span style="color: #000080; font-weight: bold;">function</span>() <span style="color: #000000;">{</span><br />
        <span style="color: #000080; font-weight: bold;">var</span> <span style="color: #000000;">txt</span> <span style="color: #000000;">=</span> <span style="color: #000000;">funGetSelectTxt</span><span style="color: #000000;">(),</span> <span style="color: #000000;">title</span> <span style="color: #000000;">=</span> <span style="color: #000000;">$</span>(<span style="color: #0000ff;">'title'</span><span style="color: #000000;">).</span><span style="color: #000000;">html</span>();<br />
        <span style="color: #000080; font-weight: bold;">if</span> (<span style="color: #000000;">txt</span>) <span style="color: #000000;">{</span><br />
            <span style="color: #000000;">window</span><span style="color: #000000;">.</span><span style="color: #000000;">open</span>(<span style="color: #0000ff;">'http://v.t.qq.com/share/share.php?title='</span> <span style="color: #000000;">+</span> <span style="color: #000000;">encodeURIComponent</span>(<span style="color: #000000;">txt</span> <span style="color: #000000;">+</span> <span style="color: #0000ff;">' —— 转载自：'</span> <span style="color: #000000;">+</span> <span style="color: #000000;">title</span>) <span style="color: #000000;">+</span> <span style="color: #0000ff;">'&amp;url='</span> <span style="color: #000000;">+</span> <span style="color: #000000;">window</span><span style="color: #000000;">.</span><span style="color: #000000;">location</span><span style="color: #000000;">.</span><span style="color: #000000;">href</span>);<br />
        <span style="color: #000000;">}</span><br />
    <span style="color: #000000;">});</span><br />
<span style="color: #000000;">}();</span></div>
<p>是不是很简单呀？</p>
<p>赶紧选中本文的标题，在微博上通知你的好友来围观吧，哈哈~</p>
<p><img src="http://byfiles.storage.live.com/y1pbpmnSpy4Pja6i0ie8UhJQntR6oaADKG8tRbhlfYsiXc21tQ02IWZ-4_h53-v8radfgLxl33jnVU/weibo_share.jpg" alt="" /></p>
<p>PS：最后，说一句，其实这个方法不仅仅适用于 WordPress，JS 是通用的，你可以把这段 JS 挂载到任何网站上都可以得到相同的效果 <img src='http://wange.im/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' /> </p>
<p>PS2：最最最后，再说一句，麻烦各位在使用前，把 JS 里的两张微博的图片路径替换成自己的地址，因为小站流量有限，大家帮我省着点花呗，嘿嘿。</p>
<div id="rl_posts">    <div id="rl_posts_hd" class="box_hd">        <span id="rl_posts_title" class="box_title">与 <h2 itemprop="keywords"><a href="http://wange.im/tag/js/" title="JS" rel="tag">JS</a>,<a href="http://wange.im/tag/qq/" title="QQ" rel="tag">QQ</a>,<a href="http://wange.im/tag/wordpress/" title="WordPress" rel="tag">WordPress</a>,<a href="http://wange.im/tag/micr-bo/" title="微博" rel="tag">微博</a>,<a href="http://wange.im/tag/sina/" title="新浪" rel="tag">新浪</a>,<a href="http://wange.im/tag/tencent/" title="腾讯" rel="tag">腾讯</a></h2> 相关的文章        </span>    </div>    <div id="rl_posts_bd">        <ul class="clearfix"><li>    <div class="rl_thumb"><img src="http://wange.im/wp-content/themes/wange/timthumb.php?src=&amp;h=45&amp;w=45&amp;zc=1" alt="微博认证，勾与火的考验" width="45" height="45" itemprop="thumbnailUrl" />    </div>    <div class="rl_title">        <a href="http://wange.im/microblog-certification.html" rel="bookmark" title="微博认证，勾与火的考验">微博认证，勾与火的考验</a>        <div class="rl_date">2011年03月27日</div>    </div></li><li>    <div class="rl_thumb"><img src="http://wange.im/wp-content/themes/wange/timthumb.php?src=&amp;h=45&amp;w=45&amp;zc=1" alt="QQ 微博初体验" width="45" height="45" itemprop="thumbnailUrl" />    </div>    <div class="rl_title">        <a href="http://wange.im/t-qq-com.html" rel="bookmark" title="QQ 微博初体验">QQ 微博初体验</a>        <div class="rl_date">2010年04月15日</div>    </div></li><li>    <div class="rl_thumb"><img src="http://wange.im/wp-content/themes/wange/timthumb.php?src=&amp;h=45&amp;w=45&amp;zc=1" alt="腾讯牌操作系统离我们还有多远？" width="45" height="45" itemprop="thumbnailUrl" />    </div>    <div class="rl_title">        <a href="http://wange.im/tencent-webos.html" rel="bookmark" title="腾讯牌操作系统离我们还有多远？">腾讯牌操作系统离我们还有多远？</a>        <div class="rl_date">2011年04月21日</div>    </div></li><li>    <div class="rl_thumb"><img src="http://wange.im/wp-content/themes/wange/timthumb.php?src=&amp;h=45&amp;w=45&amp;zc=1" alt="非插件同步 WordPress 日志到嘀咕" width="45" height="45" itemprop="thumbnailUrl" />    </div>    <div class="rl_title">        <a href="http://wange.im/sync-wordpress-to-digu.html" rel="bookmark" title="非插件同步 WordPress 日志到嘀咕">非插件同步 WordPress 日志到嘀咕</a>        <div class="rl_date">2011年03月31日</div>    </div></li>        </ul>    </div></div>]]></content:encoded>
			<wfw:commentRss>http://wange.im/wordpress-share-selected-text-to-weibo.html/feed</wfw:commentRss>
		<slash:comments>116</slash:comments>
		</item>
		<item>
		<title>jQuery/JavaScript 实现的异步加载图片</title>
		<link>http://wange.im/jquery-js-ajax-pic.html</link>
		<comments>http://wange.im/jquery-js-ajax-pic.html#comments</comments>
		<pubDate>Sun, 10 Apr 2011 12:55:34 +0000</pubDate>
		<dc:creator>万戈</dc:creator>
				<category><![CDATA[电脑网络]]></category>
		<category><![CDATA[AJAX]]></category>
		<category><![CDATA[Javascript]]></category>
		<category><![CDATA[jQuery]]></category>
		<category><![CDATA[JS]]></category>
		<category><![CDATA[图片]]></category>

		<guid isPermaLink="false">http://wange.im/?p=4745</guid>
		<description><![CDATA[前天我亲奶滴偶像+室友+同事任平生小盆友在为我首页加载的速度上挑刺（YSlow V2下Grade A的我已经神一般的飞速了 O(∩_∩)O~），还真被他一眼挑出几个可以优化的细节之处，比如说首页文章列表页的展开后显示的缩略图，任平生GG 表示，这些图片完全可以不用事先加载，等用户点击展开之后才加载，不点击就不加载。这样一来，以我首页显示10篇文章列表为例，如果每篇缩略图6K左右，一个首页加载就节省了60K左右，何乐而不为呢？ 任平生GG 用的是 jQuery 实现的图片异步加载，而我整理了一下，又折腾了一个 JavaScript 版的图片异步加载效果，两者原理是一样一样的，先请看 DEMO。 在上代码之前先说一下简单的原理，我们知道在 img 标签中的 src 属性是指向图片地址，要实现异步加载，就先暂时不给 src 属性赋值，而是先找个中间变量的属性 data-src，把图片地址写在 data-src 属性里，然后当触发 onclick 事件的时候，把 data-src 的值复制给 src，也就实现了异步加载。 代码时间到，因为无论是 jQuery 还是 JavaScript 的方法，HTML 的结构是相同的，如下： &#60;div id="box"&#62;     &#60;input type="submit" value="异步加载图片" id="submitBtn" /&#62;     &#60;div class="picBox"&#62;         &#60;img data-src="logo.png" alt="" class="logo" /&#62;     &#60;/div&#62; &#60;/div&#62; 先上 jQuery [...]]]></description>
			<content:encoded><![CDATA[<p>前天我亲奶滴偶像+室友+同事<a title="任平生" href="http://rpsh.net/" target="_blank">任平生</a>小盆友在为我首页加载的速度上挑刺（YSlow V2下Grade A的我已经神一般的飞速了 O(∩_∩)O~），还真被他一眼挑出几个可以优化的细节之处，比如说首页文章列表页的展开后显示的缩略图，任平生GG 表示，这些图片完全可以不用事先加载，等用户点击展开之后才加载，不点击就不加载。这样一来，以我首页显示10篇文章列表为例，如果每篇缩略图6K左右，一个首页加载就节省了60K左右，何乐而不为呢？</p>
<p>任平生GG 用的是 jQuery 实现的图片异步加载，而我整理了一下，又折腾了一个 JavaScript 版的图片异步加载效果，两者原理是一样一样的，先请看 <a title="jQuery/JavaScript 实现的异步加载图片" href="http://wange.im/demo/ajax-pic/">DEMO</a>。</p>
<p>在上代码之前先说一下简单的原理，我们知道在 img 标签中的 src 属性是指向图片地址，要实现异步加载，就先暂时不给 src 属性赋值，而是先找个中间变量的属性 data-src，把图片地址写在 data-src 属性里，然后当触发 onclick 事件的时候，把 data-src 的值复制给 src，也就实现了异步加载。</p>
<p>代码时间到，因为无论是 jQuery 还是 JavaScript 的方法，HTML 的结构是相同的，如下：</p>
<div class="source" style="font-family: 'Courier New', 'Lucida Console', 'monospace'; color: #000000;"><span style="color: #000080; font-weight: bold;">&lt;div</span> <span style="color: #ff0000;">id=</span><span style="color: #0000ff;">"box"</span><span style="color: #000080; font-weight: bold;">&gt;</span><br />
    <span style="color: #000080; font-weight: bold;">&lt;input</span> <span style="color: #ff0000;">type=</span><span style="color: #0000ff;">"submit"</span> <span style="color: #ff0000;">value=</span><span style="color: #0000ff;">"异步加载图片"</span> <span style="color: #ff0000;">id=</span><span style="color: #0000ff;">"submitBtn"</span> <span style="color: #000080; font-weight: bold;">/&gt;</span><br />
    <span style="color: #000080; font-weight: bold;">&lt;div</span> <span style="color: #ff0000;">class=</span><span style="color: #0000ff;">"picBox"</span><span style="color: #000080; font-weight: bold;">&gt;</span><br />
        <span style="color: #000080; font-weight: bold;">&lt;img</span> <span style="color: #ff0000;">data-src=</span><span style="color: #0000ff;">"logo.png"</span> <span style="color: #ff0000;">alt=</span><span style="color: #0000ff;">""</span> <span style="color: #ff0000;">class=</span><span style="color: #0000ff;">"logo"</span> <span style="color: #000080; font-weight: bold;">/&gt;</span><br />
    <span style="color: #000080; font-weight: bold;">&lt;/div&gt;</span><br />
<span style="color: #000080; font-weight: bold;">&lt;/div&gt;</span></div>
<p>先上 jQuery 的方法：</p>
<div class="source" style="font-family: 'Courier New', 'Lucida Console', 'monospace'; color: #000000;"><span style="color: #000000;">$</span>(<span style="color: #000000;">document</span><span style="color: #000000;">).</span><span style="color: #000000;">ready</span>(<span style="color: #000080; font-weight: bold;">function</span><span style="color: #000000;">(){</span><br />
    <span style="color: #000000;">$</span>(<span style="color: #0000ff;">'#submitBtn'</span><span style="color: #000000;">).</span><span style="color: #000000;">click</span>(<span style="color: #000080; font-weight: bold;">function</span>() <span style="color: #000000;">{</span><br />
        <span style="color: #000080; font-weight: bold;">var</span> <span style="color: #000000;">imgSrc</span> <span style="color: #000000;">=</span> <span style="color: #000000;">$</span>(<span style="color: #000080; font-weight: bold;">this</span><span style="color: #000000;">).</span><span style="color: #000000;">next</span><span style="color: #000000;">().</span><span style="color: #000000;">find</span>(<span style="color: #0000ff;">'.logo'</span><span style="color: #000000;">).</span><span style="color: #000000;">attr</span>(<span style="color: #0000ff;">'data-src'</span>);<br />
        <span style="color: #000000;">$</span>(<span style="color: #000080; font-weight: bold;">this</span><span style="color: #000000;">).</span><span style="color: #000000;">next</span><span style="color: #000000;">().</span><span style="color: #000000;">find</span>(<span style="color: #0000ff;">'.logo'</span><span style="color: #000000;">).</span><span style="color: #000000;">attr</span>(<span style="color: #0000ff;">'src'</span><span style="color: #000000;">,</span> <span style="color: #000000;">imgSrc</span>);<br />
    <span style="color: #000000;">});</span><br />
<span style="color: #000000;">});</span></div>
<p>再比较一下 JavaScript 的方法：</p>
<div class="source" style="font-family: 'Courier New', 'Lucida Console', 'monospace'; color: #000000;"><span style="color: #000000;">window</span><span style="color: #000000;">.</span><span style="color: #000000;">onload</span> <span style="color: #000000;">=</span> <span style="color: #000080; font-weight: bold;">function</span><span style="color: #000000;">(){</span><br />
    <span style="color: #000000;">document</span><span style="color: #000000;">.</span><span style="color: #000000;">getElementById</span>(<span style="color: #0000ff;">'submitBtn'</span><span style="color: #000000;">).</span><span style="color: #000000;">onclick</span> <span style="color: #000000;">=</span> <span style="color: #000000;">submitBtn</span>;<br />
<span style="color: #000000;">}</span><br />
<span style="color: #000080; font-weight: bold;">function</span> <span style="color: #000000;">submitBtn</span><span style="color: #000000;">(){</span><br />
    <span style="color: #000080; font-weight: bold;">var</span> <span style="color: #000000;">imgTag</span> <span style="color: #000000;">=</span> <span style="color: #000000;">document</span><span style="color: #000000;">.</span><span style="color: #000000;">getElementById</span>(<span style="color: #0000ff;">'box'</span><span style="color: #000000;">).</span><span style="color: #000000;">getElementsByTagName</span>(<span style="color: #0000ff;">'img'</span>);<br />
    <span style="color: #000080; font-weight: bold;">var</span> <span style="color: #000000;">imgSrc</span> <span style="color: #000000;">=</span> <span style="color: #000000;">imgTag</span><span style="color: #000000;">[</span><span style="color: #0000ff;">0</span><span style="color: #000000;">].</span><span style="color: #000000;">getAttribute</span>(<span style="color: #0000ff;">'data-src'</span>);<br />
    <span style="color: #000000;">imgTag</span><span style="color: #000000;">[</span><span style="color: #0000ff;">0</span><span style="color: #000000;">].</span><span style="color: #000000;">setAttribute</span>(<span style="color: #0000ff;">'src'</span><span style="color: #000000;">,</span><span style="color: #000000;">imgSrc</span>);<br />
<span style="color: #000000;">}</span></div>
<p>再来玩一下这个 <a title="jQuery/JavaScript 实现的异步加载图片" href="http://wange.im/demo/ajax-pic/">DEMO</a>，按照这个原理，发现自己写一个 lazyload 的 jQuery 插件也并不是很难嘛，哈哈～</p>
<div id="rl_posts">    <div id="rl_posts_hd" class="box_hd">        <span id="rl_posts_title" class="box_title">与 <h2 itemprop="keywords"><a href="http://wange.im/tag/ajax/" title="AJAX" rel="tag">AJAX</a>,<a href="http://wange.im/tag/javascript/" title="Javascript" rel="tag">Javascript</a>,<a href="http://wange.im/tag/jquery/" title="jQuery" rel="tag">jQuery</a>,<a href="http://wange.im/tag/js/" title="JS" rel="tag">JS</a>,<a href="http://wange.im/tag/picture/" title="图片" rel="tag">图片</a></h2> 相关的文章        </span>    </div>    <div id="rl_posts_bd">        <ul class="clearfix"><li>    <div class="rl_thumb"><img src="http://wange.im/wp-content/themes/wange/timthumb.php?src=http://wange.im/cache/rss2.jpg&amp;h=45&amp;w=45&amp;zc=1" alt="JQuery 鼠标滑动渐隐渐显效果" width="45" height="45" itemprop="thumbnailUrl" />    </div>    <div class="rl_title">        <a href="http://wange.im/fadein-and-fadeout-with-jquery.html" rel="bookmark" title="JQuery 鼠标滑动渐隐渐显效果">JQuery 鼠标滑动渐隐渐显效果</a>        <div class="rl_date">2010年05月5日</div>    </div></li><li>    <div class="rl_thumb"><img src="http://wange.im/wp-content/themes/wange/imgs/category/computer.jpg" alt="电脑网络" width="45" height="45" itemprop="thumbnailUrl" />    </div>    <div class="rl_title">        <a href="http://wange.im/fadeto-effect-with-jquery.html" rel="bookmark" title="利用 JQuery 实现图片显隐特效">利用 JQuery 实现图片显隐特效</a>        <div class="rl_date">2010年04月8日</div>    </div></li><li>    <div class="rl_thumb"><img src="http://wange.im/wp-content/themes/wange/timthumb.php?src=http://wange.im/cache/sweet-titles.jpg&amp;h=45&amp;w=45&amp;zc=1" alt="JQuery 鼠标提示特效之 Sweet Titles" width="45" height="45" itemprop="thumbnailUrl" />    </div>    <div class="rl_title">        <a href="http://wange.im/jquery-sweet-titles-tooltips.html" rel="bookmark" title="JQuery 鼠标提示特效之 Sweet Titles">JQuery 鼠标提示特效之 Sweet Titles</a>        <div class="rl_date">2010年03月14日</div>    </div></li><li>    <div class="rl_thumb"><img src="http://wange.im/wp-content/themes/wange/imgs/category/computer.jpg" alt="电脑网络" width="45" height="45" itemprop="thumbnailUrl" />    </div>    <div class="rl_title">        <a href="http://wange.im/marquee-scroll.html" rel="bookmark" title="基于 jQuery 的图片/文字无缝滚动">基于 jQuery 的图片/文字无缝滚动</a>        <div class="rl_date">2011年12月20日</div>    </div></li>        </ul>    </div></div>]]></content:encoded>
			<wfw:commentRss>http://wange.im/jquery-js-ajax-pic.html/feed</wfw:commentRss>
		<slash:comments>121</slash:comments>
		</item>
		<item>
		<title>WordPress 3.1 偷偷挂载 l10n.js 脚本！</title>
		<link>http://wange.im/l10n-js-in-wordpress-3-1.html</link>
		<comments>http://wange.im/l10n-js-in-wordpress-3-1.html#comments</comments>
		<pubDate>Thu, 24 Feb 2011 14:29:16 +0000</pubDate>
		<dc:creator>万戈</dc:creator>
				<category><![CDATA[电脑网络]]></category>
		<category><![CDATA[JS]]></category>
		<category><![CDATA[l10n]]></category>
		<category><![CDATA[WordPress]]></category>

		<guid isPermaLink="false">http://wange.im/?p=4571</guid>
		<description><![CDATA[最近因为龙体欠佳，很少有关注 WordPress 的最新动态，今天趁稍微恢复一点精神看了一下 WordPress 后台，居然有 WordPress 3.1 中文版可以升级了，作为与时俱进的升级控，对自己的主题向后兼容性是绝对有信心的，果断升级！ 还没去 WordPress 官方了解过 3.1 版本到底是个什么样的东东，只是从第一眼来看，最明显的是多了一个工具条，和我的万戈牌工具条插件有异曲同工之处。但是再仔细一看，Wordpress 3.1 做了一件非常 YD + 恶心 + 无耻 + 卑鄙的事情！在给我的主题头部偷偷加上了一小段 JS！有图有真相： 虽说这段脚本不大，也才0.3K 左右，但是 WordPress 的这种做法是让人不能容忍的，凭什么呀凭什么呀，哥明明没在主题里允许你的存在，非要给我多加一段 JS，作为有代码洁癖的我，怎么能容许它的存在呢，除之而后快！ 把以下这句函数放在 WordPress 主题的 functions.php 中就可以了： wp_deregister_script( 'l10n' ); 世界又清静了，如果你也升级到了 WordPress 3.1，那估计你的主题中也会多出那么一小段 JS，基本就是个累赘，没啥用，该删就删了吧~ 与 JS,l10n,WordPress 相关的文章 WordPress 将选中文字转发到微博 2011年10月30日 Wordpress 之欢迎 OOXX 归来 2011年01月19日 利用 JQuery 实现图片显隐特效 2010年04月8日 [...]]]></description>
			<content:encoded><![CDATA[<p>最近因为龙体欠佳，很少有关注 WordPress 的最新动态，今天趁稍微恢复一点精神看了一下 WordPress 后台，居然有 WordPress 3.1 中文版可以升级了，作为与时俱进的升级控，对自己的主题向后兼容性是绝对有信心的，果断升级！</p>
<p>还没去 WordPress 官方了解过 3.1 版本到底是个什么样的东东，只是从第一眼来看，最明显的是多了一个工具条，和我的<a title="万戈牌工具条" href="http://wange.im/wg-toolbar.html">万戈牌工具条</a>插件有异曲同工之处。但是再仔细一看，Wordpress 3.1 做了一件非常 YD + 恶心 + 无耻 + 卑鄙的事情！在给我的主题头部偷偷加上了一小段 JS！有图有真相：</p>
<p><img src="http://public.bay.livefilestore.com/y1p_5-XDCQIefGPKMONU27V-R8bPuH_Lt9a4g_HwgnED7L1wy77zQHVTFuXxTUkcACkii0AFQA9AkQEwshcvbEwiw/l10n.jpg" alt="" /></p>
<p>虽说这段脚本不大，也才0.3K 左右，但是 WordPress 的这种做法是让人不能容忍的，凭什么呀凭什么呀，哥明明没在主题里允许你的存在，非要给我多加一段 JS，作为有代码洁癖的我，怎么能容许它的存在呢，除之而后快！</p>
<p>把以下这句函数放在 WordPress 主题的 functions.php 中就可以了：</p>
<div class="source" style="font-family: 'Courier New', 'Consolas', 'Lucida Console'; color: #000000;"><span style="color: #000000;">wp_deregister_script</span>( <span style="color: #0000ff;">'l10n'</span> );</div>
<p>世界又清静了，如果你也升级到了 WordPress 3.1，那估计你的主题中也会多出那么一小段 JS，基本就是个累赘，没啥用，该删就删了吧~</p>
<div id="rl_posts">    <div id="rl_posts_hd" class="box_hd">        <span id="rl_posts_title" class="box_title">与 <h2 itemprop="keywords"><a href="http://wange.im/tag/js/" title="JS" rel="tag">JS</a>,<a href="http://wange.im/tag/l10n/" title="l10n" rel="tag">l10n</a>,<a href="http://wange.im/tag/wordpress/" title="WordPress" rel="tag">WordPress</a></h2> 相关的文章        </span>    </div>    <div id="rl_posts_bd">        <ul class="clearfix"><li>    <div class="rl_thumb"><img src="http://wange.im/wp-content/themes/wange/timthumb.php?src=http://wange.im/cache/weibo_share.jpg&amp;h=45&amp;w=45&amp;zc=1" alt="WordPress 将选中文字转发到微博" width="45" height="45" itemprop="thumbnailUrl" />    </div>    <div class="rl_title">        <a href="http://wange.im/wordpress-share-selected-text-to-weibo.html" rel="bookmark" title="WordPress 将选中文字转发到微博">WordPress 将选中文字转发到微博</a>        <div class="rl_date">2011年10月30日</div>    </div></li><li>    <div class="rl_thumb"><img src="http://wange.im/wp-content/themes/wange/imgs/category/computer.jpg" alt="电脑网络" width="45" height="45" itemprop="thumbnailUrl" />    </div>    <div class="rl_title">        <a href="http://wange.im/welcome-ooxx-back-in-wordpress.html" rel="bookmark" title="Wordpress 之欢迎 OOXX 归来">Wordpress 之欢迎 OOXX 归来</a>        <div class="rl_date">2011年01月19日</div>    </div></li><li>    <div class="rl_thumb"><img src="http://wange.im/wp-content/themes/wange/imgs/category/computer.jpg" alt="电脑网络" width="45" height="45" itemprop="thumbnailUrl" />    </div>    <div class="rl_title">        <a href="http://wange.im/fadeto-effect-with-jquery.html" rel="bookmark" title="利用 JQuery 实现图片显隐特效">利用 JQuery 实现图片显隐特效</a>        <div class="rl_date">2010年04月8日</div>    </div></li><li>    <div class="rl_thumb"><img src="http://wange.im/wp-content/themes/wange/timthumb.php?src=http://wange.im/cache/sweet-titles.jpg&amp;h=45&amp;w=45&amp;zc=1" alt="JQuery 鼠标提示特效之 Sweet Titles" width="45" height="45" itemprop="thumbnailUrl" />    </div>    <div class="rl_title">        <a href="http://wange.im/jquery-sweet-titles-tooltips.html" rel="bookmark" title="JQuery 鼠标提示特效之 Sweet Titles">JQuery 鼠标提示特效之 Sweet Titles</a>        <div class="rl_date">2010年03月14日</div>    </div></li>        </ul>    </div></div>]]></content:encoded>
			<wfw:commentRss>http://wange.im/l10n-js-in-wordpress-3-1.html/feed</wfw:commentRss>
		<slash:comments>186</slash:comments>
		</item>
		<item>
		<title>最短最给力的 IE 版本判断脚本</title>
		<link>http://wange.im/ietester-version.html</link>
		<comments>http://wange.im/ietester-version.html#comments</comments>
		<pubDate>Sat, 19 Feb 2011 15:10:05 +0000</pubDate>
		<dc:creator>万戈</dc:creator>
				<category><![CDATA[电脑网络]]></category>
		<category><![CDATA[IE]]></category>
		<category><![CDATA[Javascript]]></category>
		<category><![CDATA[JS]]></category>

		<guid isPermaLink="false">http://wange.im/?p=4559</guid>
		<description><![CDATA[随着 WEB 标准的发展，随着浏览器时代的推进，重构以及前端工作人员将会面临更多的挑战，而其中就要接受 IE 最严峻的挑战，一方面是因为 IE 的用户量还是无庸质疑的排行老大，另一方面 IE 每个版本都如同新生一般让人捉摸不定。在对网站进行开发时就不可避免地会用到 HACK 或者对各版本 IE 区别对待的特殊处理。 网上有过很多对 IE 版本进行判断的脚本，今天发现了一个最短、最给力、性价比最高的一段，甚至可以说是只有几行的脚本，可以对 IE 版本进行精确判断。当我看到这段脚本时，我震精了，眼中充满了泪花，征服 IE 指日可待了呀~ 先来看看我写的一个 DEMO，建议使用 IE 进行测试，因为对 IE 以外的浏览器无法识别（经测试，IE 5 也是辨认不出来滴，不过我相信没有哪个火星人还在用 IE5 吧？） 见证完奇迹的时刻，我们再回头来看这段代码的核心部分： var ie = (function(){     var undef,     v = 3,     div = document.createElement('div'),     all = div.getElementsByTagName('i');     while (         div.innerHTML [...]]]></description>
			<content:encoded><![CDATA[<p>随着 WEB 标准的发展，随着浏览器时代的推进，重构以及前端工作人员将会面临更多的挑战，而其中就要接受 IE 最严峻的挑战，一方面是因为 IE 的用户量还是无庸质疑的排行老大，另一方面 IE 每个版本都如同新生一般让人捉摸不定。在对网站进行开发时就不可避免地会用到 HACK 或者对各版本 IE 区别对待的特殊处理。</p>
<p>网上有过很多对 IE 版本进行判断的脚本，今天发现了一个最短、最给力、性价比最高的一段，甚至可以说是只有几行的脚本，可以对 IE 版本进行精确判断。当我看到这段脚本时，我震精了，眼中充满了泪花，征服 IE 指日可待了呀~</p>
<p>先来看看我写的一个 <a title="IE 版本测试" href="http://wange.im/demo/ietester/index.html">DEMO</a>，建议使用 IE 进行测试，因为对 IE 以外的浏览器无法识别（经测试，IE 5 也是辨认不出来滴，不过我相信没有哪个火星人还在用 IE5 吧？）</p>
<p>见证完奇迹的时刻，我们再回头来看这段代码的核心部分：</p>
<div class="source" style="font-family: 'Courier New', 'Consolas', 'Lucida Console'; color: #000000;"><span style="color: #000080; font-weight: bold;">var</span> <span style="color: #000000;">ie</span> <span style="color: #000000;">=</span> (<span style="color: #000080; font-weight: bold;">function</span><span style="color: #000000;">(){</span><br />
    <span style="color: #000080; font-weight: bold;">var</span> <span style="color: #000000;">undef</span><span style="color: #000000;">,</span><br />
    <span style="color: #000000;">v</span> <span style="color: #000000;">=</span> <span style="color: #0000ff;">3</span><span style="color: #000000;">,</span><br />
    <span style="color: #000000;">div</span> <span style="color: #000000;">=</span> <span style="color: #000000;">document</span><span style="color: #000000;">.</span><span style="color: #000000;">createElement</span>(<span style="color: #0000ff;">'div'</span><span style="color: #000000;">),</span><br />
    <span style="color: #000000;">all</span> <span style="color: #000000;">=</span> <span style="color: #000000;">div</span><span style="color: #000000;">.</span><span style="color: #000000;">getElementsByTagName</span>(<span style="color: #0000ff;">'i'</span>);<br />
    <span style="color: #000080; font-weight: bold;">while</span> (<br />
        <span style="color: #000000;">div</span><span style="color: #000000;">.</span><span style="color: #000000;">innerHTML</span> <span style="color: #000000;">=</span> <span style="color: #0000ff;">'&lt;!--[if gt IE '</span> <span style="color: #000000;">+</span> (<span style="color: #000000;">++</span><span style="color: #000000;">v</span>) <span style="color: #000000;">+</span> <span style="color: #0000ff;">']&gt;&lt;i&gt;&lt;/i&gt;&lt;![endif]--&gt;'</span><span style="color: #000000;">,</span><br />
        <span style="color: #000000;">all</span><span style="color: #000000;">[</span><span style="color: #0000ff;">0</span><span style="color: #000000;">]</span><br />
    );<br />
    <span style="color: #000080; font-weight: bold;">return</span> <span style="color: #000000;">v</span> <span style="color: #000000;">&gt;</span> <span style="color: #0000ff;">4</span> <span style="color: #000000;">?</span> <span style="color: #000000;">v</span> <span style="color: #000000;">:</span> <span style="color: #000000;">undef</span>;<br />
<span style="color: #000000;">}());</span></div>
<p>代码短的不能再短了，语法也是基础的不能再基础了，可我就是看不懂他为什么要这么写，唉，牛人自有高招，咱只有佩服的份了。</p>
<p>方法来自：<a title="最短的 IE 版本判断" rel="external nofollow" target="_blank" href="http://sofish.de/1665">最短的 IE 版本判断</a></p>
<div id="rl_posts">    <div id="rl_posts_hd" class="box_hd">        <span id="rl_posts_title" class="box_title">与 <h2 itemprop="keywords"><a href="http://wange.im/tag/ie/" title="IE" rel="tag">IE</a>,<a href="http://wange.im/tag/javascript/" title="Javascript" rel="tag">Javascript</a>,<a href="http://wange.im/tag/js/" title="JS" rel="tag">JS</a></h2> 相关的文章        </span>    </div>    <div id="rl_posts_bd">        <ul class="clearfix"><li>    <div class="rl_thumb"><img src="http://wange.im/wp-content/themes/wange/imgs/category/computer.jpg" alt="电脑网络" width="45" height="45" itemprop="thumbnailUrl" />    </div>    <div class="rl_title">        <a href="http://wange.im/jquery-js-ajax-pic.html" rel="bookmark" title="jQuery/JavaScript 实现的异步加载图片">jQuery/JavaScript 实现的异步加载图片</a>        <div class="rl_date">2011年04月10日</div>    </div></li><li>    <div class="rl_thumb"><img src="http://wange.im/wp-content/themes/wange/timthumb.php?src=http://wange.im/cache/rss2.jpg&amp;h=45&amp;w=45&amp;zc=1" alt="JQuery 鼠标滑动渐隐渐显效果" width="45" height="45" itemprop="thumbnailUrl" />    </div>    <div class="rl_title">        <a href="http://wange.im/fadein-and-fadeout-with-jquery.html" rel="bookmark" title="JQuery 鼠标滑动渐隐渐显效果">JQuery 鼠标滑动渐隐渐显效果</a>        <div class="rl_date">2010年05月5日</div>    </div></li><li>    <div class="rl_thumb"><img src="http://wange.im/wp-content/themes/wange/timthumb.php?src=http://wange.im/cache/sweet-titles.jpg&amp;h=45&amp;w=45&amp;zc=1" alt="JQuery 鼠标提示特效之 Sweet Titles" width="45" height="45" itemprop="thumbnailUrl" />    </div>    <div class="rl_title">        <a href="http://wange.im/jquery-sweet-titles-tooltips.html" rel="bookmark" title="JQuery 鼠标提示特效之 Sweet Titles">JQuery 鼠标提示特效之 Sweet Titles</a>        <div class="rl_date">2010年03月14日</div>    </div></li><li>    <div class="rl_thumb"><img src="http://wange.im/wp-content/themes/wange/imgs/category/computer.jpg" alt="电脑网络" width="45" height="45" itemprop="thumbnailUrl" />    </div>    <div class="rl_title">        <a href="http://wange.im/html-to-javascript.html" rel="bookmark" title="HTML 转换到 Javascript（附源码）">HTML 转换到 Javascript（附源码）</a>        <div class="rl_date">2010年03月11日</div>    </div></li>        </ul>    </div></div>]]></content:encoded>
			<wfw:commentRss>http://wange.im/ietester-version.html/feed</wfw:commentRss>
		<slash:comments>117</slash:comments>
		</item>
		<item>
		<title>WordPress 之欢迎 OOXX 归来</title>
		<link>http://wange.im/welcome-ooxx-back-in-wordpress.html</link>
		<comments>http://wange.im/welcome-ooxx-back-in-wordpress.html#comments</comments>
		<pubDate>Wed, 19 Jan 2011 13:28:14 +0000</pubDate>
		<dc:creator>万戈</dc:creator>
				<category><![CDATA[电脑网络]]></category>
		<category><![CDATA[JS]]></category>
		<category><![CDATA[WordPress]]></category>
		<category><![CDATA[留言]]></category>

		<guid isPermaLink="false">http://wange.im/?p=4381</guid>
		<description><![CDATA[已经有童鞋在迫不急待地抽我的筋扒我的皮了，当然我是指现在这个 WordPress 主题，但是要知道有些东东是无法靠 HTML 和 CSS 就能照搬的，不过这个学习的精神很是可贵。今天又有童鞋问我了，这个 title 标题栏的：OOXX，欢迎归来~这是怎么实现的（只有留过言的小盆友才会看见哟~）这招其实很简单，就是利用 Cookie 来记录的评论者信息，应该已经有很多朋友用上了，但还是会有人来问这个问题，既然这样，就单独写一篇来分享一下这个功能吧。 把以下代码放到你 WordPress 主题的 header.php 或者 footer.php 文件中去就可以了： &#60;?php if($_COOKIE["comment_author_" . COOKIEHASH]!="") { ?&#62;     &#60;script type="text/javascript"&#62;document.title = "&#60;?php echo $_COOKIE["comment_author_" . COOKIEHASH].'，欢迎归来~'; ?&#62;" + document.title&#60;/script&#62; &#60;?php } ?&#62; 有几点需要申明一下： 首先有人质疑过这个功能对 SEO 的影响，把 title 都改了？会不会影响收录什么的呢？我可以以“万戈牌”的名誉作担保，这个质疑是多余的，因为我们可以看到被输出的文字是被套在 script 里的，一个 JS 的脚本是无法被搜索爬虫识别的。 另外，这个效果只有在你留过言的前提下再刷新页面才能看到，因为需要浏览器记录你的 Cookie 信息，首次登门的朋友不妨先留言试试。 再另外，这个方法是所有主题通用的，请大家不要再特地发Q和我说加你这段代码进去主题就崩溃了啥啥啥的，给 WordPress 初学者几个建议：第一，修改任何代码前请记得备份；第二，先不要怀疑别人的代码，先检查一下代码放置的位置有没有错；第三，学会独立思考。 [...]]]></description>
			<content:encoded><![CDATA[<p>已经有童鞋在迫不急待地抽我的筋扒我的皮了，当然我是指现在这个 WordPress 主题，但是要知道有些东东是无法靠 HTML 和 CSS 就能照搬的，不过这个学习的精神很是可贵。今天又有童鞋问我了，这个 title 标题栏的：OOXX，欢迎归来~这是怎么实现的（只有留过言的小盆友才会看见哟~）这招其实很简单，就是利用 Cookie 来记录的评论者信息，应该已经有很多朋友用上了，但还是会有人来问这个问题，既然这样，就单独写一篇来分享一下这个功能吧。</p>
<p>把以下代码放到你 WordPress 主题的 header.php 或者 footer.php 文件中去就可以了：</p>
<div class="source" style="font-family: 'Courier New', 'Consolas', 'Lucida Console'; color: #000000;"><span style="color: #008080;">&lt;?php</span> <span style="color: #000080; font-weight: bold;">if</span>(<span style="color: #000000;">$_COOKIE</span><span style="color: #000000;">[</span><span style="color: #0000ff;">"comment_author_"</span> <span style="color: #000000;">.</span> <span style="color: #000000;">COOKIEHASH</span><span style="color: #000000;">]</span><span style="color: #000000;">!=</span><span style="color: #0000ff;">""</span>) <span style="color: #000000;">{</span> <span style="color: #008080;">?&gt;</span><br />
    <span style="color: #000080; font-weight: bold;">&lt;script </span><span style="color: #ff0000;">type=</span><span style="color: #0000ff;">"text/javascript"</span><span style="color: #000080; font-weight: bold;">&gt;</span><span style="color: #000000;">document</span><span style="color: #000000;">.</span><span style="color: #000000;">title</span> <span style="color: #000000;">=</span> <span style="color: #0000ff;">"</span><span style="color: #008080;">&lt;?php</span> <span style="color: #000080; font-weight: bold;">echo</span> <span style="color: #000000;">$_COOKIE</span><span style="color: #000000;">[</span><span style="color: #0000ff;">"comment_author_"</span> <span style="color: #000000;">.</span> <span style="color: #000000;">COOKIEHASH</span><span style="color: #000000;">]</span><span style="color: #000000;">.</span><span style="color: #0000ff;">'，欢迎归来~'</span>; <span style="color: #008080;">?&gt;</span><span style="color: #0000ff;">"</span> <span style="color: #000000;">+</span> <span style="color: #000000;">document</span><span style="color: #000000;">.</span><span style="color: #000000;">title</span><span style="color: #000080; font-weight: bold;">&lt;/script&gt;</span><br />
<span style="color: #008080;">&lt;?php</span> <span style="color: #000000;">}</span> <span style="color: #008080;">?&gt;</span></div>
<p>有几点需要申明一下：</p>
<p>首先有人质疑过这个功能对 SEO 的影响，把 title 都改了？会不会影响收录什么的呢？我可以以“万戈牌”的名誉作担保，这个质疑是多余的，因为我们可以看到被输出的文字是被套在 script 里的，一个 JS 的脚本是无法被搜索爬虫识别的。</p>
<p>另外，这个效果只有在你留过言的前提下再刷新页面才能看到，因为需要浏览器记录你的 Cookie 信息，首次登门的朋友不妨先留言试试。</p>
<p>再另外，这个方法是所有主题通用的，请大家不要再特地发Q和我说加你这段代码进去主题就崩溃了啥啥啥的，给 WordPress 初学者几个建议：第一，修改任何代码前请记得备份；第二，先不要怀疑别人的代码，先检查一下代码放置的位置有没有错；第三，学会独立思考。</p>
<p>再再另外，因为这个方法年代久远，我也忘记是从哪里学来的了，有哪位知道请给个链接吧。</p>
<p>今天就到这里吧，事情堆起来了，干活去~~~</p>
<div id="rl_posts">    <div id="rl_posts_hd" class="box_hd">        <span id="rl_posts_title" class="box_title">与 <h2 itemprop="keywords"><a href="http://wange.im/tag/js/" title="JS" rel="tag">JS</a>,<a href="http://wange.im/tag/wordpress/" title="WordPress" rel="tag">WordPress</a>,<a href="http://wange.im/tag/leave-word/" title="留言" rel="tag">留言</a></h2> 相关的文章        </span>    </div>    <div id="rl_posts_bd">        <ul class="clearfix"><li>    <div class="rl_thumb"><img src="http://wange.im/wp-content/themes/wange/imgs/category/computer.jpg" alt="电脑网络" width="45" height="45" itemprop="thumbnailUrl" />    </div>    <div class="rl_title">        <a href="http://wange.im/hide-visitor-info-in-wordpress.html" rel="bookmark" title="记录并隐藏 Wordpress 评论者信息">记录并隐藏 Wordpress 评论者信息</a>        <div class="rl_date">2009年12月6日</div>    </div></li><li>    <div class="rl_thumb"><img src="http://wange.im/wp-content/themes/wange/imgs/category/computer.jpg" alt="电脑网络" width="45" height="45" itemprop="thumbnailUrl" />    </div>    <div class="rl_title">        <a href="http://wange.im/wordpress-comment-author-link-open-in-new-window.html" rel="bookmark" title="在新窗口中打开 Wordpress 评论者链接">在新窗口中打开 Wordpress 评论者链接</a>        <div class="rl_date">2009年11月1日</div>    </div></li><li>    <div class="rl_thumb"><img src="http://wange.im/wp-content/themes/wange/timthumb.php?src=http://wange.im/cache/weibo_share.jpg&amp;h=45&amp;w=45&amp;zc=1" alt="WordPress 将选中文字转发到微博" width="45" height="45" itemprop="thumbnailUrl" />    </div>    <div class="rl_title">        <a href="http://wange.im/wordpress-share-selected-text-to-weibo.html" rel="bookmark" title="WordPress 将选中文字转发到微博">WordPress 将选中文字转发到微博</a>        <div class="rl_date">2011年10月30日</div>    </div></li><li>    <div class="rl_thumb"><img src="http://wange.im/wp-content/themes/wange/timthumb.php?src=http://wange.im/cache/l10n.jpg&amp;h=45&amp;w=45&amp;zc=1" alt="Wordpress 3.1 偷偷挂载 l10n.js 脚本！" width="45" height="45" itemprop="thumbnailUrl" />    </div>    <div class="rl_title">        <a href="http://wange.im/l10n-js-in-wordpress-3-1.html" rel="bookmark" title="Wordpress 3.1 偷偷挂载 l10n.js 脚本！">Wordpress 3.1 偷偷挂载 l10n.js 脚本！</a>        <div class="rl_date">2011年02月24日</div>    </div></li>        </ul>    </div></div>]]></content:encoded>
			<wfw:commentRss>http://wange.im/welcome-ooxx-back-in-wordpress.html/feed</wfw:commentRss>
		<slash:comments>183</slash:comments>
		</item>
		<item>
		<title>精简版的 LavaLamp JQuery 滑动导航</title>
		<link>http://wange.im/lavalamp-for-jquery.html</link>
		<comments>http://wange.im/lavalamp-for-jquery.html#comments</comments>
		<pubDate>Sun, 06 Jun 2010 13:49:59 +0000</pubDate>
		<dc:creator>万戈</dc:creator>
				<category><![CDATA[电脑网络]]></category>
		<category><![CDATA[jQuery]]></category>
		<category><![CDATA[JS]]></category>
		<category><![CDATA[LavaLamp]]></category>
		<category><![CDATA[菜单]]></category>

		<guid isPermaLink="false">http://wange.im/?p=3223</guid>
		<description><![CDATA[本来是在做 WordPress 主题的，做着做着就想给主题的导航加一个 JQuery 的滑动效果，很久没有折腾 JQuery 了，今天有点手痒痒，于是就深入折腾了一下。用 JQuery 实现的动感导航效果有很多，我之前就介绍过一个，也就是我这个主题正在使用的导航效果，本来想用著名的 LavaLamp 的滑动导航，但是因为 LavaLamp 的代码过于冗长，除了一个 JQuery 库，还需要另外两个脚本再加一段 JQuery 的执行文件，对于小站来说太奢侈了一些。 于是今天又折腾了一个精简版的 LavaLamp 滑动导航效果，为什么说是精简版呢？因为这个滑动效果同样也是用 JQuery 库，不过这个精简版的 LavaLamp 仅需要几行执行脚本，再加上一些样式就可以实现了，同样可以完美支持 IE、Firefox、Chrome 等主流浏览器，其效果和完整版的 LavaLamp 可以媲美。 先看一下这两个 LavaLamp 的对比效果吧： 完整版的 LavaLamp 效果 DEMO：http://www.gmarwaha.com/blog/2007/08/23/lavalamp-for-jquery-lovers/ 精简版的 LavaLamp 效果 DEMO：http://wange.im/demo/lavalamp/ 精简版 LavaLamp 实现方法： 一、HTML 部分 &#60;ul class="navipages" id="lavalamp"&#62;     &#60;li class="current"&#62;&#60;a href="#"&#62;分类一&#60;/a&#62;&#60;/li&#62;     &#60;li&#62;&#60;a href="#"&#62;分类二&#60;/a&#62;&#60;/li&#62;     [...]]]></description>
			<content:encoded><![CDATA[<p>本来是在做 WordPress 主题的，做着做着就想给主题的导航加一个 JQuery 的滑动效果，很久没有折腾 JQuery 了，今天有点手痒痒，于是就深入折腾了一下。<a title="JQuery 实现动感导航菜单" href="http://wange.im/animated-menu-using-jquery.html">用 JQuery 实现的动感导航效果</a>有很多，我之前就介绍过一个，也就是我这个主题正在使用的导航效果，本来想用著名的 LavaLamp 的滑动导航，但是因为 LavaLamp 的代码过于冗长，除了一个 JQuery 库，还需要另外两个脚本再加一段 JQuery 的执行文件，对于小站来说太奢侈了一些。</p>
<p>于是今天又折腾了一个精简版的 LavaLamp 滑动导航效果，为什么说是精简版呢？因为这个滑动效果同样也是用 JQuery 库，不过这个精简版的 LavaLamp 仅需要几行执行脚本，再加上一些样式就可以实现了，同样可以完美支持 IE、Firefox、Chrome 等主流浏览器，其效果和完整版的 LavaLamp 可以媲美。</p>
<p>先看一下这两个 LavaLamp 的对比效果吧：</p>
<p>完整版的 LavaLamp 效果 DEMO：<a title="完整版 LavaLamp" href="http://www.gmarwaha.com/blog/2007/08/23/lavalamp-for-jquery-lovers/" target="_blank">http://www.gmarwaha.com/blog/2007/08/23/lavalamp-for-jquery-lovers/</a></p>
<p>精简版的 LavaLamp 效果 DEMO：<a title="精简版 LavaLamp" href="http://wange.im/demo/lavalamp/">http://wange.im/demo/lavalamp/</a></p>
<p>精简版 LavaLamp 实现方法：</p>
<p><strong>一、HTML 部分</strong></p>
<div class="source" style="font-family: 'Courier New','Lucida Console','monospace'; color: #000000;"><span style="color: #000080; font-weight: bold;">&lt;ul</span> <span style="color: #ff0000;">class=</span><span style="color: #0000ff;">"navipages"</span> <span style="color: #ff0000;">id=</span><span style="color: #0000ff;">"lavalamp"</span><span style="color: #000080; font-weight: bold;">&gt;</span><br />
    <span style="color: #000080; font-weight: bold;">&lt;li</span> <span style="color: #ff0000;">class=</span><span style="color: #0000ff;">"current"</span><span style="color: #000080; font-weight: bold;">&gt;&lt;a</span> <span style="color: #ff0000;">href=</span><span style="color: #0000ff;">"#"</span><span style="color: #000080; font-weight: bold;">&gt;</span><span style="color: #000000;">分类一</span><span style="color: #000080; font-weight: bold;">&lt;/a&gt;&lt;/li&gt;</span><br />
    <span style="color: #000080; font-weight: bold;">&lt;li&gt;&lt;a</span> <span style="color: #ff0000;">href=</span><span style="color: #0000ff;">"#"</span><span style="color: #000080; font-weight: bold;">&gt;</span><span style="color: #000000;">分类二</span><span style="color: #000080; font-weight: bold;">&lt;/a&gt;&lt;/li&gt;</span><br />
    <span style="color: #000080; font-weight: bold;">&lt;li&gt;&lt;a</span> <span style="color: #ff0000;">href=</span><span style="color: #0000ff;">"#"</span><span style="color: #000080; font-weight: bold;">&gt;</span><span style="color: #000000;">分类三</span><span style="color: #000080; font-weight: bold;">&lt;/a&gt;&lt;/li&gt;</span><br />
    <span style="color: #000080; font-weight: bold;">&lt;li&gt;&lt;a</span> <span style="color: #ff0000;">href=</span><span style="color: #0000ff;">"#"</span><span style="color: #000080; font-weight: bold;">&gt;</span><span style="color: #000000;">分类四</span><span style="color: #000080; font-weight: bold;">&lt;/a&gt;&lt;/li&gt;</span><br />
<span style="color: #000080; font-weight: bold;">&lt;/ul&gt;</span></div>
<p><strong>二、引入 JQuery</strong></p>
<p>这里和完整版的 LavaLamp 有些不同，完整版的 LavaLamp 仅简 JQuery 1.2X 就可以了，而我这里的精简版 LavaLamp 必须 JQuery 1.3X 才行。这里我就以 Google 的 JQuery 库为例了：</p>
<div class="source" style="font-family: 'Courier New', 'Lucida Console', 'monospace'; color: #000000;"><span style="color: #000080; font-weight: bold;">&lt;script </span><span style="color: #ff0000;">type=</span><span style="color: #0000ff;">"text/javascript"</span> <span style="color: #ff0000;">src=</span><span style="color: #0000ff;">"http://ajax.googleapis.com/ajax/libs/jquery/1.4/jquery.min.js?ver=1.3.2"</span><span style="color: #000080; font-weight: bold;">&gt;&lt;/script&gt;</span></div>
<p><strong>三、执行脚本部分</strong></p>
<div class="source" style="font-family: 'Courier New', 'Lucida Console', 'monospace'; color: #000000;"><span style="color: #000000;">$</span>(<span style="color: #000080; font-weight: bold;">function</span><span style="color: #000000;">(){</span><br />
    <span style="color: #000080; font-weight: bold;">var</span> <span style="color: #000000;">$el</span><span style="color: #000000;">,</span> <span style="color: #000000;">leftPos</span><span style="color: #000000;">,</span> <span style="color: #000000;">newWidth</span><span style="color: #000000;">,</span><br />
    <span style="color: #000000;">$mainNav</span> <span style="color: #000000;">=</span> <span style="color: #000000;">$</span>(<span style="color: #0000ff;">"#lavalamp"</span>);<br />
    <span style="color: #000000;">$mainNav</span><span style="color: #000000;">.</span><span style="color: #000000;">append</span>(<span style="color: #0000ff;">"&lt;li id='lavalampbg'&gt;&lt;/li&gt;"</span>);<br />
    <span style="color: #000080; font-weight: bold;">var</span> <span style="color: #000000;">$magicLine</span> <span style="color: #000000;">=</span> <span style="color: #000000;">$</span>(<span style="color: #0000ff;">"#lavalampbg"</span>);<br />
    <span style="color: #000000;">$magicLine</span><br />
        <span style="color: #000000;">.</span><span style="color: #000000;">css</span>(<span style="color: #0000ff;">"left"</span><span style="color: #000000;">,</span> <span style="color: #000000;">$</span>(<span style="color: #0000ff;">".current a"</span><span style="color: #000000;">).</span><span style="color: #000000;">position</span><span style="color: #000000;">().</span><span style="color: #000000;">left</span>)<br />
        <span style="color: #000000;">.</span><span style="color: #000000;">data</span>(<span style="color: #0000ff;">"origLeft"</span><span style="color: #000000;">,</span> <span style="color: #000000;">$</span>(<span style="color: #0000ff;">".current a"</span><span style="color: #000000;">).</span><span style="color: #000000;">position</span><span style="color: #000000;">().</span><span style="color: #000000;">left</span>)               <br />
    <span style="color: #000000;">$</span>(<span style="color: #0000ff;">"#lavalamp li"</span><span style="color: #000000;">).</span><span style="color: #000000;">find</span>(<span style="color: #0000ff;">"a"</span><span style="color: #000000;">).</span><span style="color: #000000;">hover</span>(<span style="color: #000080; font-weight: bold;">function</span>() <span style="color: #000000;">{</span><br />
        <span style="color: #000000;">$el</span> <span style="color: #000000;">=</span> <span style="color: #000000;">$</span>(<span style="color: #000080; font-weight: bold;">this</span>);<br />
        <span style="color: #000000;">leftPos</span> <span style="color: #000000;">=</span> <span style="color: #000000;">$el</span><span style="color: #000000;">.</span><span style="color: #000000;">position</span><span style="color: #000000;">().</span><span style="color: #000000;">left</span>;<br />
        <span style="color: #000000;">$magicLine</span><span style="color: #000000;">.</span><span style="color: #000000;">stop</span><span style="color: #000000;">().</span><span style="color: #000000;">animate</span><span style="color: #000000;">({</span><br />
          <span style="color: #000000;">left</span><span style="color: #000000;">:</span> <span style="color: #000000;">leftPos</span><br />
        <span style="color: #000000;">})</span><br />
    <span style="color: #000000;">},</span> <span style="color: #000080; font-weight: bold;">function</span>() <span style="color: #000000;">{</span><br />
        <span style="color: #000000;">$magicLine</span><span style="color: #000000;">.</span><span style="color: #000000;">stop</span><span style="color: #000000;">().</span><span style="color: #000000;">animate</span><span style="color: #000000;">({</span><br />
            <span style="color: #000000;">left</span><span style="color: #000000;">:</span> <span style="color: #000000;">$magicLine</span><span style="color: #000000;">.</span><span style="color: #000000;">data</span>(<span style="color: #0000ff;">"origLeft"</span>)<br />
        <span style="color: #000000;">});</span>   <br />
    <span style="color: #000000;">});</span><br />
<span style="color: #000000;">});</span></div>
<p><strong>四、样式部分</strong></p>
<div class="source" style="font-family: 'Courier New', 'Lucida Console', 'monospace'; color: #000000;"><span style="color: #000000;">.navipages</span><span style="color: #000000;">:after</span> <span style="color: #000000;">{</span><span style="color: #000080; font-weight: bold;">visibility</span><span style="color: #000000;">:</span><span style="color: #000080; font-weight: bold;">hidden</span>;<span style="color: #000080; font-weight: bold;">display</span><span style="color: #000000;">:</span><span style="color: #000080; font-weight: bold;">block</span><span style="color: #000000;">;}</span><br />
<span style="color: #000000;">*</span><span style="color: #000000;">:first-child</span><span style="color: #000000;">+</span><span style="color: #000080; font-weight: bold;">html</span> <span style="color: #000000;">.navipages</span> <span style="color: #000000;">{</span><span style="color: #000000;">zoom</span><span style="color: #000000;">:</span><span style="color: #0000ff;">1</span><span style="color: #000000;">;}</span> <span style="font-style: italic; color: #008800;">/* IE7 */</span><br />
<span style="color: #000000;">#lavalamp</span> <span style="color: #000080; font-weight: bold;">li</span> <span style="color: #000000;">{</span><span style="color: #000080; font-weight: bold;">display</span><span style="color: #000000;">:</span><span style="color: #000080; font-weight: bold;">inline</span><span style="color: #000000;">;}</span><br />
<span style="color: #000000;">#lavalamp</span> <span style="color: #000080; font-weight: bold;">li</span> <span style="color: #000080; font-weight: bold;">a</span> <span style="color: #000000;">{</span><span style="color: #000080; font-weight: bold;">width</span><span style="color: #000000;">:</span><span style="color: #0000ff;">90px</span>;<span style="color: #000080; font-weight: bold;">display</span><span style="color: #000000;">:</span><span style="color: #000080; font-weight: bold;">block</span>;<span style="color: #000080; font-weight: bold;">float</span><span style="color: #000000;">:</span><span style="color: #000080; font-weight: bold;">left</span>;<span style="color: #000080; font-weight: bold;">text-align</span><span style="color: #000000;">:</span><span style="color: #000080; font-weight: bold;">center</span>;<span style="color: #000080; font-weight: bold;">position</span><span style="color: #000000;">:</span><span style="color: #000080; font-weight: bold;">relative</span>;<span style="color: #000080; font-weight: bold;">z-index</span><span style="color: #000000;">:</span><span style="color: #0000ff;">200</span><span style="color: #000000;">;}</span><br />
<span style="color: #000000;">#lavalamp</span> <span style="color: #000080; font-weight: bold;">li</span> <span style="color: #000080; font-weight: bold;">a</span><span style="color: #000000;">:hover</span> <span style="color: #000000;">{</span><span style="color: #000080; font-weight: bold;">color</span><span style="color: #000000;">:</span><span style="color: #000000;">white</span><span style="color: #000000;">;}</span><br />
<span style="color: #000000;">#lavalamp</span> <span style="color: #000000;">#lavalampbg</span> <span style="color: #000000;">{</span><span style="color: #000080; font-weight: bold;">width</span><span style="color: #000000;">:</span><span style="color: #0000ff;">90px</span>;<span style="color: #000080; font-weight: bold;">height</span><span style="color: #000000;">:</span><span style="color: #0000ff;">25px</span>;<span style="color: #000080; font-weight: bold;">position</span><span style="color: #000000;">:</span><span style="color: #000080; font-weight: bold;">absolute</span>;<span style="color: #000080; font-weight: bold;">top</span><span style="color: #000000;">:</span><span style="color: #0000ff;">10px</span>;<span style="color: #000080; font-weight: bold;">left</span><span style="color: #000000;">:</span><span style="color: #0000ff;">0</span>;<span style="color: #000080; font-weight: bold;">background</span><span style="color: #000000;">:</span><span style="color: #0000ff;">#D90018</span>;<span style="color: #000080; font-weight: bold;">z-index</span><span style="color: #000000;">:</span><span style="color: #0000ff;">100</span><span style="color: #000000;">;}</span></div>
<p>这样就 OK 了，比完整版的 LavaLamp 可要简单很多吧，不过相比完整版的 LavaLamp 而言还有一点不足，对于每个 li 元素的宽度是固定的，没有完整版的 LavaLamp 那样可以长短伸缩灵活，大家就各取所需吧。</p>
<div id="rl_posts">    <div id="rl_posts_hd" class="box_hd">        <span id="rl_posts_title" class="box_title">与 <h2 itemprop="keywords"><a href="http://wange.im/tag/jquery/" title="jQuery" rel="tag">jQuery</a>,<a href="http://wange.im/tag/js/" title="JS" rel="tag">JS</a>,<a href="http://wange.im/tag/lavalamp/" title="LavaLamp" rel="tag">LavaLamp</a>,<a href="http://wange.im/tag/menu/" title="菜单" rel="tag">菜单</a></h2> 相关的文章        </span>    </div>    <div id="rl_posts_bd">        <ul class="clearfix"><li>    <div class="rl_thumb"><img src="http://wange.im/wp-content/themes/wange/imgs/category/computer.jpg" alt="电脑网络" width="45" height="45" itemprop="thumbnailUrl" />    </div>    <div class="rl_title">        <a href="http://wange.im/animated-menu-using-jquery.html" rel="bookmark" title="JQuery 实现动感导航菜单">JQuery 实现动感导航菜单</a>        <div class="rl_date">2010年02月25日</div>    </div></li><li>    <div class="rl_thumb"><img src="http://wange.im/wp-content/themes/wange/imgs/category/computer.jpg" alt="电脑网络" width="45" height="45" itemprop="thumbnailUrl" />    </div>    <div class="rl_title">        <a href="http://wange.im/jquery-js-ajax-pic.html" rel="bookmark" title="jQuery/JavaScript 实现的异步加载图片">jQuery/JavaScript 实现的异步加载图片</a>        <div class="rl_date">2011年04月10日</div>    </div></li><li>    <div class="rl_thumb"><img src="http://wange.im/wp-content/themes/wange/imgs/category/computer.jpg" alt="电脑网络" width="45" height="45" itemprop="thumbnailUrl" />    </div>    <div class="rl_title">        <a href="http://wange.im/delay-effect-in-jquery.html" rel="bookmark" title="关于 jQuery 中的事件延时执行">关于 jQuery 中的事件延时执行</a>        <div class="rl_date">2011年01月30日</div>    </div></li><li>    <div class="rl_thumb"><img src="http://wange.im/wp-content/themes/wange/timthumb.php?src=http://wange.im/cache/sub-menu.jpg&amp;h=45&amp;w=45&amp;zc=1" alt="WordPress 3.0 菜单功能支持二级菜单" width="45" height="45" itemprop="thumbnailUrl" />    </div>    <div class="rl_title">        <a href="http://wange.im/sub-menu-in-wordpress-3.html" rel="bookmark" title="WordPress 3.0 菜单功能支持二级菜单">WordPress 3.0 菜单功能支持二级菜单</a>        <div class="rl_date">2010年08月29日</div>    </div></li>        </ul>    </div></div>]]></content:encoded>
			<wfw:commentRss>http://wange.im/lavalamp-for-jquery.html/feed</wfw:commentRss>
		<slash:comments>131</slash:comments>
		</item>
		<item>
		<title>JQuery 鼠标滑动渐隐渐显效果</title>
		<link>http://wange.im/fadein-and-fadeout-with-jquery.html</link>
		<comments>http://wange.im/fadein-and-fadeout-with-jquery.html#comments</comments>
		<pubDate>Wed, 05 May 2010 13:27:31 +0000</pubDate>
		<dc:creator>万戈</dc:creator>
				<category><![CDATA[电脑网络]]></category>
		<category><![CDATA[Javascript]]></category>
		<category><![CDATA[jQuery]]></category>
		<category><![CDATA[JS]]></category>

		<guid isPermaLink="false">http://wange.im/?p=3090</guid>
		<description><![CDATA[最近我工作以外的生活就是围绕着 WordPress 新主题转了，是和尘埃老哥合作的主题，雏形已经做出来了，有好奇心的朋友可以去尘埃的网站一睹为快，这是给尘埃定制的主题，所以主题的名字就由他给起了，PRChina，是一款以红色为主色调的主题。因为刚刚搭好布局，还有很多功能没有完善，自己看着都不是很满意。 尘埃的网站是以图片分享为主题的，所以为了整站的加载速度，预载了 JQuery 的 lazyload，既然已经用上了 JQuery，不多用两个，就显得浪费了。尘埃也是这么认为的，所以还打算给导航部分加个 JQuery 的效果。说到导航部分的 JQuery 效果，我最先想到的就是著名的 lavalamp，不过 MS 要改动的 HTML 和 CSS 都比较多，我又实在懒得大规模修改了，于是我又想到了另一个效果，也就是我现在头部 RSS 订阅部分用到的渐隐渐显的效果，当然，这也是 JQuery，而且不需要另外加载 lavalamp 插件，应该说是精简不少，效果也很显著。 我就先写一下这个渐隐渐显的 JQuery RSS 展示的方法吧，之后再移植到新主题上去。话说这是从某个高手的网站上借鉴来的，不过用的太久，出处早就忘了，向作者说声抱歉啦～ 1.加载 JQuery 这个已经说过很多次了吧，可以用 google 的 JQuery 库，又或者是调用自己本地的 JQuery，经测试 JQuery 1.2x 版本就足够了。 &#60;script type="text/javascript" src="http://jqueryjs.googlecode.com/files/jquery-1.2.3.min.js"&#62;&#60;/script&#62; 2.HTML 部分 &#60;div id="rss"&#62;     &#60;a id="rssurl" href="http://feed.wange.im" target="_blank"&#62;&#60;/a&#62;     &#60;div id="rsstip"&#62;     请点击右上角的 [...]]]></description>
			<content:encoded><![CDATA[<p>最近我工作以外的生活就是围绕着 WordPress 新主题转了，是和尘埃老哥合作的主题，雏形已经做出来了，有好奇心的朋友可以去<a title="尘埃" href="http://www.dustmedia.net/" target="_blank">尘埃</a>的网站一睹为快，这是给尘埃定制的主题，所以主题的名字就由他给起了，PRChina，是一款以红色为主色调的主题。因为刚刚搭好布局，还有很多功能没有完善，自己看着都不是很满意。</p>
<p>尘埃的网站是以图片分享为主题的，所以为了整站的加载速度，预载了 JQuery 的 lazyload，既然已经用上了 JQuery，不多用两个，就显得浪费了。尘埃也是这么认为的，所以还打算给导航部分加个 JQuery 的效果。说到导航部分的 JQuery 效果，我最先想到的就是著名的 lavalamp，不过 MS 要改动的 HTML 和 CSS 都比较多，我又实在懒得大规模修改了，于是我又想到了另一个效果，也就是我现在头部 RSS 订阅部分用到的渐隐渐显的效果，当然，这也是 JQuery，而且不需要另外加载 lavalamp 插件，应该说是精简不少，效果也很显著。</p>
<p>我就先写一下这个渐隐渐显的 JQuery RSS 展示的方法吧，之后再移植到新主题上去。话说这是从某个高手的网站上借鉴来的，不过用的太久，出处早就忘了，向作者说声抱歉啦～</p>
<p><img src="http://public.bay.livefilestore.com/y1piHH3TAQ7vmsCFcncRqFotvzSA61g8xmJE5g3XSchWTIP7eD2eoeMmiHWGirqJ5JD62RrzSdUcFtTVfUTaov-HA/rss1.jpg" alt="" /><img src="http://public.bay.livefilestore.com/y1p2NgzaFEcpvCyH0KtjGwJJPnoVdBOlo_WJO7B9CQDAU7stLl0Z7mynEkONHSOHF49m16JiF5PhglRmc0z4BRe6w/rss2.jpg" alt="" /></p>
<p><strong>1.加载 JQuery</strong></p>
<p>这个已经说过很多次了吧，可以用 google 的 JQuery 库，又或者是调用自己本地的 JQuery，经测试 JQuery 1.2x 版本就足够了。</p>
<div class="source" style="font-family: 'Courier New','Lucida Console','monospace'; color: #000000;"><span style="color: #000080; font-weight: bold;">&lt;script </span><span style="color: #ff0000;">type=</span><span style="color: #0000ff;">"text/javascript"</span> <span style="color: #ff0000;">src=</span><span style="color: #0000ff;">"http://jqueryjs.googlecode.com/files/jquery-1.2.3.min.js"</span><span style="color: #000080; font-weight: bold;">&gt;&lt;/script&gt;</span></div>
<p><strong>2.HTML 部分</strong></p>
<div class="source" style="font-family: 'Courier New','Lucida Console','monospace'; color: #000000;"><span style="color: #000000;">&lt;</span><span style="color: #000080; font-weight: bold;">div</span> <span style="color: #000080; font-weight: bold;">id</span><span style="color: #000000;">=</span><span style="color: #0000ff;">"rss"</span><span style="color: #000000;">&gt;</span><br />
    <span style="color: #000000;">&lt;</span><span style="color: #000080; font-weight: bold;">a</span> <span style="color: #000080; font-weight: bold;">id</span><span style="color: #000000;">=</span><span style="color: #0000ff;">"rssurl"</span> <span style="color: #000080; font-weight: bold;">href</span><span style="color: #000000;">=</span><span style="color: #0000ff;">"http://feed.wange.im"</span> <span style="color: #000080; font-weight: bold;">target</span><span style="color: #000000;">=</span><span style="color: #0000ff;">"_blank"</span><span style="color: #000000;">&gt;&lt;/</span><span style="color: #000080; font-weight: bold;">a</span><span style="color: #000000;">&gt;</span><br />
    <span style="color: #000000;">&lt;</span><span style="color: #000080; font-weight: bold;">div</span> <span style="color: #000080; font-weight: bold;">id</span><span style="color: #000000;">=</span><span style="color: #0000ff;">"rsstip"</span><span style="color: #000000;">&gt;</span><br />
    请点击右上角的 RSS 按钮并选择适合您的订阅方式～<br />
    <span style="color: #000000;">&lt;/</span><span style="color: #000080; font-weight: bold;">div</span><span style="color: #000000;">&gt;</span><br />
<span style="color: #000000;">&lt;/</span><span style="color: #000080; font-weight: bold;">div</span><span style="color: #000000;">&gt;</span></div>
<p><strong>3.CSS 部分</strong></p>
<p>这里可以自由发挥，唯一需要注意的是，要给 #rsstip 加入 display:none; 的属性，意思就是默认隐藏提示文字，鼠标移动上之后才渐显出来，也就是下一步。</p>
<p><strong>4.JS 执行代码</strong></p>
<div class="source" style="font-family: 'Courier New','Lucida Console','monospace'; color: #000000;"><span style="color: #000000;">$</span>(<span style="color: #000080; font-weight: bold;">function</span>() <span style="color: #000000;">{</span><br />
    <span style="color: #000000;">$</span>(<span style="color: #0000ff;">'#rssurl,#rsstip'</span><span style="color: #000000;">).</span><span style="color: #000000;">mouseover</span>(<span style="color: #000080; font-weight: bold;">function</span>() <span style="color: #000000;">{</span><br />
        <span style="color: #000080; font-weight: bold;">if</span> (<span style="color: #000000;">window</span><span style="color: #000000;">.</span><span style="color: #000000;">willhide</span>) <span style="color: #000000;">clearTimeout</span>(<span style="color: #000000;">window</span><span style="color: #000000;">.</span><span style="color: #000000;">willhide</span>);<br />
        <span style="color: #000000;">$</span>(<span style="color: #0000ff;">'#rsstip'</span><span style="color: #000000;">).</span><span style="color: #000000;">fadeIn</span>(<span style="color: #0000ff;">500</span>)<br />
    <span style="color: #000000;">});</span><br />
    <span style="color: #000000;">$</span>(<span style="color: #0000ff;">'#rssurl,#rsstip'</span><span style="color: #000000;">).</span><span style="color: #000000;">mouseout</span>(<span style="color: #000080; font-weight: bold;">function</span>() <span style="color: #000000;">{</span><br />
        <span style="color: #000000;">window</span><span style="color: #000000;">.</span><span style="color: #000000;">willhide</span> <span style="color: #000000;">=</span> <span style="color: #000000;">setTimeout</span>(<span style="color: #000080; font-weight: bold;">function</span>() <span style="color: #000000;">{</span><br />
            <span style="color: #000000;">$</span>(<span style="color: #0000ff;">'#rsstip'</span><span style="color: #000000;">).</span><span style="color: #000000;">fadeOut</span>(<span style="color: #0000ff;">500</span>)<br />
        <span style="color: #000000;">},</span><br />
        <span style="color: #0000ff;">750</span>)<br />
    <span style="color: #000000;">});</span><br />
<span style="color: #000000;">});</span></div>
<p>这个也没啥好说的，唯一需要注意的就是这段 JS 代码必须放在 JQuery 之后，顺序问题。</p>
<p>好了，继续折腾去啦。</p>
<div id="rl_posts">    <div id="rl_posts_hd" class="box_hd">        <span id="rl_posts_title" class="box_title">与 <h2 itemprop="keywords"><a href="http://wange.im/tag/javascript/" title="Javascript" rel="tag">Javascript</a>,<a href="http://wange.im/tag/jquery/" title="jQuery" rel="tag">jQuery</a>,<a href="http://wange.im/tag/js/" title="JS" rel="tag">JS</a></h2> 相关的文章        </span>    </div>    <div id="rl_posts_bd">        <ul class="clearfix"><li>    <div class="rl_thumb"><img src="http://wange.im/wp-content/themes/wange/imgs/category/computer.jpg" alt="电脑网络" width="45" height="45" itemprop="thumbnailUrl" />    </div>    <div class="rl_title">        <a href="http://wange.im/jquery-js-ajax-pic.html" rel="bookmark" title="jQuery/JavaScript 实现的异步加载图片">jQuery/JavaScript 实现的异步加载图片</a>        <div class="rl_date">2011年04月10日</div>    </div></li><li>    <div class="rl_thumb"><img src="http://wange.im/wp-content/themes/wange/timthumb.php?src=http://wange.im/cache/sweet-titles.jpg&amp;h=45&amp;w=45&amp;zc=1" alt="JQuery 鼠标提示特效之 Sweet Titles" width="45" height="45" itemprop="thumbnailUrl" />    </div>    <div class="rl_title">        <a href="http://wange.im/jquery-sweet-titles-tooltips.html" rel="bookmark" title="JQuery 鼠标提示特效之 Sweet Titles">JQuery 鼠标提示特效之 Sweet Titles</a>        <div class="rl_date">2010年03月14日</div>    </div></li><li>    <div class="rl_thumb"><img src="http://wange.im/wp-content/themes/wange/imgs/category/computer.jpg" alt="电脑网络" width="45" height="45" itemprop="thumbnailUrl" />    </div>    <div class="rl_title">        <a href="http://wange.im/ietester-version.html" rel="bookmark" title="最短最给力的 IE 版本判断脚本">最短最给力的 IE 版本判断脚本</a>        <div class="rl_date">2011年02月19日</div>    </div></li><li>    <div class="rl_thumb"><img src="http://wange.im/wp-content/themes/wange/imgs/category/computer.jpg" alt="电脑网络" width="45" height="45" itemprop="thumbnailUrl" />    </div>    <div class="rl_title">        <a href="http://wange.im/jian-xian-bg-with-jquery.html" rel="bookmark" title="jQuery 实现的背景渐显渐隐效果">jQuery 实现的背景渐显渐隐效果</a>        <div class="rl_date">2010年08月4日</div>    </div></li>        </ul>    </div></div>]]></content:encoded>
			<wfw:commentRss>http://wange.im/fadein-and-fadeout-with-jquery.html/feed</wfw:commentRss>
		<slash:comments>86</slash:comments>
		</item>
		<item>
		<title>利用 JQuery 实现图片显隐特效</title>
		<link>http://wange.im/fadeto-effect-with-jquery.html</link>
		<comments>http://wange.im/fadeto-effect-with-jquery.html#comments</comments>
		<pubDate>Thu, 08 Apr 2010 13:00:33 +0000</pubDate>
		<dc:creator>万戈</dc:creator>
				<category><![CDATA[电脑网络]]></category>
		<category><![CDATA[转来载去]]></category>
		<category><![CDATA[jQuery]]></category>
		<category><![CDATA[JS]]></category>
		<category><![CDATA[WordPress]]></category>
		<category><![CDATA[图片]]></category>

		<guid isPermaLink="false">http://wange.im/?p=2978</guid>
		<description><![CDATA[今天又挖到一个 JQuery 特效，迫不及待用到 WordPress 上了，是一个利用 JQuery 实现图片显隐的特效，效果可以见我的评论头像，把鼠标移动上去试试看～可以看到头像会渐隐吧，在 IE、Firefox、Chrome 等各大浏览器下都是兼容的，这就是 JQuery 的魅力。 方法转自：http://www.skyoy.com/jquery-picture-hidden-effects.html 第一步：在 header.php 中加载 jquery，可以使用外链也可以内链。 外链可利用 google 提供的 JQ 库，调用格式为： &#60;script type="text/javascript" src="http://jqueryjs.googlecode.com/files/jquery-1.2.3.min.js"&#62;&#60;/script&#62; 内链空间 jquery，把 jquery.min.js 上传到风格的 js 目录下，调用格式为： &#60;script type="text/javascript" src="&#60;?php bloginfo('stylesheet_directory'); ?&#62;/js/jquery.min.js" &#62;&#60;/script&#62; 第二步：在 header.php 中，添加到 &#60;/head&#62; 前，插入代码为： &#60;script type="text/javascript"&#62; $(function () { $('img').hover( function() {$(this).fadeTo("fast", 0.5);}, function() {$(this).fadeTo("fast", 1); }); }); [...]]]></description>
			<content:encoded><![CDATA[<p>今天又挖到一个 JQuery 特效，迫不及待用到 WordPress 上了，是一个利用 JQuery 实现图片显隐的特效，效果可以见我的评论头像，把鼠标移动上去试试看～可以看到头像会渐隐吧，在 IE、Firefox、Chrome 等各大浏览器下都是兼容的，这就是 JQuery 的魅力。</p>
<p>方法转自：<a title="利用jquery实现图片显隐特效" href="http://www.skyoy.com/jquery-picture-hidden-effects.html" target="_blank">http://www.skyoy.com/jquery-picture-hidden-effects.html</a></p>
<p>第一步：在 header.php 中加载 jquery，可以使用外链也可以内链。</p>
<p>外链可利用 google 提供的 JQ 库，调用格式为：</p>
<div class="source" style="font-family: 'Courier New', 'Lucida Console', 'monospace'; color: #000000;"><span style="color: #000080; font-weight: bold;">&lt;script </span><span style="color: #ff0000;">type=</span><span style="color: #0000ff;">"text/javascript"</span> <span style="color: #ff0000;">src=</span><span style="color: #0000ff;">"http://jqueryjs.googlecode.com/files/jquery-1.2.3.min.js"</span><span style="color: #000080; font-weight: bold;">&gt;&lt;/script&gt;</span></div>
<p>内链空间 jquery，把 jquery.min.js 上传到风格的 js 目录下，调用格式为：</p>
<div class="source" style="font-family: 'Courier New', 'Lucida Console', 'monospace'; color: #000000;"><span style="color: #000080; font-weight: bold;">&lt;script </span><span style="color: #ff0000;">type=</span><span style="color: #0000ff;">"text/javascript"</span> <span style="color: #ff0000;">src=</span><span style="color: #0000ff;">"</span><span style="color: #008080;">&lt;?php</span> <span style="color: #000000;">bloginfo</span>(<span style="color: #0000ff;">'stylesheet_directory'</span>); <span style="color: #008080;">?&gt;</span><span style="color: #0000ff;">/js/jquery.min.js"</span> <span style="color: #000080; font-weight: bold;">&gt;&lt;/script&gt;</span></div>
<p>第二步：在 header.php 中，添加到 &lt;/head&gt; 前，插入代码为：</p>
<div class="source" style="font-family: 'Courier New', 'Lucida Console', 'monospace'; color: #000000;"><span style="color: #000080; font-weight: bold;">&lt;script </span><span style="color: #ff0000;">type=</span><span style="color: #0000ff;">"text/javascript"</span><span style="color: #000080; font-weight: bold;">&gt;</span><br />
<span style="color: #000000;">$</span>(<span style="color: #000080; font-weight: bold;">function</span> () <span style="color: #000000;">{</span><br />
<span style="color: #000000;">$</span>(<span style="color: #0000ff;">'img'</span><span style="color: #000000;">).</span><span style="color: #000000;">hover</span>(<br />
<span style="color: #000080; font-weight: bold;">function</span>() <span style="color: #000000;">{</span><span style="color: #000000;">$</span>(<span style="color: #000080; font-weight: bold;">this</span><span style="color: #000000;">).</span><span style="color: #000000;">fadeTo</span>(<span style="color: #0000ff;">"fast"</span><span style="color: #000000;">,</span> <span style="color: #0000ff;">0.5</span><span style="color: #000000;">);},</span><br />
<span style="color: #000080; font-weight: bold;">function</span>() <span style="color: #000000;">{</span><span style="color: #000000;">$</span>(<span style="color: #000080; font-weight: bold;">this</span><span style="color: #000000;">).</span><span style="color: #000000;">fadeTo</span>(<span style="color: #0000ff;">"fast"</span><span style="color: #000000;">,</span> <span style="color: #0000ff;">1</span>);<br />
<span style="color: #000000;">});</span><br />
<span style="color: #000000;">});</span><br />
<span style="color: #000080; font-weight: bold;">&lt;/script&gt;</span></div>
<p>看到这个效果的时候我第一时间想到了用 CSS 实现，因为通过 hover 伪类也可以实现鼠标移动上图片上显隐的效果，不过唯一区别就是，JQuery 实现的显隐有渐变的过渡效果，虽然区别很微弱，不过细节绝定成败，这个 JQuery 也很小巧，何乐而不为呢？</p>
<div id="rl_posts">    <div id="rl_posts_hd" class="box_hd">        <span id="rl_posts_title" class="box_title">与 <h2 itemprop="keywords"><a href="http://wange.im/tag/jquery/" title="jQuery" rel="tag">jQuery</a>,<a href="http://wange.im/tag/js/" title="JS" rel="tag">JS</a>,<a href="http://wange.im/tag/wordpress/" title="WordPress" rel="tag">WordPress</a>,<a href="http://wange.im/tag/picture/" title="图片" rel="tag">图片</a></h2> 相关的文章        </span>    </div>    <div id="rl_posts_bd">        <ul class="clearfix"><li>    <div class="rl_thumb"><img src="http://wange.im/wp-content/themes/wange/imgs/category/computer.jpg" alt="电脑网络" width="45" height="45" itemprop="thumbnailUrl" />    </div>    <div class="rl_title">        <a href="http://wange.im/jquery-js-ajax-pic.html" rel="bookmark" title="jQuery/JavaScript 实现的异步加载图片">jQuery/JavaScript 实现的异步加载图片</a>        <div class="rl_date">2011年04月10日</div>    </div></li><li>    <div class="rl_thumb"><img src="http://wange.im/wp-content/themes/wange/timthumb.php?src=http://wange.im/cache/sweet-titles.jpg&amp;h=45&amp;w=45&amp;zc=1" alt="JQuery 鼠标提示特效之 Sweet Titles" width="45" height="45" itemprop="thumbnailUrl" />    </div>    <div class="rl_title">        <a href="http://wange.im/jquery-sweet-titles-tooltips.html" rel="bookmark" title="JQuery 鼠标提示特效之 Sweet Titles">JQuery 鼠标提示特效之 Sweet Titles</a>        <div class="rl_date">2010年03月14日</div>    </div></li><li>    <div class="rl_thumb"><img src="http://wange.im/wp-content/themes/wange/imgs/category/computer.jpg" alt="电脑网络" width="45" height="45" itemprop="thumbnailUrl" />    </div>    <div class="rl_title">        <a href="http://wange.im/animated-menu-using-jquery.html" rel="bookmark" title="JQuery 实现动感导航菜单">JQuery 实现动感导航菜单</a>        <div class="rl_date">2010年02月25日</div>    </div></li><li>    <div class="rl_thumb"><img src="http://wange.im/wp-content/themes/wange/imgs/category/computer.jpg" alt="电脑网络" width="45" height="45" itemprop="thumbnailUrl" />    </div>    <div class="rl_title">        <a href="http://wange.im/jquery-slideshow-twitter.html" rel="bookmark" title="JQuery 循环滚动展示 Twitter 公告">JQuery 循环滚动展示 Twitter 公告</a>        <div class="rl_date">2010年02月22日</div>    </div></li>        </ul>    </div></div>]]></content:encoded>
			<wfw:commentRss>http://wange.im/fadeto-effect-with-jquery.html/feed</wfw:commentRss>
		<slash:comments>124</slash:comments>
		</item>
		<item>
		<title>JQuery 鼠标提示特效之 Sweet Titles</title>
		<link>http://wange.im/jquery-sweet-titles-tooltips.html</link>
		<comments>http://wange.im/jquery-sweet-titles-tooltips.html#comments</comments>
		<pubDate>Sun, 14 Mar 2010 13:33:40 +0000</pubDate>
		<dc:creator>万戈</dc:creator>
				<category><![CDATA[电脑网络]]></category>
		<category><![CDATA[Javascript]]></category>
		<category><![CDATA[jQuery]]></category>
		<category><![CDATA[JS]]></category>
		<category><![CDATA[Sweet Titles]]></category>
		<category><![CDATA[WordPress]]></category>

		<guid isPermaLink="false">http://wange.im/?p=2840</guid>
		<description><![CDATA[JQuery 的 Sweet Titles 鼠标提示特效我早就用过了，但是后来发现和链接平移 JQuery 特效同时使用会在 IE 下有些冲突，虽说只有在我的主题上发现有这个情况，不过还是很可惜被我弃用了一段时间。今天却又被我重新用上了，用了比较折衷的方法，那就是只在友情链接页面使用 Sweet Titles，正好最近对友情链接做了彻底的改革，所以也就顺便对友链页面小小的美化一下。 说了半天，再来介绍一下什么是 Sweet Titles 吧，效果请见我的友情链接页面。Sweet Titles 是 JQuery 中有名的鼠标悬浮提示效果之一，与其相类似的 JQuery 插件也不少，比如说，jQuery Plugin - Tooltip、jTip - The jQuery Tool Tip、clueTip、BetterTip、Flash Tooltips using jQuery、ToolTip，这些都是 JQuery 的鼠标提示效果插件，各有特色，不过相比较而言，Sweet Titles 是其中代码最少，使用最方便，效果也相当华丽丽的一个，所以个人感觉很适合博客使用。 接下来说一下使用方法： 一、载入 JQuery 库 &#60;script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4/jquery.min.js"&#62;&#60;/script&#62; 其实用 JQuery 1.4 有点浪费，JQuery 1.2x 就完全可以胜任。 二、执行代码 jQuery(document).ready(function($){ $("a").mouseover(function(e){     this.myTitle = [...]]]></description>
			<content:encoded><![CDATA[<p>JQuery 的 Sweet Titles 鼠标提示特效我早就用过了，但是后来发现和<a title="Wordpress 之链接平移 JQuery 特效" href="http://wange.im/mouseover-link-slide-for-wordpress.html">链接平移 JQuery 特效</a>同时使用会在 IE 下有些冲突，虽说只有在我的主题上发现有这个情况，不过还是很可惜被我弃用了一段时间。今天却又被我重新用上了，用了比较折衷的方法，那就是只在<a title="网上邻居" href="http://wange.im">友情链接</a>页面使用 Sweet Titles，正好最近对友情链接做了彻底的改革，所以也就顺便对友链页面小小的美化一下。</p>
<p>说了半天，再来介绍一下什么是 Sweet Titles 吧，效果请见我的<a title="网上邻居" href="http://wange.im">友情链接</a>页面。<img style="float: right;" src="http://public.bay.livefilestore.com/y1pwyq5u0DWv9v2EAB1R87-M5sLRjreAaUKBApQ8mVoxaZn5nUAwavRt4BxYwMeyVKHNo7NVKikfTuOiBlU5XoWXQ/sweet-titles.jpg" alt="sweet titles" />Sweet Titles 是 JQuery 中有名的鼠标悬浮提示效果之一，与其相类似的 JQuery 插件也不少，比如说，<a href="http://bassistance.de/jquery-plugins/jquery-plugin-tooltip/" target="_blank">jQuery Plugin - Tooltip</a>、<a href="http://www.codylindley.com/blogstuff/js/jtip/" target="_blank">jTip - The jQuery Tool Tip</a>、<a href="http://examples.learningjquery.com/62/demo/index.html#examplesection" target="_blank">clueTip</a>、<a href="http://edgarverle.com/BetterTip/default.cfm" target="_blank">BetterTip</a>、<a href="http://ioreader.com/2007/05/15/flash-tooltips-using-jquery/" target="_blank">Flash Tooltips using jQuery</a>、<a href="http://www.texotela.co.uk/code/jquery/tooltipdemo/" target="_blank">ToolTip</a>，这些都是 JQuery 的鼠标提示效果插件，各有特色，不过相比较而言，Sweet Titles 是其中代码最少，使用最方便，效果也相当华丽丽的一个，所以个人感觉很适合博客使用。</p>
<p>接下来说一下使用方法：</p>
<p><strong>一、载入 JQuery 库</strong></p>
<div class="source" style="font-family: 'Courier New','Lucida Console','monospace'; color: #000000;"><span style="color: #000080; font-weight: bold;">&lt;script </span><span style="color: #ff0000;">type=</span><span style="color: #0000ff;">"text/javascript"</span> <span style="color: #ff0000;">src=</span><span style="color: #0000ff;">"http://ajax.googleapis.com/ajax/libs/jquery/1.4/jquery.min.js"</span><span style="color: #000080; font-weight: bold;">&gt;&lt;/script&gt;</span></div>
<p>其实用 JQuery 1.4 有点浪费，JQuery 1.2x 就完全可以胜任。</p>
<p><strong>二、执行代码</strong></p>
<div class="source" style="font-family: 'Courier New','Lucida Console','monospace'; color: #000000;"><span style="color: #000000;">jQuery</span>(<span style="color: #000000;">document</span><span style="color: #000000;">).</span><span style="color: #000000;">ready</span>(<span style="color: #000080; font-weight: bold;">function</span>(<span style="color: #000000;">$</span><span style="color: #000000;">){</span></p>
<p><span style="color: #000000;">$</span>(<span style="color: #0000ff;">"a"</span><span style="color: #000000;">).</span><span style="color: #000000;">mouseover</span>(<span style="color: #000080; font-weight: bold;">function</span>(<span style="color: #000000;">e</span><span style="color: #000000;">){</span><br />
    <span style="color: #000080; font-weight: bold;">this</span><span style="color: #000000;">.</span><span style="color: #000000;">myTitle</span> <span style="color: #000000;">=</span> <span style="color: #000080; font-weight: bold;">this</span><span style="color: #000000;">.</span><span style="color: #000000;">title</span>;<br />
    <span style="color: #000080; font-weight: bold;">this</span><span style="color: #000000;">.</span><span style="color: #000000;">myHref</span> <span style="color: #000000;">=</span> <span style="color: #000080; font-weight: bold;">this</span><span style="color: #000000;">.</span><span style="color: #000000;">href</span>;<br />
    <span style="color: #000080; font-weight: bold;">this</span><span style="color: #000000;">.</span><span style="color: #000000;">myHref</span> <span style="color: #000000;">=</span> (<span style="color: #000080; font-weight: bold;">this</span><span style="color: #000000;">.</span><span style="color: #000000;">myHref</span><span style="color: #000000;">.</span><span style="color: #000000;">length</span> <span style="color: #000000;">&gt;</span> <span style="color: #0000ff;">30</span> <span style="color: #000000;">?</span> <span style="color: #000080; font-weight: bold;">this</span><span style="color: #000000;">.</span><span style="color: #000000;">myHref</span><span style="color: #000000;">.</span><span style="color: #000000;">toString</span><span style="color: #000000;">().</span><span style="color: #000000;">substring</span>(<span style="color: #0000ff;">0</span><span style="color: #000000;">,</span><span style="color: #0000ff;">30</span>)<span style="color: #000000;">+</span><span style="color: #0000ff;">"..."</span> <span style="color: #000000;">:</span> <span style="color: #000080; font-weight: bold;">this</span><span style="color: #000000;">.</span><span style="color: #000000;">myHref</span>);<br />
    <span style="color: #000080; font-weight: bold;">this</span><span style="color: #000000;">.</span><span style="color: #000000;">title</span> <span style="color: #000000;">=</span> <span style="color: #0000ff;">""</span>;<br />
    <span style="color: #000080; font-weight: bold;">var</span> <span style="color: #000000;">tooltip</span> <span style="color: #000000;">=</span> <span style="color: #0000ff;">"&lt;div id='tooltip'&gt;&lt;p&gt;"</span><span style="color: #000000;">+</span><span style="color: #000080; font-weight: bold;">this</span><span style="color: #000000;">.</span><span style="color: #000000;">myTitle</span><span style="color: #000000;">+</span><span style="color: #0000ff;">"&lt;em&gt;"</span><span style="color: #000000;">+</span><span style="color: #000080; font-weight: bold;">this</span><span style="color: #000000;">.</span><span style="color: #000000;">myHref</span><span style="color: #000000;">+</span><span style="color: #0000ff;">"&lt;/em&gt;"</span><span style="color: #000000;">+</span><span style="color: #0000ff;">"&lt;/p&gt;&lt;/div&gt;"</span>;<br />
    <span style="color: #000000;">$</span>(<span style="color: #0000ff;">'body'</span><span style="color: #000000;">).</span><span style="color: #000000;">append</span>(<span style="color: #000000;">tooltip</span>);<br />
    <span style="color: #000000;">$</span>(<span style="color: #0000ff;">'#tooltip'</span><span style="color: #000000;">).</span><span style="color: #000000;">css</span><span style="color: #000000;">({</span><span style="color: #0000ff;">"opacity"</span><span style="color: #000000;">:</span><span style="color: #0000ff;">"0.8"</span><span style="color: #000000;">,</span><span style="color: #0000ff;">"top"</span><span style="color: #000000;">:</span>(<span style="color: #000000;">e</span><span style="color: #000000;">.</span><span style="color: #000000;">pageY</span><span style="color: #000000;">+</span><span style="color: #0000ff;">20</span>)<span style="color: #000000;">+</span><span style="color: #0000ff;">"px"</span><span style="color: #000000;">,</span><span style="color: #0000ff;">"left"</span><span style="color: #000000;">:</span>(<span style="color: #000000;">e</span><span style="color: #000000;">.</span><span style="color: #000000;">pageX</span><span style="color: #000000;">+</span><span style="color: #0000ff;">10</span>)<span style="color: #000000;">+</span><span style="color: #0000ff;">"px"</span><span style="color: #000000;">}).</span><span style="color: #000000;">show</span>(<span style="color: #0000ff;">'fast'</span>);<br />
<span style="color: #000000;">}).</span><span style="color: #000000;">mouseout</span>(<span style="color: #000080; font-weight: bold;">function</span><span style="color: #000000;">(){</span><span style="color: #000080; font-weight: bold;">this</span><span style="color: #000000;">.</span><span style="color: #000000;">title</span> <span style="color: #000000;">=</span> <span style="color: #000080; font-weight: bold;">this</span><span style="color: #000000;">.</span><span style="color: #000000;">myTitle</span>;<span style="color: #000000;">$</span>(<span style="color: #0000ff;">'#tooltip'</span><span style="color: #000000;">).</span><span style="color: #000000;">remove</span>();<br />
<span style="color: #000000;">}).</span><span style="color: #000000;">mousemove</span>(<span style="color: #000080; font-weight: bold;">function</span>(<span style="color: #000000;">e</span><span style="color: #000000;">){</span><span style="color: #000000;">$</span>(<span style="color: #0000ff;">'#tooltip'</span><span style="color: #000000;">).</span><span style="color: #000000;">css</span><span style="color: #000000;">({</span><span style="color: #0000ff;">"top"</span><span style="color: #000000;">:</span>(<span style="color: #000000;">e</span><span style="color: #000000;">.</span><span style="color: #000000;">pageY</span><span style="color: #000000;">+</span><span style="color: #0000ff;">20</span>)<span style="color: #000000;">+</span><span style="color: #0000ff;">"px"</span><span style="color: #000000;">,</span><span style="color: #0000ff;">"left"</span><span style="color: #000000;">:</span>(<span style="color: #000000;">e</span><span style="color: #000000;">.</span><span style="color: #000000;">pageX</span><span style="color: #000000;">+</span><span style="color: #0000ff;">10</span>)<span style="color: #000000;">+</span><span style="color: #0000ff;">"px"</span><span style="color: #000000;">});</span><br />
<span style="color: #000000;">});</span></p>
<p><span style="color: #000000;">});</span></div>
<p><strong>三、样式美化部分</strong></p>
<div class="source" style="font-family: 'Courier New','Lucida Console','monospace'; color: #000000;"><span style="color: #000000;">#tooltip</span> <span style="color: #000000;">{</span><span style="color: #000080; font-weight: bold;">position</span><span style="color: #000000;">:</span><span style="color: #000080; font-weight: bold;">absolute</span>;<span style="color: #000080; font-weight: bold;">z-index</span><span style="color: #000000;">:</span><span style="color: #0000ff;">1000</span>;<span style="color: #000080; font-weight: bold;">max-width</span><span style="color: #000000;">:</span><span style="color: #0000ff;">250px</span>;<span style="color: #000000;">word</span><span style="color: #000000;">-</span><span style="color: #000000;">wrap</span><span style="color: #000000;">:</span><span style="color: #000000;">break</span><span style="color: #000000;">-</span><span style="color: #000000;">word</span>;<span style="color: #000080; font-weight: bold;">background</span><span style="color: #000000;">:</span><span style="color: #0000ff;">#000</span>;<span style="color: #000080; font-weight: bold;">text-align</span><span style="color: #000000;">:</span><span style="color: #000080; font-weight: bold;">left</span>;<span style="color: #000080; font-weight: bold;">padding</span><span style="color: #000000;">:</span><span style="color: #0000ff;">5px</span>;<span style="color: #000080; font-weight: bold;">min-height</span><span style="color: #000000;">:</span><span style="color: #0000ff;">1em</span>;<span style="color: #000000;">-</span><span style="color: #000000;">moz</span><span style="color: #000000;">-</span><span style="color: #000080; font-weight: bold;">border</span><span style="color: #000000;">-</span><span style="color: #000000;">radius</span><span style="color: #000000;">:</span><span style="color: #0000ff;">5px</span>;<span style="color: #000000;">-</span><span style="color: #000000;">khtml</span><span style="color: #000000;">-</span><span style="color: #000080; font-weight: bold;">border</span><span style="color: #000000;">-</span><span style="color: #000000;">radius</span><span style="color: #000000;">:</span><span style="color: #0000ff;">5px</span>;<span style="color: #000000;">-</span><span style="color: #000000;">webkit</span><span style="color: #000000;">-</span><span style="color: #000080; font-weight: bold;">border</span><span style="color: #000000;">-</span><span style="color: #000000;">radius</span><span style="color: #000000;">:</span><span style="color: #0000ff;">5px</span>;<span style="color: #000080; font-weight: bold;">border</span><span style="color: #000000;">-</span><span style="color: #000000;">radius</span><span style="color: #000000;">:</span><span style="color: #0000ff;">5px</span><span style="color: #000000;">;}</span><br />
<span style="color: #000000;">#tooltip</span> p <span style="color: #000000;">{</span><span style="color: #000080; font-weight: bold;">color</span><span style="color: #000000;">:</span><span style="color: #0000ff;">#fff</span>;<span style="color: #000080; font-weight: bold;">font</span><span style="color: #000000;">:</span><span style="color: #0000ff;">12px</span> <span style="color: #0000ff;">'Microsoft YaHei'</span><span style="color: #000000;">,</span><span style="color: #000000;">Arial</span><span style="color: #000000;">,</span><span style="color: #a61717;">宋体</span><span style="color: #000000;">,</span><span style="color: #000000;">Tahoma</span><span style="color: #000000;">,</span><span style="color: #000000;">Sans</span><span style="color: #000000;">-</span><span style="color: #000000;">Serif</span><span style="color: #000000;">;}</span><br />
<span style="color: #000000;">#tooltip</span> p <span style="color: #000080; font-weight: bold;">em</span> <span style="color: #000000;">{</span><span style="color: #000080; font-weight: bold;">display</span><span style="color: #000000;">:</span><span style="color: #000080; font-weight: bold;">block</span>;<span style="color: #000080; font-weight: bold;">margin-top</span><span style="color: #000000;">:</span><span style="color: #0000ff;">3px</span>;<span style="color: #000080; font-weight: bold;">color</span><span style="color: #000000;">:</span><span style="color: #0000ff;">#f60</span>;<span style="color: #000080; font-weight: bold;">font-style</span><span style="color: #000000;">:</span><span style="color: #000080; font-weight: bold;">normal</span><span style="color: #000000;">;}</span></div>
<p>以上代码部分摘自：<a title="JQuery 学习笔记之：美妙的标题提示" href="http://immmmm.com/jquery-study-notes-the-wonderful-title-tips.html" target="_blank">http://immmmm.com/jquery-study-notes-the-wonderful-title-tips.html</a></p>
<div id="rl_posts">    <div id="rl_posts_hd" class="box_hd">        <span id="rl_posts_title" class="box_title">与 <h2 itemprop="keywords"><a href="http://wange.im/tag/javascript/" title="Javascript" rel="tag">Javascript</a>,<a href="http://wange.im/tag/jquery/" title="jQuery" rel="tag">jQuery</a>,<a href="http://wange.im/tag/js/" title="JS" rel="tag">JS</a>,<a href="http://wange.im/tag/sweet-titles/" title="Sweet Titles" rel="tag">Sweet Titles</a>,<a href="http://wange.im/tag/wordpress/" title="WordPress" rel="tag">WordPress</a></h2> 相关的文章        </span>    </div>    <div id="rl_posts_bd">        <ul class="clearfix"><li>    <div class="rl_thumb"><img src="http://wange.im/wp-content/themes/wange/imgs/category/computer.jpg" alt="电脑网络" width="45" height="45" itemprop="thumbnailUrl" />    </div>    <div class="rl_title">        <a href="http://wange.im/jquery-js-ajax-pic.html" rel="bookmark" title="jQuery/JavaScript 实现的异步加载图片">jQuery/JavaScript 实现的异步加载图片</a>        <div class="rl_date">2011年04月10日</div>    </div></li><li>    <div class="rl_thumb"><img src="http://wange.im/wp-content/themes/wange/timthumb.php?src=http://wange.im/cache/rss2.jpg&amp;h=45&amp;w=45&amp;zc=1" alt="JQuery 鼠标滑动渐隐渐显效果" width="45" height="45" itemprop="thumbnailUrl" />    </div>    <div class="rl_title">        <a href="http://wange.im/fadein-and-fadeout-with-jquery.html" rel="bookmark" title="JQuery 鼠标滑动渐隐渐显效果">JQuery 鼠标滑动渐隐渐显效果</a>        <div class="rl_date">2010年05月5日</div>    </div></li><li>    <div class="rl_thumb"><img src="http://wange.im/wp-content/themes/wange/imgs/category/computer.jpg" alt="电脑网络" width="45" height="45" itemprop="thumbnailUrl" />    </div>    <div class="rl_title">        <a href="http://wange.im/fadeto-effect-with-jquery.html" rel="bookmark" title="利用 JQuery 实现图片显隐特效">利用 JQuery 实现图片显隐特效</a>        <div class="rl_date">2010年04月8日</div>    </div></li><li>    <div class="rl_thumb"><img src="http://wange.im/wp-content/themes/wange/imgs/category/computer.jpg" alt="电脑网络" width="45" height="45" itemprop="thumbnailUrl" />    </div>    <div class="rl_title">        <a href="http://wange.im/animated-menu-using-jquery.html" rel="bookmark" title="JQuery 实现动感导航菜单">JQuery 实现动感导航菜单</a>        <div class="rl_date">2010年02月25日</div>    </div></li>        </ul>    </div></div>]]></content:encoded>
			<wfw:commentRss>http://wange.im/jquery-sweet-titles-tooltips.html/feed</wfw:commentRss>
		<slash:comments>95</slash:comments>
		</item>
		<item>
		<title>HTML 转换到 Javascript（附源码）</title>
		<link>http://wange.im/html-to-javascript.html</link>
		<comments>http://wange.im/html-to-javascript.html#comments</comments>
		<pubDate>Thu, 11 Mar 2010 12:55:35 +0000</pubDate>
		<dc:creator>万戈</dc:creator>
				<category><![CDATA[电脑网络]]></category>
		<category><![CDATA[HTML]]></category>
		<category><![CDATA[Javascript]]></category>
		<category><![CDATA[JS]]></category>

		<guid isPermaLink="false">http://wange.im/?p=2828</guid>
		<description><![CDATA[今天发现一个很好玩又比较实用的功能，HTML 转换成 Javascript，请见：http://wange.im/tool/htmltojs/ 这个小工具对我来说相当之有用啊，虽然只是用 Javascript 的形式表现 HTML，比如说： 原 HTML： &#60;title&#62;Life Studio&#60;/title&#62;&#60;div id="author"&#62;万戈&#60;/div&#62; 转换后的 Javascript： document.writeln("&#60;title&#62;Life Studio&#60;\/title&#62;&#60;div id=\"author\"&#62;万戈&#60;\/div&#62;"); 当然，这只是一个很简单的例子，用 HTML 转换成 Javascript 用诸多好处，比如说，我们可以随意地改变 Javascript 加载的地方，如果是出于页面载入速度考虑，我就会把类似于 flash/JQuery 实现的幻灯效果以 Javascript 的形式表现出来，然后加载在&#60;/body&#62;标签之前，Yslow 以建议我们把 JS 放在最后，有些不太重要的 HTML 标签就可以用这个方法，然后再用 CSS 定位。 不过嘛，好工具总是一把双刃剑，如果把 HTML 转换成 Javascript 的方法应用于友情链接上，那就不太好咯。因为我们知道蜘蛛爬虫是咬不动 Javascript 的，所以如果把友情链接的 HTML 用 JS 表现出来，那就太不公平了，请三思而用之。 最后，附上 HTML 转换至 Javascript 的源码： &#60;html&#62; &#60;head&#62; &#60;title&#62;HTML转JavaScript&#60;/title&#62; &#60;/head&#62; &#60;body&#62; [...]]]></description>
			<content:encoded><![CDATA[<p>今天发现一个很好玩又比较实用的功能，HTML 转换成 Javascript，请见：<a title="HTML to Javascript" href="http://wange.im/tool/htmltojs/">http://wange.im/tool/htmltojs/</a></p>
<p>这个小工具对我来说相当之有用啊，虽然只是用 Javascript 的形式表现 HTML，比如说：</p>
<p>原 HTML：</p>
<div class="source" style="font-family: 'Courier New', 'Lucida Console', 'monospace'; color: #000000;"><span style="color: #000080; font-weight: bold;">&lt;title&gt;</span><span style="color: #000000;">Life Studio</span><span style="color: #000080; font-weight: bold;">&lt;/title&gt;&lt;div</span> <span style="color: #ff0000;">id=</span><span style="color: #0000ff;">"author"</span><span style="color: #000080; font-weight: bold;">&gt;</span><span style="color: #000000;">万戈</span><span style="color: #000080; font-weight: bold;">&lt;/div&gt;</span></div>
<p>转换后的 Javascript：</p>
<div class="source" style="font-family: 'Courier New', 'Lucida Console', 'monospace'; color: #000000;"><span style="color: #000000;">document</span><span style="color: #000000;">.</span><span style="color: #000000;">writeln</span>(<span style="color: #0000ff;">"&lt;title&gt;Life Studio&lt;\/title&gt;&lt;div id=\"author\"&gt;万戈&lt;\/div&gt;"</span>);</div>
<p>当然，这只是一个很简单的例子，用 HTML 转换成 Javascript 用诸多好处，比如说，我们可以随意地改变 Javascript 加载的地方，如果是出于页面载入速度考虑，我就会把类似于 flash/JQuery 实现的幻灯效果以 Javascript 的形式表现出来，然后加载在&lt;/body&gt;标签之前，Yslow 以建议我们把 JS 放在最后，有些不太重要的 HTML 标签就可以用这个方法，然后再用 CSS 定位。</p>
<p>不过嘛，好工具总是一把双刃剑，如果把 HTML 转换成 Javascript 的方法应用于友情链接上，那就不太好咯。因为我们知道蜘蛛爬虫是咬不动 Javascript 的，所以如果把友情链接的 HTML 用 JS 表现出来，那就太不公平了，请三思而用之。</p>
<p>最后，附上 HTML 转换至 Javascript 的源码：</p>
<div class="source" style="overflow:auto;font-family: 'Courier New', 'Lucida Console', 'monospace'; color: #000000;"><span style="color: #000080; font-weight: bold;">&lt;html&gt;</span><br />
<span style="color: #000080; font-weight: bold;">&lt;head&gt;</span><br />
<span style="color: #000080; font-weight: bold;">&lt;title&gt;</span><span style="color: #000000;">HTML转JavaScript</span><span style="color: #000080; font-weight: bold;">&lt;/title&gt;</span><br />
<span style="color: #000080; font-weight: bold;">&lt;/head&gt;</span><br />
<span style="color: #000080; font-weight: bold;">&lt;body&gt;</span><br />
<span style="color: #000080; font-weight: bold;">&lt;p</span> <span style="color: #ff0000;">align=</span><span style="color: #0000ff;">"center"</span><span style="color: #000080; font-weight: bold;">&gt;&lt;font</span> <span style="color: #ff0000;">style=</span><span style="color: #0000ff;">"font-size:18pt;"</span><span style="color: #000080; font-weight: bold;">&gt;</span><span style="color: #000000;">HTML转换为JS</span><span style="color: #000080; font-weight: bold;">&lt;/font&gt;&lt;br&gt;</span><span style="color: #000000;">请将html代码拷至下面文本框中: </span><span style="color: #000080; font-weight: bold;">&lt;br&gt;</span><br />
<span style="color: #000080; font-weight: bold;">&lt;textarea</span> <span style="color: #ff0000;">cols=</span><span style="color: #0000ff;">"70"</span><span style="color: #ff0000;">id=</span><span style="color: #0000ff;">"oSource"</span> <span style="color: #ff0000;">onpropertychange=</span><span style="color: #0000ff;">"showhideJSTag(change(oSource.value));"</span> <span style="color: #ff0000;">rows=</span><span style="color: #0000ff;">"10"</span> <span style="color: #ff0000;">name=</span><span style="color: #0000ff;">"oSource"</span> <span style="color: #000080; font-weight: bold;">&gt;&lt;/textarea&gt;&lt;br&gt;</span><br />
<span style="color: #000000;">为您生成的JS代码，双击可以复制:(</span><span style="color: #000080; font-weight: bold;">&lt;input</span> <span style="color: #ff0000;">name=</span><span style="color: #0000ff;">"ShowJSTag"</span> <span style="color: #ff0000;">type=</span><span style="color: #0000ff;">"checkbox"</span> <span style="color: #ff0000;">id=</span><span style="color: #0000ff;">"ShowJSTag"</span> <span style="color: #ff0000;">onClick=</span><span style="color: #0000ff;">"showhideJSTag(change(oSource.value));"</span> <span style="color: #ff0000;">value=</span><span style="color: #0000ff;">"yes"</span><span style="color: #000080; font-weight: bold;">&gt;</span><span style="color: #000000;">是否加上Javascript标签)</span><span style="color: #000080; font-weight: bold;">&lt;p</span> <span style="color: #ff0000;">align=</span><span style="color: #0000ff;">"center"</span><span style="color: #000080; font-weight: bold;">&gt;</span><br />
  <span style="color: #000080; font-weight: bold;">&lt;textarea</span> <span style="color: #ff0000;">cols=</span><span style="color: #0000ff;">"70"</span> <span style="color: #ff0000;">id=</span><span style="color: #0000ff;">"oResult"</span> <span style="color: #ff0000;">title=</span><span style="color: #0000ff;">"双击复制"</span> <span style="color: #ff0000;">ondblclick=</span><span style="color: #0000ff;">'this.select();oResult.createTextRange().execCommand("Copy")'</span> <span style="color: #ff0000;">rows=</span><span style="color: #0000ff;">"10"</span> <span style="color: #ff0000;">name=</span><span style="color: #0000ff;">"oResult"</span><span style="color: #000080; font-weight: bold;">&gt;&lt;/textarea&gt;</span>        <br />
   <span style="color: #000080; font-weight: bold;">&lt;p</span> <span style="color: #ff0000;">align=</span><span style="color: #0000ff;">"center"</span><span style="color: #000080; font-weight: bold;">&gt;</span> <span style="color: #000080; font-weight: bold;">&lt;input</span> <span style="color: #ff0000;">type=</span><span style="color: #0000ff;">"button"</span> <span style="color: #ff0000;">value=</span><span style="color: #0000ff;">"  清空  "</span> <span style="color: #ff0000;">name=</span><span style="color: #0000ff;">"B1"</span> <span style="color: #ff0000;">onclick=</span><span style="color: #0000ff;">"oSource.value='';showhideJSTag(change(oSource.value));"</span> <span style="color: #000080; font-weight: bold;">&gt;</span><span style="color: #000000;">&amp;nbsp;&amp;nbsp;&amp;nbsp;</span>   <span style="color: #000080; font-weight: bold;">&lt;input</span> <span style="color: #ff0000;">type=</span><span style="color: #0000ff;">"button"</span> <span style="color: #ff0000;">value=</span><span style="color: #0000ff;">"预览效果"</span> <span style="color: #ff0000;">name=</span><span style="color: #0000ff;">"B2"</span> <span style="color: #ff0000;">onclick=</span><span style="color: #0000ff;">"opentestwin(oResult.value);"</span><span style="color: #000080; font-weight: bold;">&gt;</span>  <span style="color: #000080; font-weight: bold;">&lt;br&gt;</span><br />
  <span style="color: #000080; font-weight: bold;">&lt;script </span><span style="color: #ff0000;">language=</span><span style="color: #0000ff;">"JavaScript"</span> <span style="color: #000080; font-weight: bold;">&gt;</span><br />
<span style="color: #000080; font-weight: bold;">function</span> <span style="color: #000000;">change</span>(<span style="color: #000000;">oSourceString</span><span style="color: #000000;">){</span><br />
<span style="color: #000080; font-weight: bold;">return</span>(<span style="color: #0000ff;">"document.writeln(\""</span><span style="color: #000000;">+</span><span style="color: #000000;">oSourceString</span><span style="color: #000000;">.</span><span style="color: #000000;">replace</span>(<span style="color: #0000ff;">/\\/g</span><span style="color: #000000;">,</span><span style="color: #0000ff;">"\\\\"</span><span style="color: #000000;">).</span><span style="color: #000000;">replace</span>(<span style="color: #0000ff;">/\//g</span><span style="color: #000000;">,</span><span style="color: #0000ff;">"\\/"</span><span style="color: #000000;">).</span><span style="color: #000000;">replace</span>(<span style="color: #0000ff;">/\'/g</span><span style="color: #000000;">,</span><span style="color: #0000ff;">"\\\'"</span><span style="color: #000000;">).</span><span style="color: #000000;">replace</span>(<span style="color: #0000ff;">/\"/g</span><span style="color: #000000;">,</span><span style="color: #0000ff;">"\\\""</span><span style="color: #000000;">).</span><span style="color: #000000;">split</span>(<span style="color: #0000ff;">'\r\n'</span><span style="color: #000000;">).</span><span style="color: #000000;">join</span>(<span style="color: #0000ff;">"\");\ndocument.writeln(\""</span>)<span style="color: #000000;">+</span><span style="color: #0000ff;">"\")"</span><span style="color: #000000;">+</span><span style="color: #0000ff;">";"</span>);<br />
<span style="color: #000000;">}</span><br />
<span style="color: #000080; font-weight: bold;">function</span>  <span style="color: #000000;">showhideJSTag</span>(<span style="color: #000000;">strjs</span>)<br />
<span style="color: #000000;">{</span><span style="color: #000080; font-weight: bold;">if</span>(<span style="color: #000000;">ShowJSTag</span><span style="color: #000000;">.</span><span style="color: #000000;">checked</span>)<br />
<span style="color: #000000;">oResult</span><span style="color: #000000;">.</span><span style="color: #000000;">value</span><span style="color: #000000;">=</span><span style="color: #0000ff;">"&lt;script language=javascript&gt;\n&lt;!--\n"</span><span style="color: #000000;">+</span><span style="color: #000000;">strjs</span><span style="color: #000000;">+</span><span style="color: #0000ff;">"\n//--&gt;\n&lt;/"</span><span style="color: #000000;">+</span><span style="color: #0000ff;">"script&gt;"</span>;<br />
<span style="color: #000080; font-weight: bold;">else</span><br />
<span style="color: #000000;">oResult</span><span style="color: #000000;">.</span><span style="color: #000000;">value</span><span style="color: #000000;">=</span><span style="color: #000000;">strjs</span>; <br />
<span style="color: #000000;">}</span><br />
<span style="font-style: italic; color: #008800;">//http:</span><br />
<span style="color: #000080; font-weight: bold;">function</span> <span style="color: #000000;">opentestwin</span>(<span style="color: #000000;">str</span>)                                    <br />
<span style="color: #000000;">{</span><span style="color: #000080; font-weight: bold;">var</span> <span style="color: #000000;">testwin</span><span style="color: #000000;">=</span><span style="color: #000000;">window</span><span style="color: #000000;">.</span><span style="color: #000000;">open</span>(<span style="color: #0000ff;">"test"</span><span style="color: #000000;">,</span><span style="color: #0000ff;">"_balnk"</span><span style="color: #000000;">,</span><span style="color: #0000ff;">"toolbar=no,location=no,directories=no,status=yes,menubar=yes,scrollbars=yes,resizable=yes"</span>);          <span style="color: #000000;">testwin</span><span style="color: #000000;">.</span><span style="color: #000000;">document</span><span style="color: #000000;">.</span><span style="color: #000000;">write</span>(<span style="color: #000000;">str</span>);                                 <br />
<span style="color: #000000;">}</span>      <br />
<span style="color: #000080; font-weight: bold;">&lt;/script&gt;</span><br />
<span style="color: #000080; font-weight: bold;">&lt;/body&gt;</span><br />
<span style="color: #000080; font-weight: bold;">&lt;/html&gt;</span></div>
<p>效果请见：<a title="HTML to Javascript" href="http://wange.im/tool/htmltojs/">http://wange.im/tool/htmltojs/</a></p>
<div id="rl_posts">    <div id="rl_posts_hd" class="box_hd">        <span id="rl_posts_title" class="box_title">与 <h2 itemprop="keywords"><a href="http://wange.im/tag/html/" title="HTML" rel="tag">HTML</a>,<a href="http://wange.im/tag/javascript/" title="Javascript" rel="tag">Javascript</a>,<a href="http://wange.im/tag/js/" title="JS" rel="tag">JS</a></h2> 相关的文章        </span>    </div>    <div id="rl_posts_bd">        <ul class="clearfix"><li>    <div class="rl_thumb"><img src="http://wange.im/wp-content/themes/wange/imgs/category/computer.jpg" alt="电脑网络" width="45" height="45" itemprop="thumbnailUrl" />    </div>    <div class="rl_title">        <a href="http://wange.im/jquery-js-ajax-pic.html" rel="bookmark" title="jQuery/JavaScript 实现的异步加载图片">jQuery/JavaScript 实现的异步加载图片</a>        <div class="rl_date">2011年04月10日</div>    </div></li><li>    <div class="rl_thumb"><img src="http://wange.im/wp-content/themes/wange/imgs/category/computer.jpg" alt="电脑网络" width="45" height="45" itemprop="thumbnailUrl" />    </div>    <div class="rl_title">        <a href="http://wange.im/ietester-version.html" rel="bookmark" title="最短最给力的 IE 版本判断脚本">最短最给力的 IE 版本判断脚本</a>        <div class="rl_date">2011年02月19日</div>    </div></li><li>    <div class="rl_thumb"><img src="http://wange.im/wp-content/themes/wange/timthumb.php?src=http://wange.im/cache/rss2.jpg&amp;h=45&amp;w=45&amp;zc=1" alt="JQuery 鼠标滑动渐隐渐显效果" width="45" height="45" itemprop="thumbnailUrl" />    </div>    <div class="rl_title">        <a href="http://wange.im/fadein-and-fadeout-with-jquery.html" rel="bookmark" title="JQuery 鼠标滑动渐隐渐显效果">JQuery 鼠标滑动渐隐渐显效果</a>        <div class="rl_date">2010年05月5日</div>    </div></li><li>    <div class="rl_thumb"><img src="http://wange.im/wp-content/themes/wange/timthumb.php?src=http://wange.im/cache/sweet-titles.jpg&amp;h=45&amp;w=45&amp;zc=1" alt="JQuery 鼠标提示特效之 Sweet Titles" width="45" height="45" itemprop="thumbnailUrl" />    </div>    <div class="rl_title">        <a href="http://wange.im/jquery-sweet-titles-tooltips.html" rel="bookmark" title="JQuery 鼠标提示特效之 Sweet Titles">JQuery 鼠标提示特效之 Sweet Titles</a>        <div class="rl_date">2010年03月14日</div>    </div></li>        </ul>    </div></div>]]></content:encoded>
			<wfw:commentRss>http://wange.im/html-to-javascript.html/feed</wfw:commentRss>
		<slash:comments>45</slash:comments>
		</item>
	</channel>
</rss>

