<?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>80年代 &#187; JavaScript</title>
	<atom:link href="http://hi1980.com/tag/javascript/feed" rel="self" type="application/rss+xml" />
	<link>http://hi1980.com</link>
	<description>热衷于IT WEB Flash Design Music</description>
	<lastBuildDate>Tue, 17 Aug 2010 07:01:39 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0</generator>
		<item>
		<title>用JS+CSS的方法左右对齐的DIV列表</title>
		<link>http://hi1980.com/2009/10/24/js-change-li-2.html</link>
		<comments>http://hi1980.com/2009/10/24/js-change-li-2.html#comments</comments>
		<pubDate>Sat, 24 Oct 2009 04:08:37 +0000</pubDate>
		<dc:creator>wulinfo</dc:creator>
				<category><![CDATA[社会大学]]></category>
		<category><![CDATA[CSS]]></category>
		<category><![CDATA[JavaScript]]></category>

		<guid isPermaLink="false">http://blog.hi1980.com/?p=589</guid>
		<description><![CDATA[调用数据库输出一个<li>列表横向排列时，而这个列表我想左右两边靠边（左右对齐父div），这样就需要对<li>做不同的class名以定义不同的样式。我用了一段JS规则动态修改<li>class（类名）。]]></description>
			<content:encoded><![CDATA[<p><a href="http://fdqujw.blu.livefilestore.com/y1pzRDjeLNEbyd5GXgcKgwDZxjnkDL35fwIZA1pA7nvFUCyZjR8d-tBhnt9NRWFZUe090PzXEq-mNW4u0zZoBctnPTZlluGuw86/js_css.jpg" class="highslide-image" onclick="return hs.expand(this);"><img class="alignleft" title="js_css" src="http://fdqujw.blu.livefilestore.com/y1pzRDjeLNEbyd5GXgcKgwDZxjnkDL35fwIZA1pA7nvFUCyZjR8d-tBhnt9NRWFZUe090PzXEq-mNW4u0zZoBctnPTZlluGuw86/js_css.jpg" alt="js_css" width="200" height="104" /></a>有些日子没有贴过代码了，都有些忘记了，写这类文章还是很懒的，测试写备注贴代码做演示等等都是让然抓狂的。</p>
<p>前些日子在制作主题遇到一个问题，当调用数据库输出一个&lt;li&gt;列表横向排列时，而这个列表我想左右两边靠边（左右对齐父div），这样就需要对&lt;li&gt;做不同的class名以定义不同的样式。当然实现这样的效果有很多解决的方法，但我用了一段JS规则动态修改class（类名）。</p>
<p>优点：省事/快捷/动态</p>
<p>缺点：js是最后面执行的，所以在页面其他内容未加载完成时，不能处理js，所以会造成短暂的样式失效，以及有部分用户的浏览器是禁止js的（反正我没见过这么变态的），这样就造成永远样式失效。<span id="more-589"></span></p>
<p>废话不多说，开始吧，注：class=box id=list   (i%4&gt;0) 等可自定义</p>
<p>html部分：调用数据库输出的列表</p>
<pre class="brush: xml;">
&lt;div class=box id=list&gt;&lt;!-- 调用数据库输出的列表--&gt;
&lt;ul&gt;
&lt;li&gt;1&lt;/li&gt;
&lt;li&gt;2&lt;/li&gt;
&lt;li&gt;3&lt;/li&gt;
&lt;li&gt;4&lt;/li&gt;
&lt;li&gt;5&lt;/li&gt;
&lt;li&gt;6&lt;/li&gt;
&lt;li&gt;7&lt;/li&gt;
&lt;li&gt;8&lt;/li&gt;
&lt;/ul&gt;
&lt;/div&gt;
</pre>
<p>JS部分：目的修改box的li className</p>
<pre class="brush: jscript;">
&lt;script type=&quot;text/javascript&quot;&gt;
&lt;!--
var Ptr=document.getElementById(&quot;list&quot;).getElementsByTagName(&quot;li&quot;);//指定的id 属性值得到对象
function $() {
      for (i=1;i&lt;Ptr.length+1;i++) {
      Ptr[i-1].className = (i%4&gt;0)?&quot;left&quot;:&quot;right&quot;;//修改className (i%4&gt;0)为节点
      }
}
window.onload=$;
//--&gt;
&lt;/script&gt;
</pre>
<p>html经过js动态修改后结果：</p>
<pre class="brush: xml;">
&lt;div class=box id=list&gt;
&lt;ul&gt;
&lt;li class=&quot;left&quot;&gt;1&lt;/li&gt;&lt;!-- 其他li className 均为left--&gt;
&lt;li class=&quot;left&quot;&gt;2&lt;/li&gt;
&lt;li class=&quot;left&quot;&gt;3&lt;/li&gt;
&lt;li class=&quot;right&quot;&gt;4&lt;/li&gt;&lt;!-- js规则每逢第四处添加li className为right--&gt;
&lt;li class=&quot;left&quot;&gt;5&lt;/li&gt;
&lt;li class=&quot;left&quot;&gt;6&lt;/li&gt;
&lt;li class=&quot;left&quot;&gt;7&lt;/li&gt;
&lt;li class=&quot;right&quot;&gt;8&lt;/li&gt;
&lt;/ul&gt;
&lt;/div&gt;
</pre>
<p>这样我们就获得到li的class=&#8221;left&#8221;和class=&#8221;right&#8221;两个不同的类名，这样我们就能为两组类名定义样式</p>
<p>css部分：给列表附上样式</p>
<pre class="brush: css;">
.box {background: #dedede;margin:0 auto;overflow:hidden;}
ul{ padding:0; margin:0;}
.box ul li {list-style:none;height:100px;width:100px;}
.box ul li.left {background-color:#666; margin:0 5px 5px 0; float:left;}/* 左样式 */
.box ul li.right {background-color:#999;margin:0 0 5px 0; float:right;}/* 右样式 */
</pre>
<p>演示：<a title="JS CSS DIV" href="http://code.hi1980.com/js/js+css.html" target="_blank">JS+CSS+DIV</a></p>
]]></content:encoded>
			<wfw:commentRss>http://hi1980.com/2009/10/24/js-change-li-2.html/feed</wfw:commentRss>
		<slash:comments>20</slash:comments>
		</item>
		<item>
		<title>ajax层打开效果</title>
		<link>http://hi1980.com/2009/06/24/ajax-loading-html-div.html</link>
		<comments>http://hi1980.com/2009/06/24/ajax-loading-html-div.html#comments</comments>
		<pubDate>Wed, 24 Jun 2009 15:47:01 +0000</pubDate>
		<dc:creator>wulinfo</dc:creator>
				<category><![CDATA[自言自语]]></category>
		<category><![CDATA[JavaScript]]></category>

		<guid isPermaLink="false">http://blog.hi1980.com/?p=548</guid>
		<description><![CDATA[缺陷：由于不能跨域,读取的文件须在同一域名下 操作：双击层关闭 演示页面 1.html 140*200 Flash播放器 2.html 500*210 图像小女孩 3.html 150*300 诗一剪梅 4.html 500*500 空白页面 仍在做进一步完善]]></description>
			<content:encoded><![CDATA[<p>缺陷：由于不能跨域,读取的文件须在同一域名下</p>
<p>操作：双击层关闭</p>
<p><a href="http://code.hi1980.com/js/ajax-div/ajax-div.html">演示页面</a></p>
<p><a href="javascript:OpenDiv(140,200,'1.html')">1.html 140*200</a> Flash播放器</p>
<p><a href="javascript:OpenDiv(502,212,'2.html')">2.html 500*210 </a>图像小女孩</p>
<p><a href="javascript:OpenDiv(150,300,'3.html')">3.html 150*300 </a>诗一剪梅</p>
<p><a href="javascript:OpenDiv(500,500,'4.html')">4.html 500*500</a> 空白页面</p>
<p>仍在做进一步完善</p>
]]></content:encoded>
			<wfw:commentRss>http://hi1980.com/2009/06/24/ajax-loading-html-div.html/feed</wfw:commentRss>
		<slash:comments>13</slash:comments>
		</item>
		<item>
		<title>提速-远程寄存</title>
		<link>http://hi1980.com/2009/06/03/speed-remote-storage.html</link>
		<comments>http://hi1980.com/2009/06/03/speed-remote-storage.html#comments</comments>
		<pubDate>Wed, 03 Jun 2009 14:36:58 +0000</pubDate>
		<dc:creator>wulinfo</dc:creator>
				<category><![CDATA[社会大学]]></category>
		<category><![CDATA[CSS]]></category>
		<category><![CDATA[gzip]]></category>
		<category><![CDATA[Html]]></category>
		<category><![CDATA[JavaScript]]></category>

		<guid isPermaLink="false">http://blog.hi1980.com/?p=532</guid>
		<description><![CDATA[由于主机商提供线路受限于CN，而我的主要访客大都来自本国CN，其次香港台湾韩国，为此我做了些优化测试，但失败告终，在此分享一下失败经验：远程寄存脚本]]></description>
			<content:encoded><![CDATA[<p>前些日子，一些朋友提醒我的站点很慢，我做了些测试，除了中国其他任何国家我的网站反应速度都还算不错，而我的主要访客大都来自本国CN，其次韩国香港台湾，这说明主机商提供的线路是受cn限制的，为此我做了些优化测试，在此分享一下经验：远程寄存脚本</p>
<p>由于本网站已经做了静态化和Gzip压缩，以及把图片等寄存在live.com等，所以唯一想到还能进行优化提速的是：远程寄存较大的脚本和CSS样式</p>
<p>我另存了一个页面到本地，发现其所有文件大小约：400KB大小，其中脚本占了近一半，虽然浏览器能缓存一部分文件，但首次访问还是需要从我这每秒传输约15KB的主机上读取，是相当久的，所以我决定寄存一些脚本到一些国内访问比较快的网站上供我的小站读取，类似谷歌提供jquery脚本引用。<span id="more-532"></span></p>
<blockquote><p>试验证明：部分脚本失败，CSS中图片相对路径出错</p></blockquote>
<p><a href="http://liregg.blu.livefilestore.com/y1pW0msljwVOmh0F0zlbHQSiMeaH_MmPw9A05L86G-GlI3iqWoo-5gl-W5_PVCHr1X-SOZp6U20kVxi1TqGzMjUgykPOP3g9xIP/CSS%E6%9C%AA%E5%8A%A0%E8%BD%BD%E5%9B%BE%E7%89%87.jpg" class="highslide-image" onclick="return hs.expand(this);"><img title="css不能加载图片" src="http://liregg.blu.livefilestore.com/y1pW0msljwVOmh0F0zlbHQSiMeaH_MmPw9ArdR96v6qel2PCwxNepMQ5TdQeYszFoU3qmKstwFVKYp8jyBBtPLy2vmKlwS83vfl/CSS%E6%9C%AA%E5%8A%A0%E8%BD%BD%E5%9B%BE%E7%89%87.jpg" alt="css不能加载图片" width="570" height="325" /></a></p>
<p>唉，有待测试，改日接着写</p>
]]></content:encoded>
			<wfw:commentRss>http://hi1980.com/2009/06/03/speed-remote-storage.html/feed</wfw:commentRss>
		<slash:comments>14</slash:comments>
		</item>
		<item>
		<title>Highslide4WP插件的完善</title>
		<link>http://hi1980.com/2009/05/13/highslide4wp-replenish.html</link>
		<comments>http://hi1980.com/2009/05/13/highslide4wp-replenish.html#comments</comments>
		<pubDate>Tue, 12 May 2009 18:56:04 +0000</pubDate>
		<dc:creator>wulinfo</dc:creator>
				<category><![CDATA[社会大学]]></category>
		<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[jQuery]]></category>

		<guid isPermaLink="false">http://blog.hi1980.com/?p=525</guid>
		<description><![CDATA[今天我鼠目獐头的四处转悠，忽然间瞄见Showfom所写的Auto HighSlide插件（其目的是增强Highslide），工作原理是通过jQuery侦测含链接的bmp&#124;gif&#124;jpeg&#124;jpg&#124;png等图片格式，然后补充上Highslide所需的点击事件，从而无需重新编辑文章中的图片插入代码，所以我提起了其精华部分并将它应用到Highslide4WP插件中（注：此插件后台可以插入专用属性图片，但缺少title和其他编辑属性，我想不理于SEO吧）]]></description>
			<content:encoded><![CDATA[<p>今天我鼠目獐头的四处转悠，忽然间瞄见<a href="http://showfom.com/">Showfom</a>所写的<a href="http://showfom.com/auto-hishslide-wordpress-plugin/">Auto HighSlide插件</a>（其目的是增强支持<a href="http://highslide.com/">Highslide</a>），工作原理是通过jQuery侦测含链接的bmp|gif|jpeg|jpg|png等图片格式，然后自动补充上<a href="http://highslide.com/">Highslide</a>所需的点击事件（查考下方）<span class="attribute-name">，从而无需重新编辑文章中的图片插入代码支持<a title="到writer主页" href="http://download.live.com/writer">Writer</a>、 <a title="到Raven主页" href="http://www.zoundry.com/">Raven</a>等本地客户端写博的用户。</span></p>
<p><span class="attribute-name">所以我提取了其精华部分并将它应用到</span><a href="http://www.neoease.com/highslide4wp/">Mg12</a><span class="attribute-name">的<a href="http://wordpress.org/extend/plugins/highslide4wp/">Highslide4WP插件</a>中（注：此插件后台可以插入专用属性图片，但缺少title和其他编辑属性，我想不利于SEO吧），这样安装过</span><a href="http://wordpress.org/extend/plugins/highslide4wp/">Highslide4WP插件</a><span class="attribute-name">的朋友无需逐一编辑文章就能应用博客的中的所有含链接的图片，同样后台插入图片和常规一样，无需额外添加</span>Highslide所需的鼠标点击事件。<span class="attribute-name"><span id="more-525"></span></span></p>
<p>Highslide所需的鼠标点击事件</p>
<pre class="brush: xml;">class=&quot;highslide-image&quot; onclick=&quot;return hs.expand(this);&quot;</pre>
<p><br class="spacer_" /></p>
<p><span class="attribute-value">下面的代码作用就是自动</span><span class="attribute-value">为</span><span class="attribute-value">每张含链接的图片加入上面的</span>鼠标点击事件</p>
<pre class="brush: jscript;">/* Add HighSlide Image Code  by:Showfom*/
add_filter('the_content', 'addhighslideclass_replace');
function addhighslideclass_replace ($content)
{   global $post;
$pattern = &quot;/&lt;a(.*?)href=('|\&quot;)([^&gt;]*).(bmp|gif|jpeg|jpg|png)('|\&quot;)(.*?)&gt;(.*?)&lt;\/a&gt;/i&quot;;
$replacement = '&lt;a$1href=$2$3.$4$5 class=&quot;highslide-image&quot; onclick=&quot;return hs.expand(this);&quot;$6&gt;$7&lt;/a&gt;';
$content = preg_replace($pattern, $replacement, $content);
return $content;
}
/* Add HighSlide */</pre>
<p>编辑<a href="http://wordpress.org/extend/plugins/highslide4wp/">Highslide4WP</a>插件目录中的highslide4wp.php文件在14行中插入上面的代码即可</p>
<p>解决在IE出现点击关闭表情返回顶部问题</p>
<p>打开插件目录toys.php查找class=&#8221;highslide-close“</p>
<p>&lt;a href=&#8221;#&#8221;  修改成 &lt;a href=&#8221;javascript:void(0);&#8221; 即可解决此问题</p>
]]></content:encoded>
			<wfw:commentRss>http://hi1980.com/2009/05/13/highslide4wp-replenish.html/feed</wfw:commentRss>
		<slash:comments>34</slash:comments>
		</item>
		<item>
		<title>Ctrl+Enter提交(JS)</title>
		<link>http://hi1980.com/2009/04/15/ctrl-enter-submit.html</link>
		<comments>http://hi1980.com/2009/04/15/ctrl-enter-submit.html#comments</comments>
		<pubDate>Tue, 14 Apr 2009 17:16:50 +0000</pubDate>
		<dc:creator>wulinfo</dc:creator>
				<category><![CDATA[社会大学]]></category>
		<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[主题]]></category>

		<guid isPermaLink="false">http://blog.hi1980.com/?p=466</guid>
		<description><![CDATA[给你的主题添加 CTRL+ENTER 快捷键提交效果，其实比较简单的东西就不详述了，主要是通过JS侦查键盘值而触发提交ID，从而达到和鼠标点击按钮提交一样的效果。]]></description>
			<content:encoded><![CDATA[<p>给你的主题添加 CTRL+ENTER 快捷键提交效果，其实比较简单的东西就不详述了，主要是通过JS侦查键盘值而触发提交ID，从而达到和鼠标点击按钮提交一样的效果。</p>
<p>方法：主题下为form添加下面的JS代码，或者另存JS文件然后引入JS</p>
<pre class="brush: jscript;">&lt;script type=&quot;text/javascript&quot;&gt;
document.getElementById(&quot;comment&quot;).onkeydown = function (moz_ev)
{
var ev = null;
if (window.event){
ev = window.event;
}else{
ev = moz_ev;
}
if (ev != null &amp;&amp; ev.ctrlKey &amp;&amp; ev.keyCode == 13)
{
document.getElementById(&quot;submit&quot;).click();
}
}
&lt;/script&gt;
</pre>
<p><br class="spacer_" /></p>
]]></content:encoded>
			<wfw:commentRss>http://hi1980.com/2009/04/15/ctrl-enter-submit.html/feed</wfw:commentRss>
		<slash:comments>14</slash:comments>
		</item>
	</channel>
</rss>

<!-- www.000webhost.com Analytics Code -->
<script type="text/javascript" src="http://analytics.hosting24.com/count.php"></script>
<noscript><a href="http://www.hosting24.com/"><img src="http://analytics.hosting24.com/count.php" alt="web hosting" /></a></noscript>
<!-- End Of Analytics Code -->
