<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" media="screen" href="/~d/styles/rss2full.xsl"?><?xml-stylesheet type="text/css" media="screen" href="http://feeds.feedburner.com/~d/styles/itemcontent.css"?><rss 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/" version="2.0">

<channel>
	<title>GOVO's Blog</title>
	
	<link>http://blog.guitarbean.com</link>
	<description>Front-end web developer——[to be a better man]</description>
	<lastBuildDate>Sat, 11 Jul 2009 07:39:13 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.1</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="self" href="http://feeds.feedburner.com/govo" type="application/rss+xml" /><item>
		<title>IE运行时设置name属性的BUG</title>
		<link>http://blog.guitarbean.com/2009/07/setting-the-name-attribute-in-internet-explorer.html</link>
		<comments>http://blog.guitarbean.com/2009/07/setting-the-name-attribute-in-internet-explorer.html#comments</comments>
		<pubDate>Sat, 11 Jul 2009 07:39:13 +0000</pubDate>
		<dc:creator>GOVO</dc:creator>
				<category><![CDATA[其它]]></category>

		<guid isPermaLink="false">http://blog.guitarbean.com/?p=496</guid>
		<description><![CDATA[在刚完成的项目中遇到用javascript动态创建的单选按钮在IE中无法选中的情况，在排除脚本逻辑错误后百思不得其解的情况下搜索到原来这是个IE下的BUG：
The NAME attribute cannot be set at run time on elements dynamically created with the createElement method. To create an element with a name attribute, include the attribute and value when using the createElement method.
中文的文章可以看这里http://www.javaeye.com/topic/26917。
其中两个参考文献链接：
http://alt-tag.com/blog/archives/2006/02/ie-dom-bugs/，
http://www.thunderguy.com/semicolon/2005/05/23/setting-the-name-attribute-in-internet-explorer/
这个BUG使得无法使用document.createElement(&#8221;input&#8221;); 创建我们想要的input标签，但可以这样：

document.createElement&#40;'&#60;input type=&#34;radio&#34; name=&#34;username&#34; &#62;'&#41;;

当然这不是W3C支持的做法，所以在FF中无效，全面一点的函数是：

function createElement&#40;type, name&#41; &#123;
   var element = null;
   try &#123;
    [...]]]></description>
			<content:encoded><![CDATA[<p>在刚完成的项目中遇到用javascript动态创建的单选按钮在IE中无法选中的情况，在排除脚本逻辑错误后百思不得其解的情况下搜索到原来这是个IE下的BUG：</p>
<blockquote><p>The NAME attribute cannot be set at run time on elements dynamically created with the createElement method. To create an element with a name attribute, include the attribute and value when using the createElement method.</p></blockquote>
<p>中文的文章可以看这里<a href="http://www.javaeye.com/topic/26917">http://www.javaeye.com/topic/26917</a>。<br />
其中两个参考文献链接：<br />
<a href="http://alt-tag.com/blog/archives/2006/02/ie-dom-bugs/">http://alt-tag.com/blog/archives/2006/02/ie-dom-bugs/</a>，<br />
<a href="http://www.thunderguy.com/semicolon/2005/05/23/setting-the-name-attribute-in-internet-explorer/">http://www.thunderguy.com/semicolon/2005/05/23/setting-the-name-attribute-in-internet-explorer/</a></p>
<p>这个BUG使得无法使用document.createElement(&#8221;input&#8221;); 创建我们想要的input标签，但可以这样：</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;">document.<span style="color: #660066;">createElement</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'&lt;input type=&quot;radio&quot; name=&quot;username&quot; &gt;'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p>当然这不是W3C支持的做法，所以在FF中无效，全面一点的函数是：</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #003366; font-weight: bold;">function</span> createElement<span style="color: #009900;">&#40;</span>type<span style="color: #339933;">,</span> <span style="color: #000066;">name</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
   <span style="color: #003366; font-weight: bold;">var</span> element <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">null</span><span style="color: #339933;">;</span>
   <span style="color: #000066; font-weight: bold;">try</span> <span style="color: #009900;">&#123;</span>
      <span style="color: #006600; font-style: italic;">// First try the IE way; if this fails then use the standard way</span>
      element <span style="color: #339933;">=</span> document.<span style="color: #660066;">createElement</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'&lt;'</span><span style="color: #339933;">+</span>type<span style="color: #339933;">+</span><span style="color: #3366CC;">' name=&quot;'</span><span style="color: #339933;">+</span><span style="color: #000066;">name</span><span style="color: #339933;">+</span><span style="color: #3366CC;">'&quot;&gt;'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
   <span style="color: #009900;">&#125;</span> <span style="color: #000066; font-weight: bold;">catch</span> <span style="color: #009900;">&#40;</span>e<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
      <span style="color: #006600; font-style: italic;">// Probably failed because we’re not running on IE</span>
   <span style="color: #009900;">&#125;</span>
   <span style="color: #000066; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #339933;">!</span>element<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
      element <span style="color: #339933;">=</span> document.<span style="color: #660066;">createElement</span><span style="color: #009900;">&#40;</span>type<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
      element.<span style="color: #000066;">name</span> <span style="color: #339933;">=</span> <span style="color: #000066;">name</span><span style="color: #339933;">;</span>
   <span style="color: #009900;">&#125;</span>
   <span style="color: #000066; font-weight: bold;">return</span> element<span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<p>然后对属性的设置需要使用：</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;">element.<span style="color: #660066;">setAttribute</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;type&quot;</span><span style="color: #339933;">,</span> <span style="color: #3366CC;">&quot;radio&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p>如果你使用了jQuery，可以直接使用jQuery(html)来创建它：</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;">elm<span style="color: #339933;">=</span>$<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'&lt;input type=&quot;radio&quot; name=&quot;username&quot; /&gt;'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p>不过，jQuery这个方法也得先把type写进去，否则会抛出<strong>uncaught exception: type property can&#8217;t be changed</strong>异常。</p>
<img src="http://blog.guitarbean.com/?ak_action=api_record_view&id=496&type=feed" alt="" />]]></content:encoded>
			<wfw:commentRss>http://blog.guitarbean.com/2009/07/setting-the-name-attribute-in-internet-explorer.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>wordpress2.8升级失败中</title>
		<link>http://blog.guitarbean.com/2009/06/wordpress28-upgrade-failure.html</link>
		<comments>http://blog.guitarbean.com/2009/06/wordpress28-upgrade-failure.html#comments</comments>
		<pubDate>Sat, 20 Jun 2009 11:20:05 +0000</pubDate>
		<dc:creator>GOVO</dc:creator>
				<category><![CDATA[其它]]></category>

		<guid isPermaLink="false">http://blog.guitarbean.com/?p=493</guid>
		<description><![CDATA[在升级到2.8时似乎失败了，出现的问题是后台一片混乱，只有回退到2.7了，使得当中一些侧栏工具重新设置了一下，目前情况不怎么好，等待2.8.1再升ORZ
]]></description>
			<content:encoded><![CDATA[<p>在升级到2.8时似乎失败了，出现的问题是后台一片混乱，只有回退到2.7了，使得当中一些侧栏工具重新设置了一下，目前情况不怎么好，等待2.8.1再升ORZ</p>
<img src="http://blog.guitarbean.com/?ak_action=api_record_view&id=493&type=feed" alt="" />]]></content:encoded>
			<wfw:commentRss>http://blog.guitarbean.com/2009/06/wordpress28-upgrade-failure.html/feed</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>A video of CSXY</title>
		<link>http://blog.guitarbean.com/2009/05/a-video-of-csxy.html</link>
		<comments>http://blog.guitarbean.com/2009/05/a-video-of-csxy.html#comments</comments>
		<pubDate>Mon, 04 May 2009 17:41:09 +0000</pubDate>
		<dc:creator>GOVO</dc:creator>
				<category><![CDATA[其它]]></category>

		<guid isPermaLink="false">http://blog.guitarbean.com/?p=486</guid>
		<description><![CDATA[Hi guys, did you remember the game &#8220;Genesis Journey to the West&#8220;? I&#8217;ve made a short introduce here.
Now ,here is a video of the game. It was created by the players while playing it. Take a look and have fun!

创世西游官方论坛及178论坛同步发布
]]></description>
			<content:encoded><![CDATA[<p>Hi guys, did you remember the game &#8220;<a href="http://csxy.163.com/">Genesis Journey to the West</a>&#8220;? I&#8217;ve made a short introduce <a href="http://blog.guitarbean.com/2009/04/genesis-journey-to-the-west.html">here</a>.<br />
Now ,here is a video of the game. It was created by the players while playing it. Take a look and have fun!<br />
<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" width="420" height="363" align="middle"><param name="movie" value="http://www.tudou.com/v/Un90I2bqjlA" /><param name="allowScriptAccess" value="always" /><param name="allowFullScreen" value="true" /><param name="quality" value="high" /><param name="wmode" value="transparent" /><embed src="http://www.tudou.com/v/Un90I2bqjlA" quality="high" width="420" height="363" align="middle" allowScriptAccess="always" allowFullScreen="true" wmode="transparent" type="application/x-shockwave-flash" /></object><br />
创世西游官方论坛及178论坛同步发布</p>
<img src="http://blog.guitarbean.com/?ak_action=api_record_view&id=486&type=feed" alt="" />]]></content:encoded>
			<wfw:commentRss>http://blog.guitarbean.com/2009/05/a-video-of-csxy.html/feed</wfw:commentRss>
		<slash:comments>8</slash:comments>
		</item>
		<item>
		<title>Genesis Journey to the West</title>
		<link>http://blog.guitarbean.com/2009/04/genesis-journey-to-the-west.html</link>
		<comments>http://blog.guitarbean.com/2009/04/genesis-journey-to-the-west.html#comments</comments>
		<pubDate>Sun, 05 Apr 2009 10:35:26 +0000</pubDate>
		<dc:creator>GOVO</dc:creator>
				<category><![CDATA[其它]]></category>
		<category><![CDATA[game]]></category>
		<category><![CDATA[genesis]]></category>
		<category><![CDATA[online game]]></category>

		<guid isPermaLink="false">http://blog.guitarbean.com/?p=477</guid>
		<description><![CDATA[
Genesis Journey to the West is the most sepecial online game I have ever seen in China with it&#8217;s beautiful art style.
The background story of the game is an ancient Chinese Myths about how the world was created.
It is said that the world is created by giant Pangu.He broke the the cosmic egg then the sky [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://csxy.163.com/"><img class="size-full" title="csxy" src="http://blog.guitarbean.com/wp-content/uploads/2009/04/qxxz.jpg" alt="csxy" width="458" height="210" /></a></p>
<p>Genesis Journey to the West is the most sepecial online game I have ever seen in China with it&#8217;s beautiful art style.</p>
<p>The background story of the game is an ancient Chinese Myths about how the world was created.</p>
<p>It is said that the world is created by giant Pangu.He broke the the cosmic egg then the sky and the earth was  formed. when he died, his body went to make the world and all its elements.For example his voice was thunder and lightning, his left eye became the sun and the right one become moon. And the parasites on his body became the divers races of humankind, and so on.(<a href="http://www.livingmyths.com/Chinese.htm">Chinese Myths</a>.)</p>
<p>As the human become more and more clever, they got more and more powers and skills.Then the six main races of humankind were formed.</p>
<p>Two of the human races were  <em>Xiuluo</em> and <em>Tiandao</em>. They hated each other and fight for years. In one of the fightings, the King of <em>Xiuluo</em> ,called <em>XiuluoWang</em> was defeated,and his soul was putted in to a stone.Days later,that stone was exploded a monkey was borned. This was the Monkey King, Sun Wukong, which was knew by all nowadays.</p>
<p>That was the backound story of online game Genesis Journey to the West. The game is on beta now. If you are interested in it, <a href="http://survey2.163.com/html/parttime_tester_recruiting/paper.html">you can apply for a serial number here</a> . <a href="http://csxy.163.com/download/client.html">Download</a> the game, <a href="http://csxy.163.com/">home page</a> of the game, <a href="http://csxy.netease.com/">forum</a> of the game, and <a href="http://csxy.163.com/photo/painting.html">arts of the game</a>.</p>
<p><span class="trans">Here is  some arts of the game:</span><br />
<a href="http://csxy.163.com/photo/painting.html"><img src="http://farm4.static.flickr.com/3550/3414366572_881ffaa5cd_m.jpg" alt="" /></a><a href="http://csxy.163.com/photo/painting.html"><img src="http://farm4.static.flickr.com/3203/3413561079_da9d3981aa_m.jpg" alt="" /></a><a href="http://csxy.163.com/photo/painting.html"> <img src="http://farm4.static.flickr.com/3048/3413561805_0ceb977855_m.jpg" alt="" /></a><a href="http://csxy.163.com/photo/painting.html"><img src="http://farm4.static.flickr.com/3318/3414368302_cb5a8a90ac_m.jpg" alt="" /><br />
</a></p>
<img src="http://blog.guitarbean.com/?ak_action=api_record_view&id=477&type=feed" alt="" />]]></content:encoded>
			<wfw:commentRss>http://blog.guitarbean.com/2009/04/genesis-journey-to-the-west.html/feed</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>解决AS3自定义滑鼠光标失焦的方法</title>
		<link>http://blog.guitarbean.com/2009/03/solution-as3-custom-mouse-cursor-out-of-focus-method.html</link>
		<comments>http://blog.guitarbean.com/2009/03/solution-as3-custom-mouse-cursor-out-of-focus-method.html#comments</comments>
		<pubDate>Tue, 31 Mar 2009 13:53:38 +0000</pubDate>
		<dc:creator>GOVO</dc:creator>
				<category><![CDATA[其它]]></category>

		<guid isPermaLink="false">http://blog.guitarbean.com/?p=470</guid>
		<description><![CDATA[在flash里自定义滑鼠光标形状是件很容易而且很觉的事件，但在AS3里却有另一个问题，就是鼠标会被自定义的MC元件遮挡住而无法点击下面的元件。

（如果您无法查看此flash，请点击这里查看。）
式神达人说AS2是不会有这个问题的。我觉得，这正是AS3的改进之处：逻辑更规范合理了（当然也有人觉得AS3很累赘很麻烦，因为代码多了   ）。
在这里，当MC手型元件跟着光标跑时，真正的光标焦点就落在MC上了，此时MC手型可被点击，而MC手型下方的就被挡住了，光标就无法穿越MC手型到达下面的物件了，这就是原因。解决方法就是取消MC手型的光标，让它不可点击，这样光标焦点就可以重新跳到下一层了。
解决方法的关键代码是：

myCursor.mouseEnabled = false;
myCursor.mouseChildren = false;

为什么AS3要这样做？因为MC手型元件在实质上并不是一个光标，它只是跟着光标运动的一个普通的元件而已，它应该也拥有同样被点击的权利，除非你刻意不允许，而只有不允许时才更适合做一个光标MC。
 
以上内容参考自：Tips for Using Custom Mouse Cursors in Flash AS3
]]></description>
			<content:encoded><![CDATA[<p>在flash里自定义滑鼠光标形状是件很容易而且很觉的事件，但在AS3里却有另一个问题，就是鼠标会被自定义的MC元件遮挡住而无法点击下面的元件。</p>
<p><object width="277" height="125" data="http://danielmclaren.net/files/public/2008/custom_mouse_cursors/custom_mouse_cursors.swf" type="application/x-shockwave-flash"><param name="id" value="custom_mouse_cursorsObject" /><param name="allowScriptAccess" value="always" /><param name="base" value="http://danielmclaren.net/files/public/2008/custom_mouse_cursors/." /><param name="quality" value="high" /><param name="bgcolor" value="#ffffff" /><param name="scale" value="noscale" /><param name="src" value="http://danielmclaren.net/files/public/2008/custom_mouse_cursors/custom_mouse_cursors.swf" /><param name="align" value="middle" /></object><br />
（如果您无法查看此flash，<a href="http://danielmclaren.net/2008/03/tips-for-using-custom-mouse-cursors-in-flash-as3">请点击这里查看</a>。）</p>
<p>式神达人说AS2是不会有这个问题的。我觉得，这正是AS3的改进之处：逻辑更规范合理了（当然也有人觉得AS3很累赘很麻烦，因为代码多了 <img src='http://blog.guitarbean.com/wp-includes/images/smilies/icon_razz.gif' alt=':P' class='wp-smiley' />  ）。</p>
<p>在这里，当MC手型元件跟着光标跑时，真正的光标焦点就落在MC上了，此时MC手型可被点击，而MC手型下方的就被挡住了，光标就无法穿越MC手型到达下面的物件了，这就是原因。解决方法就是取消MC手型的光标，让它不可点击，这样光标焦点就可以重新跳到下一层了。</p>
<p>解决方法的关键代码是：</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;">myCursor.<span style="color: #660066;">mouseEnabled</span> <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">false</span><span style="color: #339933;">;</span>
myCursor.<span style="color: #660066;">mouseChildren</span> <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">false</span><span style="color: #339933;">;</span></pre></div></div>

<p>为什么AS3要这样做？因为MC手型元件在实质上并不是一个光标，它只是跟着光标运动的一个普通的元件而已，它应该也拥有同样被点击的权利，除非你刻意不允许，而只有不允许时才更适合做一个光标MC。</p>
<p><object height="125" width="100%" id="custom_mouse_cursors_niceObject" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0" classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000"><param value="always" name="allowScriptAccess"/><param value="http://danielmclaren.net/files/public/2008/custom_mouse_cursors/." name="base"/><param value="http://danielmclaren.net/files/public/2008/custom_mouse_cursors/custom_mouse_cursors_nice.swf" name="movie"/><param value="" name="flashvars"/><param value="high" name="quality"/><param value="#ffffff" name="bgcolor"/><param value="noscale" name="scale"/><embed height="125" width="100%" align="middle" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" allowscriptaccess="always" scale="noscale" base="http://danielmclaren.net/files/public/2008/custom_mouse_cursors/." flashvars="" bgcolor="#ffffff" quality="high" src="http://danielmclaren.net/files/public/2008/custom_mouse_cursors/custom_mouse_cursors_nice.swf" id="custom_mouse_cursors_niceEmbed"/> </object></p>
<p>以上内容参考自：<a href="http://danielmclaren.net/2008/03/tips-for-using-custom-mouse-cursors-in-flash-as3">Tips for Using Custom Mouse Cursors in Flash AS3</a></p>
<img src="http://blog.guitarbean.com/?ak_action=api_record_view&id=470&type=feed" alt="" />]]></content:encoded>
			<wfw:commentRss>http://blog.guitarbean.com/2009/03/solution-as3-custom-mouse-cursor-out-of-focus-method.html/feed</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Javascript多个不重复随机数</title>
		<link>http://blog.guitarbean.com/2009/03/javascript-does-not-duplicate-a-number-of-random-numbers.html</link>
		<comments>http://blog.guitarbean.com/2009/03/javascript-does-not-duplicate-a-number-of-random-numbers.html#comments</comments>
		<pubDate>Wed, 11 Mar 2009 12:20:17 +0000</pubDate>
		<dc:creator>GOVO</dc:creator>
				<category><![CDATA[其它]]></category>

		<guid isPermaLink="false">http://blog.guitarbean.com/?p=459</guid>
		<description><![CDATA[关于命题，我曾在google上搜索了很久，发现多数人对这个命题不感兴趣，当然部分同学说可以用离散什么的，哎呀，偶除了冒泡算法，可真不知道什么离散算法。笨人有笨办法，于是我写出了下面的一个代码：


var rmArrayElement=function&#40;i,arr&#41;&#123;return arr.slice&#40;0,i&#41;.concat&#40;arr.slice&#40;i+1&#41;&#41;;&#125;;//返回移除了第i个数组的新数组
var rand=function&#40;n&#41;&#123;return Math.floor&#40;Math.random&#40;&#41;*&#40;parseInt&#40;n&#41; &#124;&#124; 1&#41;&#41;;&#125;;//返回小于n的整数随机数
var rands=function&#40;n,c&#41;&#123;//返回小于n的c个不重复的整数随机数
	var i=0,
	_reArr=&#91;&#93;,//结果
	c=&#40;typeof&#40;parseInt&#40;c&#41;&#41;==&#34;number&#34; &#38;&#38; c&#62;1 &#38;&#38; c&#60;=n&#41;?c:1,//随机数个数修正
	_tempRand=null,//所抓取的随机序号
	_tempArr=&#91;&#93;;//临时数组
	for&#40;i=0;i&#60;n;i++&#41;&#123;_tempArr=_tempArr.concat&#40;&#91;i&#93;&#41;;&#125;//生成临时数组，此处有待改善:P
	for&#40;i=0;i&#60;c;i++&#41;&#123;//循环不大于c次
		_tempRand=rand&#40;_tempArr.length&#41;;//得到随机序号
		_reArr=_reArr.concat&#40;&#91;_tempArr&#91;_tempRand&#93;&#93;&#41;;//从临时数组中抓1个随机数
		_tempArr=rmArrayElement&#40;_tempRand,_tempArr&#41;;//在临时数组中删除已抓取的数组
	&#125;
	return _reArr;//返回最终结果
&#125;;

这个代码的特点：
循环次数不超n+c次，可用于生成多个不重复的随机数。
缺点：n可能很大。。。。。。
建议用于100以内的随机数生成。例如，有50个广告，每次随机显示3个。
也可以用于把序号进行随机打散，如rands(20,20)：
[9,19,17,14,0,1,15,4,6,8,11,12,18,13,2,3,16,7,10,5]
这个代码经过变化，还可以变成取得区间内的随机数的函数，有兴趣的同学可以去试一试。不过上面的代码有一个缺憾，就是n这个数可能会很大，多数人找随机数是找9999999以内的随机数。但这么大的数，随便取十多个也来也不怕会有重复了   。
另外，把生成临时数组部分进行改善，也会有很大的效率提升哦，只是我还没想到更好的办法，或者完全不用这个方法。
还有，这个东西很神奇：

Array.prototype.riffle = function&#40;&#41;&#123;
    var sf = function&#40;&#41;&#123; return 0.5 - Math.random&#40;&#41;; &#125;
    this.sort&#40;sf&#41;.sort&#40;sf&#41;;
&#125;

代码从这里找到的，我还百思不得其解，为什么这样的洗牌会让数组乱序，真的太神奇了，如果可以这样，那就简单多了，只要洗一次牌，然后取前n个数组不就可解决前面的问题了吗！
唉，我发觉自己对javascript真的越来越无知了   。请各位多多指教，THX！
]]></description>
			<content:encoded><![CDATA[<p>关于命题，我曾在google上搜索了很久，发现多数人对这个命题不感兴趣，当然部分同学说可以用离散什么的，哎呀，偶除了冒泡算法，可真不知道什么离散算法。笨人有笨办法，于是我写出了下面的一个代码：<br />
<span id="more-459"></span></p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #003366; font-weight: bold;">var</span> rmArrayElement<span style="color: #339933;">=</span><span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span>i<span style="color: #339933;">,</span>arr<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span><span style="color: #000066; font-weight: bold;">return</span> arr.<span style="color: #660066;">slice</span><span style="color: #009900;">&#40;</span><span style="color: #CC0000;">0</span><span style="color: #339933;">,</span>i<span style="color: #009900;">&#41;</span>.<span style="color: #660066;">concat</span><span style="color: #009900;">&#40;</span>arr.<span style="color: #660066;">slice</span><span style="color: #009900;">&#40;</span>i<span style="color: #339933;">+</span><span style="color: #CC0000;">1</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><span style="color: #009900;">&#125;</span><span style="color: #339933;">;</span><span style="color: #006600; font-style: italic;">//返回移除了第i个数组的新数组</span>
<span style="color: #003366; font-weight: bold;">var</span> rand<span style="color: #339933;">=</span><span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span>n<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span><span style="color: #000066; font-weight: bold;">return</span> Math.<span style="color: #660066;">floor</span><span style="color: #009900;">&#40;</span>Math.<span style="color: #660066;">random</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">*</span><span style="color: #009900;">&#40;</span>parseInt<span style="color: #009900;">&#40;</span>n<span style="color: #009900;">&#41;</span> <span style="color: #339933;">||</span> <span style="color: #CC0000;">1</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><span style="color: #009900;">&#125;</span><span style="color: #339933;">;</span><span style="color: #006600; font-style: italic;">//返回小于n的整数随机数</span>
<span style="color: #003366; font-weight: bold;">var</span> rands<span style="color: #339933;">=</span><span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span>n<span style="color: #339933;">,</span>c<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span><span style="color: #006600; font-style: italic;">//返回小于n的c个不重复的整数随机数</span>
	<span style="color: #003366; font-weight: bold;">var</span> i<span style="color: #339933;">=</span><span style="color: #CC0000;">0</span><span style="color: #339933;">,</span>
	_reArr<span style="color: #339933;">=</span><span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">,</span><span style="color: #006600; font-style: italic;">//结果</span>
	c<span style="color: #339933;">=</span><span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">typeof</span><span style="color: #009900;">&#40;</span>parseInt<span style="color: #009900;">&#40;</span>c<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">==</span><span style="color: #3366CC;">&quot;number&quot;</span> <span style="color: #339933;">&amp;&amp;</span> c<span style="color: #339933;">&gt;</span><span style="color: #CC0000;">1</span> <span style="color: #339933;">&amp;&amp;</span> c<span style="color: #339933;">&lt;=</span>n<span style="color: #009900;">&#41;</span><span style="color: #339933;">?</span>c<span style="color: #339933;">:</span><span style="color: #CC0000;">1</span><span style="color: #339933;">,</span><span style="color: #006600; font-style: italic;">//随机数个数修正</span>
	_tempRand<span style="color: #339933;">=</span><span style="color: #003366; font-weight: bold;">null</span><span style="color: #339933;">,</span><span style="color: #006600; font-style: italic;">//所抓取的随机序号</span>
	_tempArr<span style="color: #339933;">=</span><span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span><span style="color: #006600; font-style: italic;">//临时数组</span>
	<span style="color: #000066; font-weight: bold;">for</span><span style="color: #009900;">&#40;</span>i<span style="color: #339933;">=</span><span style="color: #CC0000;">0</span><span style="color: #339933;">;</span>i<span style="color: #339933;">&lt;</span>n<span style="color: #339933;">;</span>i<span style="color: #339933;">++</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>_tempArr<span style="color: #339933;">=</span>_tempArr.<span style="color: #660066;">concat</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#91;</span>i<span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><span style="color: #009900;">&#125;</span><span style="color: #006600; font-style: italic;">//生成临时数组，此处有待改善:P</span>
	<span style="color: #000066; font-weight: bold;">for</span><span style="color: #009900;">&#40;</span>i<span style="color: #339933;">=</span><span style="color: #CC0000;">0</span><span style="color: #339933;">;</span>i<span style="color: #339933;">&lt;</span>c<span style="color: #339933;">;</span>i<span style="color: #339933;">++</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span><span style="color: #006600; font-style: italic;">//循环不大于c次</span>
		_tempRand<span style="color: #339933;">=</span>rand<span style="color: #009900;">&#40;</span>_tempArr.<span style="color: #660066;">length</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><span style="color: #006600; font-style: italic;">//得到随机序号</span>
		_reArr<span style="color: #339933;">=</span>_reArr.<span style="color: #660066;">concat</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#91;</span>_tempArr<span style="color: #009900;">&#91;</span>_tempRand<span style="color: #009900;">&#93;</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><span style="color: #006600; font-style: italic;">//从临时数组中抓1个随机数</span>
		_tempArr<span style="color: #339933;">=</span>rmArrayElement<span style="color: #009900;">&#40;</span>_tempRand<span style="color: #339933;">,</span>_tempArr<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><span style="color: #006600; font-style: italic;">//在临时数组中删除已抓取的数组</span>
	<span style="color: #009900;">&#125;</span>
	<span style="color: #000066; font-weight: bold;">return</span> _reArr<span style="color: #339933;">;</span><span style="color: #006600; font-style: italic;">//返回最终结果</span>
<span style="color: #009900;">&#125;</span><span style="color: #339933;">;</span></pre></div></div>

<p>这个代码的特点：<br />
循环次数不超n+c次，可用于生成多个不重复的随机数。<br />
缺点：n可能很大。。。。。。<br />
建议用于100以内的随机数生成。例如，有50个广告，每次随机显示3个。<br />
也可以用于把序号进行随机打散，如rands(20,20)：<br />
<code>[9,19,17,14,0,1,15,4,6,8,11,12,18,13,2,3,16,7,10,5]</code></p>
<p>这个代码经过变化，还可以变成取得区间内的随机数的函数，有兴趣的同学可以去试一试。不过上面的代码有一个缺憾，就是n这个数可能会很大，多数人找随机数是找9999999以内的随机数。但这么大的数，随便取十多个也来也不怕会有重复了 <img src='http://blog.guitarbean.com/wp-includes/images/smilies/icon_razz.gif' alt=':P' class='wp-smiley' />  。</p>
<p>另外，把生成临时数组部分进行改善，也会有很大的效率提升哦，只是我还没想到更好的办法，或者完全不用这个方法。<br />
还有，这个东西很神奇：</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;">Array.<span style="color: #660066;">prototype</span>.<span style="color: #660066;">riffle</span> <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
    <span style="color: #003366; font-weight: bold;">var</span> sf <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span> <span style="color: #000066; font-weight: bold;">return</span> <span style="color: #CC0000;">0.5</span> <span style="color: #339933;">-</span> Math.<span style="color: #660066;">random</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #009900;">&#125;</span>
    <span style="color: #000066; font-weight: bold;">this</span>.<span style="color: #660066;">sort</span><span style="color: #009900;">&#40;</span>sf<span style="color: #009900;">&#41;</span>.<span style="color: #660066;">sort</span><span style="color: #009900;">&#40;</span>sf<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<p>代码从<a href="http://bbs.51js.com/archiver/tid-73468.html">这里</a>找到的，我还百思不得其解，为什么这样的洗牌会让数组乱序，真的太神奇了，如果可以这样，那就简单多了，只要洗一次牌，然后取前n个数组不就可解决前面的问题了吗！</p>
<p>唉，我发觉自己对javascript真的越来越无知了 <img src='http://blog.guitarbean.com/wp-includes/images/smilies/icon_cry.gif' alt=':cry:' class='wp-smiley' />  。请各位多多指教，THX！</p>
<img src="http://blog.guitarbean.com/?ak_action=api_record_view&id=459&type=feed" alt="" />]]></content:encoded>
			<wfw:commentRss>http://blog.guitarbean.com/2009/03/javascript-does-not-duplicate-a-number-of-random-numbers.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Dreamweaver CS4的一个恼人功能</title>
		<link>http://blog.guitarbean.com/2009/03/dreamweaver-cs4s-an-annoying-feature.html</link>
		<comments>http://blog.guitarbean.com/2009/03/dreamweaver-cs4s-an-annoying-feature.html#comments</comments>
		<pubDate>Wed, 11 Mar 2009 03:37:08 +0000</pubDate>
		<dc:creator>GOVO</dc:creator>
				<category><![CDATA[其它]]></category>

		<guid isPermaLink="false">http://blog.guitarbean.com/?p=457</guid>
		<description><![CDATA[请先看图：

Dreamweaver CS4的确增加了很多实时功能，在网页编辑方面很有效，但这个脚本实时错误提示就十分恼人   ！
什么恼人法？它反应太敏感啦，很多时候我们写一个var，稍稍停一停就弹个提示出来了，而且每次弹出会把整个编辑区域下推，搞得整个画面在眼前晃了一晃，这一晃，它不脑残我倒差点脑残了＝。＝
如上面的截图，就是我在改代码时，页面突然一跳，就选择错了，然后Ctrl+v……问题是，我到现在还不知如何取消它   

我想这可能是学IE的，如上图。但在编辑器方面，最好学Eclipse系列的，如下图Aptana的错误提示，在左边的行号提示，或者直接在代码下加波浪线。

有人问我：那你为什么不直接用Apatana编写JS呢？难道我写个小东西也要打开Apatana么？
其实Dreamweaver很早之前就有在代码下加波浪线的习惯了，为什么不贯彻下去呢？
]]></description>
			<content:encoded><![CDATA[<p>请先看图：</p>
<p><a title="dwcs4 by ejialin, on Flickr" href="http://www.flickr.com/photos/govo/3346000708/"><img src="http://farm4.static.flickr.com/3351/3346000708_c3f3c3f51e_o.png" alt="dwcs4" width="538" height="232" /></a><br />
Dreamweaver CS4的确增加了很多实时功能，在网页编辑方面很有效，但这个脚本实时错误提示就十分恼人 <img src='http://blog.guitarbean.com/wp-includes/images/smilies/icon_evil.gif' alt=':evil:' class='wp-smiley' />  ！</p>
<p>什么恼人法？它反应太敏感啦，很多时候我们写一个var，稍稍停一停就弹个提示出来了，而且每次弹出会把整个编辑区域下推，搞得整个画面在眼前晃了一晃，这一晃，它不脑残我倒差点脑残了＝。＝</p>
<p>如上面的截图，就是我在改代码时，页面突然一跳，就选择错了，然后Ctrl+v……问题是，我到现在还不知如何取消它  <img src='http://blog.guitarbean.com/wp-includes/images/smilies/icon_neutral.gif' alt=':|' class='wp-smiley' /> </p>
<p><a title="iealert by ejialin, on Flickr" href="http://www.flickr.com/photos/govo/3346069626/"><img src="http://farm4.static.flickr.com/3580/3346069626_6e8fae6d28_o.jpg" alt="iealert" width="243" height="224" /></a></p>
<p>我想这可能是学IE的，如上图。但在编辑器方面，最好学Eclipse系列的，如下图Aptana的错误提示，在左边的行号提示，或者直接在代码下加波浪线。</p>
<p><a title="aptanaalert by ejialin, on Flickr" href="http://www.flickr.com/photos/govo/3345248323/"><img src="http://farm4.static.flickr.com/3336/3345248323_a2e777d49b_o.jpg" alt="aptanaalert" width="287" height="201" /></a></p>
<p>有人问我：那你为什么不直接用Apatana编写JS呢？难道我写个小东西也要打开Apatana么？</p>
<p>其实Dreamweaver很早之前就有在代码下加波浪线的习惯了，为什么不贯彻下去呢？</p>
<img src="http://blog.guitarbean.com/?ak_action=api_record_view&id=457&type=feed" alt="" />]]></content:encoded>
			<wfw:commentRss>http://blog.guitarbean.com/2009/03/dreamweaver-cs4s-an-annoying-feature.html/feed</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>诺基亚中国可能已大量泄漏客户信息</title>
		<link>http://blog.guitarbean.com/2009/02/nokia-china-may-have-been-substantial-leakage-of-customer-information.html</link>
		<comments>http://blog.guitarbean.com/2009/02/nokia-china-may-have-been-substantial-leakage-of-customer-information.html#comments</comments>
		<pubDate>Fri, 13 Feb 2009 12:19:45 +0000</pubDate>
		<dc:creator>GOVO</dc:creator>
				<category><![CDATA[其它]]></category>

		<guid isPermaLink="false">http://blog.guitarbean.com/?p=445</guid>
		<description><![CDATA[更新：相关链接《315晚会揭秘个人隐私泄漏 百元能买千条信息》，“其中，移动运营商通过出售用户信息，帮助发送垃圾短信谋取利益”。
诺基亚行货手机在开箱上卡时，会给10657109082580发送一条短信，让客户加入MY NOKAI，并偶尔地发送一些关于本手机的使用TIPS；而客户可以回复00取消订阅此类信息。
同样，我在1月3日购买诺基亚N79时，也执行了同样的操作，第二天，居然收到手机使用TIPS的短信，提示如何快速切换为“无声模式”，回复00取消订阅【诺基亚】。我开始还不知道是怎么回事，上网查到说这是诺基亚的一个信息服务，号码来源显示来自北京。我觉得这服务还算贴心，还据说不会扣你钱。然后第3天，我却收到一条这样的信息：
发牛人：1066013510267848
标题：配置信息
内容：名称：*补发一首Mp3-保存有效
网址：http://nokiu.cn/b?v=rX20bv09Ad
我一开始还以为直的有补发Mp3，但仔细看链接，并不是nokia的，而是nokiu.cn，山寨！骗子短信！我马上把它放到垃圾短信里，并把它加入黑名单 ，但这样没有用，到现在已是2月中了，依然会不时的收到那个号码的骚扰信息。网友wcgsxf 说他关闭了手机网络服务信息的接收,该信息从来没有停止过,一个月3-5条,相当烦恼，从链接进去还被扣收4元一条的信息费（标准为2元）。
上网查这个号码，网友说这是深圳的号，信息是通过飞信发送的，收到这条信息的不只我一个，而且似乎都是使用诺基亚智能机的网友，为什么？我觉得有两种可能：
1、诺基亚中国泄漏了客户的信息；
2、中移动漏泄客户信息；
为什么我会怀疑中移动？请看《深圳普威德恶意发送带有欺诈嫌疑的网址配置信息，多次扣费》。过程可能是中移动通过过滤收集发向诺基亚的这条信息，得到客户的机型信息，某此人通过向这类用户进行欺诈。这样有用户投诉了，也不进行处理。（汗，想必此人很高层。。。。）
但我觉得第一种情况最有可能，因为诺基亚收集来的信息最全面，而且诺基亚中国的MY NOKIA服务站应该比不上中移动这样大的机构，只要相关的内部操作人员一查即可得到客户信息。相反，如果想在中移动上做手脚的话会更难一点。而且这个号码的发送方式似乎很了解MY NOKIA服务信息的发送方式，第一条信息就是等MY NOKIA发过信息后才去发欺诈信息，所以这很可能就是诺基亚中国内部出的问题了。
但不管是哪一方的问题，诺基亚和中移动谁都逃不了责任。虽然我在这里唠叨没什么用，但似乎投诉也没什么用，那各位就看着办吧，我也只是小百姓个，最多练练忍耐能力。。。。
如果想知道更多的关于1066013510267848这个号码的资料，可以上google搜索一下。列出几个相关的网址给大家看看：
[1].诺基亚的手机，1066013510267848发来的短信？ 
[2].1066013510267848此号码是骗子号码
[3].服务信息可以点吗
PS：本文标题党成份比较多，各位看客请BS之，哈哈！  
]]></description>
			<content:encoded><![CDATA[<p><ins datetime="2009-03-16T01:25:43+00:00"><strong>更新：</strong>相关链接<a href="http://news.163.com/09/0316/07/54GQF1UV0001124J.html">《315晚会揭秘个人隐私泄漏 百元能买千条信息》</a>，“其中，移动运营商通过出售用户信息，帮助发送垃圾短信谋取利益”。</ins></p>
<p>诺基亚行货手机在开箱上卡时，会给10657109082580发送一条短信，让客户加入MY NOKAI，并偶尔地发送一些关于本手机的使用TIPS；而客户可以回复00取消订阅此类信息。</p>
<p>同样，我在1月3日购买诺基亚N79时，也执行了同样的操作，第二天，居然收到手机使用TIPS的短信，提示如何快速切换为“无声模式”，回复00取消订阅【诺基亚】。我开始还不知道是怎么回事，上网查到说这是诺基亚的一个信息服务，号码来源显示来自北京。我觉得这服务还算贴心，还据说不会扣你钱。然后第3天，我却收到一条这样的信息：</p>
<blockquote><p>发牛人：1066013510267848</p>
<p>标题：配置信息</p>
<p>内容：名称：*补发一首Mp3-保存有效</p>
<p>网址：http://nokiu.cn/b?v=rX20bv09Ad</p></blockquote>
<p>我一开始还以为直的有补发Mp3，但仔细看链接，并不是nokia的，而是nokiu.cn，山寨！骗子短信！我马上把它放到垃圾短信里，并把它加入黑名单 ，但这样没有用，到现在已是2月中了，依然会不时的收到那个号码的骚扰信息。网友wcgsxf 说他关闭了手机网络服务信息的接收,该信息从来没有停止过,一个月3-5条,相当烦恼，从链接进去还被扣收4元一条的信息费（标准为2元）。</p>
<p>上网查这个号码，网友说这是深圳的号，信息是通过飞信发送的，收到这条信息的不只我一个，而且似乎都是使用诺基亚智能机的网友，为什么？我觉得有两种可能：</p>
<p>1、诺基亚中国泄漏了客户的信息；</p>
<p>2、中移动漏泄客户信息；</p>
<p>为什么我会怀疑中移动？请看<a href="http://www.315ts.net/archive/tousu/2009/0103/281830.shtml" target="_blank">《深圳普威德恶意发送带有欺诈嫌疑的网址配置信息，多次扣费》</a>。过程可能是中移动通过过滤收集发向诺基亚的这条信息，得到客户的机型信息，某此人通过向这类用户进行欺诈。这样有用户投诉了，也不进行处理。（汗，想必此人很高层。。。。）</p>
<p>但我觉得第一种情况最有可能，因为诺基亚收集来的信息最全面，而且诺基亚中国的MY NOKIA服务站应该比不上中移动这样大的机构，只要相关的内部操作人员一查即可得到客户信息。相反，如果想在中移动上做手脚的话会更难一点。而且这个号码的发送方式似乎很了解MY NOKIA服务信息的发送方式，第一条信息就是等MY NOKIA发过信息后才去发欺诈信息，所以这很可能就是诺基亚中国内部出的问题了。</p>
<p>但不管是哪一方的问题，诺基亚和中移动谁都逃不了责任。虽然我在这里唠叨没什么用，但似乎投诉也没什么用，那各位就看着办吧，我也只是小百姓个，最多练练忍耐能力。。。。</p>
<p>如果想知道更多的关于1066013510267848这个号码的资料，可以上google搜索一下。列出几个相关的网址给大家看看：</p>
<p>[1].<a href="http://wenwen.soso.com/z/q110260143.htm" target="_blank">诺基亚的手机，1066013510267848发来的短信？ </a></p>
<p>[2].<a href="http://bbs.dospy.com/thread-2888034-1-1.html" target="_blank">1066013510267848此号码是骗子号码</a></p>
<p>[3].<a href="http://www.dospy.com/bbs/thread-2235777-1-1.html" target="_blank">服务信息可以点吗</a></p>
<p>PS：本文标题党成份比较多，各位看客请BS之，哈哈！ <img src='http://blog.guitarbean.com/wp-includes/images/smilies/icon_twisted.gif' alt=':twisted:' class='wp-smiley' /> </p>
<img src="http://blog.guitarbean.com/?ak_action=api_record_view&id=445&type=feed" alt="" />]]></content:encoded>
			<wfw:commentRss>http://blog.guitarbean.com/2009/02/nokia-china-may-have-been-substantial-leakage-of-customer-information.html/feed</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>Mobile Version is available博客手机版可用了！</title>
		<link>http://blog.guitarbean.com/2009/01/mobile-version-is-available.html</link>
		<comments>http://blog.guitarbean.com/2009/01/mobile-version-is-available.html#comments</comments>
		<pubDate>Wed, 07 Jan 2009 08:49:14 +0000</pubDate>
		<dc:creator>GOVO</dc:creator>
				<category><![CDATA[其它]]></category>

		<guid isPermaLink="false">http://blog.guitarbean.com/?p=429</guid>
		<description><![CDATA[
您现在可以随时切换到手机版和完全版来访问我的博客了。加后缀?mobile可切换为手机版，加?nomobile强制切换为完全版，对手机移动设备，多数可自动识别而切换为手机版，当然，对于使用iphone等其它较高级移动设备的用户，可以强制切回完全版。两个版本的页面上的头部和底部都可以找到相应的模式切换链接，点击即可相互切换了。
这个功能我是通过Mobilepress插件来实现的，能实现手机版功能的插件有很多，不过我觉得这个在文章内容方面还原得比较好，所以就用它了。如果你有需要，上网搜索一下，找到你喜欢的吧！
Hi guys! You can switch to mobile version or full version state to view my blog now!   Add ?mobile or ?nomobile to switch to mobile version or full vision.   Most of the mobile device can detect which version to display. You can switch to each other by the links at the top or bottom of [...]]]></description>
			<content:encoded><![CDATA[<p><img class="size-full wp-image-428 alignright" style="margin-left: 10px; margin-right: 10px;" title="mobiale" src="http://blog.guitarbean.com/wp-content/uploads/2009/01/mobiale.png" alt="mobiale" width="284" height="500" /></p>
<p>您现在可以随时切换到<a href="?mobile&PHPSESSID=b9cd5c3828ac1ae879af67d69967518c">手机版</a>和<a href="?nomobile&PHPSESSID=b9cd5c3828ac1ae879af67d69967518c">完全版</a>来访问我的博客了。加后缀?mobile可切换为手机版，加?nomobile强制切换为完全版，对手机移动设备，多数可自动识别而切换为手机版，当然，对于使用iphone等其它较高级移动设备的用户，可以强制切回完全版。两个版本的页面上的头部和底部都可以找到相应的模式切换链接，点击即可相互切换了。</p>
<p>这个功能我是通过<a href="http://mobilepress.co.za/" target="_blank">Mobilepress</a>插件来实现的，能实现手机版功能的插件有很多，不过我觉得这个在文章内容方面还原得比较好，所以就用它了。如果你有需要，上网搜索一下，找到你喜欢的吧！</p>
<p>Hi guys! You can switch to mobile version or full version state to view my blog now!   Add ?mobile or ?nomobile to switch to mobile version or full vision.   Most of the mobile device can detect which version to display. You can switch to each other by the links at the top or bottom of each view.</p>
<p>I am using <a href="http://mobilepress.co.za/" target="_blank">Mobilepress</a> to make mobile version. I think it the best one I have seen. Welcome introduce me more plugs, thank you!</p>
<img src="http://blog.guitarbean.com/?ak_action=api_record_view&id=429&type=feed" alt="" />]]></content:encoded>
			<wfw:commentRss>http://blog.guitarbean.com/2009/01/mobile-version-is-available.html/feed</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>什么是Array.prototype.slice.call</title>
		<link>http://blog.guitarbean.com/2008/12/what-is-arrayprototypeslicecall.html</link>
		<comments>http://blog.guitarbean.com/2008/12/what-is-arrayprototypeslicecall.html#comments</comments>
		<pubDate>Sun, 21 Dec 2008 10:15:15 +0000</pubDate>
		<dc:creator>GOVO</dc:creator>
				<category><![CDATA[其它]]></category>
		<category><![CDATA[array]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[prototype]]></category>
		<category><![CDATA[slice]]></category>

		<guid isPermaLink="false">http://blog.guitarbean.com/?p=414</guid>
		<description><![CDATA[上次写了一篇《Array.prototype.slice.call自解》，主要是讲我在学习Currying in Javascript时所遇到的一个小问题，即为什么很多人把[].slice()写成了Array.prototype.slice.call(ArrObj)，有朋友说此文质量太差，所以偶重写一次，看看能不能说清楚问题。
Array.prototype.slice.call 其实是对slice方法进行的静态调用。这里说的静态调用，主要区别于OOP方式。OOP方式需要先建立对象，如下：
[].slice(begin,end);
在JS中，[]就是一个数组对象，在执行时，先会建立对象，再执行自身对象下的slice方法，对这个数组进行切割。
而静态调用与OOP方式调用主要目的是静态方式的机器执行效率较高，因为不需要先经过建立对象，而不需要为对象增加内在开销，所以这种写法在较底层的JS程序（如JS框架，兼容性基础库）里面使用得比较多。
Array.prototype.slice就是这样的一个函数，如果要知道为什么不直接写slice而写那么长的三个单词，这不是三言两语说和清楚的，请看JavaScript中的prototype(原型)属性研究 ，如果简单点说，可以用伪代码表示：

Array.prototype.slice=function&#40;begin,end&#41;&#123;
  var arr=this;//this就是被切割的函数
  var newArr=我只要arr数组的begin到end中间的部分;//这才是真正的中文编程
  return newArr;//返回被切割后的新数组，强大吧！
&#125;

然后，通过调用函数的call方法：call(thisObj,begin,end)，把里面的this强制转换成将要被切割的数组，即术语中的改变函数的scope，从而完成切割。
使用情况：
这个语句通常用于把arguments转换为数组。

function fn&#40;&#41; &#123;
  a = Array.prototype.slice.call&#40;arguments,0&#41;;
  alert&#40;a&#41;;
&#125;&#40;1,2,3,4,5,6,7,'never-online.net/blog'&#41;

该代码片段摘自CSDN WEB开发社区的某帖的2楼。
函数的argements在JS1.5中只是一个类似数组的对象，有length属性，但并不是真正的数组，具体请看：Array-like Objects in JavaScript。(据说在ECMA script2中将会是个真正的数组了)
注意：这个语句可不能随便用哦，有的同学把String作为对象转进去，把abcde变为[a,b,c,d,e]，这可不是万试万灵的哦，不同的浏览器对slice的解释是有所区别的哦。例如Prototype.js中的$A函数也可以把arguments转为单纯数组，但为了适应更多的情况，它直接使用循环来实现了。
相关文章：

Currying JavaScript Functions
JavaScript Currying Redux
JavaScript currying
functional.js 介绍及源码分析
Array.prototype.slice.apply 使用技巧
Array-like Objects in JavaScript
JavaScript中的prototype(原型)属性研究
http://topic.csdn.net/u/20080725/09/162cb47f-be44-44bf-adcf-2a0ea7538454.html

UPDATE:我写的研究和学习总结性的技术文章，除非是比较重要和大型的项目，否则不会给出直接的代码和可下载的例子，更加不会像幼儿园教小朋友那样手把手的第一步第二步，也不想那样做，以后也不打算那样做，因为我发现越来越多人根本就不想自己动手，习惯性的拿来主义不利于业界的长久发展。
]]></description>
			<content:encoded><![CDATA[<p>上次写了一篇《<a href="http://blog.guitarbean.com/2008/04/understandingo-arrayprototypesliceapply.html">Array.prototype.slice.call自解</a>》，主要是讲我在学习Currying in Javascript时所遇到的一个小问题，即为什么很多人把[].slice()写成了Array.prototype.slice.call(ArrObj)，有朋友说此文质量太差，所以偶重写一次，看看能不能说清楚问题。</p>
<p>Array.prototype.slice.call 其实是对slice方法进行的静态调用。这里说的静态调用，主要区别于OOP方式。OOP方式需要先建立对象，如下：</p>
<p><code>[].slice(begin,end);</code></p>
<p>在JS中，[]就是一个数组对象，在执行时，先会建立对象，再执行自身对象下的slice方法，对这个数组进行<a title="[新窗口中打开]" href="http://blog.guitarbean.com/2008/04/method-array-slice.html" target="_blank">切割</a>。</p>
<p>而静态调用与OOP方式调用主要目的是静态方式的机器执行效率较高，因为不需要先经过建立对象，而不需要为对象增加内在开销，所以这种写法在较底层的JS程序（如JS框架，兼容性基础库）里面使用得比较多。</p>
<p>Array.prototype.slice就是这样的一个函数，如果要知道为什么不直接写slice而写那么长的三个单词，这不是三言两语说和清楚的，请看<a title="[新窗口中打开]" href="http://jetway.javaeye.com/blog/56533" target="_blank">JavaScript中的prototype(原型)属性研究</a> ，如果简单点说，可以用伪代码表示：</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;">Array.<span style="color: #660066;">prototype</span>.<span style="color: #660066;">slice</span><span style="color: #339933;">=</span><span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span>begin<span style="color: #339933;">,</span>end<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
  <span style="color: #003366; font-weight: bold;">var</span> arr<span style="color: #339933;">=</span><span style="color: #000066; font-weight: bold;">this</span><span style="color: #339933;">;</span><span style="color: #006600; font-style: italic;">//this就是被切割的函数</span>
  <span style="color: #003366; font-weight: bold;">var</span> newArr<span style="color: #339933;">=</span>我只要arr数组的begin到end中间的部分<span style="color: #339933;">;</span><span style="color: #006600; font-style: italic;">//这才是真正的中文编程</span>
  <span style="color: #000066; font-weight: bold;">return</span> newArr<span style="color: #339933;">;</span><span style="color: #006600; font-style: italic;">//返回被切割后的新数组，强大吧！</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<p>然后，通过调用函数的<a href="http://www.devguru.com/Technologies/ecmascript/quickref/call.html" target="_blank">call方法</a>：call(thisObj,begin,end)，把里面的this强制转换成将要被切割的数组，即术语中的改变函数的scope，从而完成切割。</p>
<p><strong>使用情况：</strong><br />
这个语句通常用于把arguments转换为数组。</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #003366; font-weight: bold;">function</span> fn<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
  a <span style="color: #339933;">=</span> Array.<span style="color: #660066;">prototype</span>.<span style="color: #660066;">slice</span>.<span style="color: #660066;">call</span><span style="color: #009900;">&#40;</span>arguments<span style="color: #339933;">,</span><span style="color: #CC0000;">0</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  <span style="color: #000066;">alert</span><span style="color: #009900;">&#40;</span>a<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#40;</span><span style="color: #CC0000;">1</span><span style="color: #339933;">,</span><span style="color: #CC0000;">2</span><span style="color: #339933;">,</span><span style="color: #CC0000;">3</span><span style="color: #339933;">,</span><span style="color: #CC0000;">4</span><span style="color: #339933;">,</span><span style="color: #CC0000;">5</span><span style="color: #339933;">,</span><span style="color: #CC0000;">6</span><span style="color: #339933;">,</span><span style="color: #CC0000;">7</span><span style="color: #339933;">,</span><span style="color: #3366CC;">'never-online.net/blog'</span><span style="color: #009900;">&#41;</span></pre></div></div>

<p>该代码片段摘自CSDN WEB开发社区的<a href="http://topic.csdn.net/u/20080725/09/162cb47f-be44-44bf-adcf-2a0ea7538454.html" target="_blank">某帖</a>的2楼。</p>
<p>函数的argements在JS1.5中只是一个类似数组的对象，有length属性，但并不是真正的数组，具体请看：<a title="Permanent Link to Array-like Objects in JavaScript" rel="bookmark" href="http://shifteleven.com/articles/2007/06/28/array-like-objects-in-javascript">Array-like Objects in JavaScript</a>。(据说在ECMA script2中将会是个真正的数组了)</p>
<p><strong>注意：</strong>这个语句可不能随便用哦，有的同学把String作为对象转进去，把abcde变为[a,b,c,d,e]，这可不是万试万灵的哦，不同的浏览器对slice的解释是有所区别的哦。例如Prototype.js中的$A函数也可以把arguments转为单纯数组，但为了适应更多的情况，它直接使用循环来实现了。</p>
<p><strong>相关文章：</strong></p>
<ol>
<li><a href="http://ajaxcookbook.org/currying-javascript-functions/">Currying JavaScript Functions</a></li>
<li><a title="Permanent Link: JavaScript Currying Redux" rel="bookmark" href="http://www.coryhudson.com/blog/2007/03/10/javascript-currying-redux/">JavaScript Currying Redux</a></li>
<li><a title="Read the entire post " rel="bookmark" href="http://www.dustindiaz.com/javascript-curry/">JavaScript currying</a></li>
<li><a href="http://lichray.javaeye.com/blog/105854">functional.js 介绍及源码分析</a></li>
<li><a href="http://www.ipcw.net/Article/200712/20071225210924.html">Array.prototype.slice.apply 使用技巧</a></li>
<li><a title="Permanent Link to Array-like Objects in JavaScript" rel="bookmark" href="http://shifteleven.com/articles/2007/06/28/array-like-objects-in-javascript">Array-like Objects in JavaScript</a></li>
<li><a title="[新窗口中打开]" href="http://jetway.javaeye.com/blog/56533" target="_blank">JavaScript中的prototype(原型)属性研究</a></li>
<li><a href="http://topic.csdn.net/u/20080725/09/162cb47f-be44-44bf-adcf-2a0ea7538454.html">http://topic.csdn.net/u/20080725/09/162cb47f-be44-44bf-adcf-2a0ea7538454.html</a></li>
</ol>
<p><ins datetime="2008-12-22T05:27:58+00:00">UPDATE:我写的研究和学习总结性的技术文章，除非是比较重要和大型的项目，否则不会给出直接的代码和可下载的例子，更加不会像幼儿园教小朋友那样手把手的第一步第二步，也不想那样做，以后也不打算那样做，因为我发现越来越多人根本就不想自己动手，习惯性的拿来主义不利于业界的长久发展。</ins></p>
<img src="http://blog.guitarbean.com/?ak_action=api_record_view&id=414&type=feed" alt="" />]]></content:encoded>
			<wfw:commentRss>http://blog.guitarbean.com/2008/12/what-is-arrayprototypeslicecall.html/feed</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
	</channel>
</rss>
