<?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>Silentash-默尘</title>
	<atom:link href="http://blog.silentash.com/feed" rel="self" type="application/rss+xml" />
	<link>http://blog.silentash.com</link>
	<description>尘埃默默，风雨洗礼</description>
	<lastBuildDate>Tue, 24 Aug 2010 16:31:08 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>doctype与hover伪类</title>
		<link>http://blog.silentash.com/2010/08/elements-hover-in-quirks-mode/?fuckgfw</link>
		<comments>http://blog.silentash.com/2010/08/elements-hover-in-quirks-mode/?fuckgfw#comments</comments>
		<pubDate>Tue, 24 Aug 2010 16:06:33 +0000</pubDate>
		<dc:creator>nunumick</dc:creator>
				<category><![CDATA[WEB标准]]></category>
		<category><![CDATA[XHTML/CSS]]></category>
		<category><![CDATA[doctype]]></category>
		<category><![CDATA[hover]]></category>
		<category><![CDATA[quirks mode]]></category>
		<category><![CDATA[文档类型]]></category>

		<guid isPermaLink="false">http://blog.silentash.com/?p=703</guid>
		<description><![CDATA[开发过程中将demo中的内容拆分进各子模块，发现之前好好的 hover 效果失效了，我排查的结果是因为在模块中没有定义doctype，页面默认使用 quirks mode，会导致非链接&#60;a&#62;标签的 hover 伪类在 IE7/8 和 firefox 均失去效果。

我们通常认为的非 IE6 以下浏览器都支持链接以外元素的 hover 伪类，其实还需要依赖 doctype，比如这样的代码就在 IE7/8 和 firefox 失去效果：
<pre><code>&#60;html&#62;
    &#60;head&#62;
        &#60;style&#62;
        .hover-test:hover{color:#f00;}
    &#60;/style&#62;
    &#60;/head&#62;
    &#60;body&#62;
        &#60;a class="hover-test" href="#"&#62;hover字体变红&#60;/a&#62;
        &#60;p class="hover-test"&#62;hover字体变红,Quirks mode下失效&#60;/p&#62;
    &#60;/body&#62;
&#60;/html&#62;
</code>
</pre>
从<a href="http://msdn.microsoft.com/en-us/library/ee371281(v=Expression.30).aspx">MSDN</a>找到相关说法：
<code>Internet Explorer 7 and later, in standards-compliant mode (strict 
!DOCTYPE), can apply the :hover pseudo-class to any element, not merely
 links.
</code>

而 Firefox 与 IE 也有区别，Firefox 下用标签名作为选择器可以使 hover 伪类恢复效用：
<pre><code>&#60;html&#62;
    &#60;head&#62;
        &#60;style&#62;
        p.hover-test:hover{color:#f00;}
        &#60;/style&#62;
    &#60;/head&#62;
    &#60;body&#62;
        &#60;a class="hover-test" href="#"&#62;hover字体变红&#60;/a&#62;
        &#60;p class="hover-test"&#62;hover字体变红&#60;/p&#62;
    &#60;/body&#62;
&#60;/html&#62;
</code>
</pre>

相关推荐：
<a href="http://blog.silentash.com/2010/01/html5-doctype-and-img-space/?fuckgfw">html5 doctype与图片多余空白</a>
<a href="http://blog.silentash.com/2008/10/doctype-and-box-model/?fuckgfw">doctype对盒子模型的影响</a>]]></description>
			<content:encoded><![CDATA[<p>开发过程中将demo中的内容拆分进各子模块，发现之前好好的 hover 效果失效了，我排查的结果是因为在模块中没有定义doctype，页面默认使用 quirks mode，会导致非链接&lt;a&gt;标签的 hover 伪类在 IE7/8 和 firefox 均失去效果。</p>
<p>我们通常认为的非 IE6 以下浏览器都支持链接以外元素的 hover 伪类，其实还需要依赖 doctype，比如这样的代码就在 IE7/8 和 firefox 失去效果：</p>
<pre class="chili"><code class="html">&lt;html&gt;
    &lt;head&gt;
        &lt;style&gt;
        .hover-test:hover{color:#f00;}
    &lt;/style&gt;
    &lt;/head&gt;
    &lt;body&gt;
        &lt;a class=&quot;hover-test&quot; href=&quot;#&quot;&gt;hover字体变红&lt;/a&gt;
        &lt;p class=&quot;hover-test&quot;&gt;hover字体变红,Quirks mode下失效&lt;/p&gt;
    &lt;/body&gt;
&lt;/html&gt;
</code></pre>
<p>从<a href="http://msdn.microsoft.com/en-us/library/ee371281(v=Expression.30).aspx">MSDN</a>找到相关说法：</p>
<pre class="chili"><code>Internet Explorer 7 and later, in standards-compliant mode (strict
!DOCTYPE), can apply the :hover pseudo-class to any element, not merely
 links.
</code></pre>
<p>而 Firefox 与 IE 也有区别，Firefox 下用标签名作为选择器可以使 hover 伪类恢复效用：</p>
<pre class="chili"><code class="html">&lt;html&gt;
    &lt;head&gt;
        &lt;style&gt;
        p.hover-test:hover{color:#f00;}
        &lt;/style&gt;
    &lt;/head&gt;
    &lt;body&gt;
        &lt;a class=&quot;hover-test&quot; href=&quot;#&quot;&gt;hover字体变红&lt;/a&gt;
        &lt;p class=&quot;hover-test&quot;&gt;hover字体变红&lt;/p&gt;
    &lt;/body&gt;
&lt;/html&gt;
</code></pre>
<p>相关推荐：<br />
<a href="http://blog.silentash.com/2010/01/html5-doctype-and-img-space/?fuckgfw">html5 doctype与图片多余空白</a><br />
<a href="http://blog.silentash.com/2008/10/doctype-and-box-model/?fuckgfw">doctype对盒子模型的影响</a></p>
<hr /><small>Copyright &copy; 2008-2010<br /> This feed is for personal, non-commercial use only. <br /> </small>]]></content:encoded>
			<wfw:commentRss>http://blog.silentash.com/2010/08/elements-hover-in-quirks-mode/?fuckgfw/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>用PHP将HTML页面转换为JSONP</title>
		<link>http://blog.silentash.com/2010/07/php-make-html-into-jsonp/?fuckgfw</link>
		<comments>http://blog.silentash.com/2010/07/php-make-html-into-jsonp/?fuckgfw#comments</comments>
		<pubDate>Sat, 24 Jul 2010 03:05:58 +0000</pubDate>
		<dc:creator>nunumick</dc:creator>
				<category><![CDATA[JS/Ajax/AS/Flex]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[file_get_contents]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[jsonp]]></category>
		<category><![CDATA[readfile]]></category>
		<category><![CDATA[格式化]]></category>

		<guid isPermaLink="false">http://blog.silentash.com/?p=667</guid>
		<description><![CDATA[<h3>背景</h3>
异步跨域请求时JSONP方式是最靠谱的选择，常规的，被请求页面应该返回诸如此类的数据格式：
<code>handleName="xxx";doSomething();...;
</code>
需要时，我们还可以返回其他的JS语句，只要符合语法即可。
<p style="text-align:center;color:#e1e1e1;">- - - - - - -分割线- - - - - - - </p> 
最近我做了一个任务，要把后台生成的HTML模板文件改造成JSONP的形式输出，供前端异步调用。
模板文件大致这样的格式：
<code>&#60;div class="xxx"&#62;
   &#60;h3&#62;something&#60;/h3&#62;
   &#60;div class="xxx"&#62;
      she's
      beautiful
   &#60;/div&#62;
&#60;/div&#62;
</code>
<strong>制约条件：模板页面我不能动，因为它还需要被其他模板页面引用</strong>
&#160;
<h3>分析</h3>
由于受到制约不能更改模板页面的内容，将其改造成JSONP形式很有难度，新建一个页面进行组织必不可少，我起初把步骤分为：
<ol>
<li>新建页面(php)</li>
<li>引入模板页面 @include</li>
<li>用单引号包含之</li>
<li>在其头部加上handleName = ，在其后加上分号结束</li>
<li>输出</li>
</ol>

php代码:
<code>handleName = '&#60;?php @include_once("filePath") ?&#62;';
</code>
实际操作中遇到了麻烦，原因是模板内容都是换行的，最后组织好的内容成了这样：
<code>handleName = '&#60;div class="xxx"&#62;
   &#60;h3&#62;something&#60;/h3&#62;
   &#60;div class="xxx"&#62;
      she's
      beautiful
   &#60;/div&#62;
&#60;/div&#62;';
</code>
<ul>
<li>赋值表达式换行在JS里是不合语法的！</li>
<li>she's的单引号更是扰乱了这个赋值表达式...</li>
</ul>
<strong>格式化来源文件势在必行！</strong>
&#160;
...
]]></description>
			<content:encoded><![CDATA[<h3>背景</h3>
<p>异步跨域请求时JSONP方式是最靠谱的选择，常规的，被请求页面应该返回诸如此类的数据格式：</p>
<pre class="chili"><code class="js">handleName=&quot;xxx&quot;;doSomething();...;
</code></pre>
<p>需要时，我们还可以返回其他的JS语句，只要符合语法即可。</p>
<p style="text-align:center;color:#e1e1e1;font-family:arial">- &#8211; - &#8211; - &#8211; -分割线- &#8211; - &#8211; - &#8211; - </p>
<p>最近我接手一个任务，要把后台生成的HTML模板文件改造成JSONP的形式输出，供前端异步调用。<br />
模板文件大致这样的格式：</p>
<pre class="chili"><code class="html">&lt;div class=&quot;xxx&quot;&gt;
   &lt;h3&gt;something&lt;/h3&gt;
   &lt;div class=&quot;xxx&quot;&gt;
      she&#039;s
      beautiful
   &lt;/div&gt;
&lt;/div&gt;
</code></pre>
<p><strong>制约条件：模板页面我不能动，因为它还需要被其他模板页面引用</strong><br />
&nbsp;</p>
<h3>分析</h3>
<p>由于受到制约不能更改模板页面的内容，将其改造成JSONP形式很有难度，新建一个页面进行组织必不可少，我起初把步骤分为：</p>
<ol>
<li>新建页面(php)</li>
<li>引入模板页面 @include</li>
<li>用单引号包含之</li>
<li>在其头部加上handleName = ，在其后加上分号结束</li>
<li>输出</li>
</ol>
<p>php代码:</p>
<pre class="chili"><code class="php">handleName = &#039;&lt;?php @include_once(&quot;filePath&quot;) ?&gt;&#039;;
</code></pre>
<p>实际操作中遇到了麻烦，原因是模板内容都是换行的，最后组织好的内容成了这样：</p>
<pre class="chili"><code class="js">handleName = &#039;&lt;div class=&quot;xxx&quot;&gt;
   &lt;h3&gt;something&lt;/h3&gt;
   &lt;div class=&quot;xxx&quot;&gt;
      she&#039;s
      beautiful
   &lt;/div&gt;
&lt;/div&gt;&#039;;
</code></pre>
<ul>
<li>赋值表达式换行在JS里是不合语法的！</li>
<li>she&#8217;s的单引号更是扰乱了这个赋值表达式&#8230;</li>
</ul>
<p><strong>格式化来源文件势在必行！</strong><br />
&nbsp;</p>
<h3>实现</h3>
<p><strong>1.编写过滤脚本：</strong></p>
<pre class="chili"><code class="php">&lt;?php
   function contFilter($str){
      //过滤换行
      $str = ereg_replace(&quot;\r|\n|\t&quot;,&quot;&quot;,$str);
      //过滤引号
      $str = ereg_replace(&#039;&quot;&#039;,&#039;\&quot;&#039;,$str);
      $str = ereg_replace(&quot;&#039;&quot;,&quot;\&#039;&quot;,$str);
      return trim($str);
   }
?&gt;
</code></pre>
<p><strong>2.用php的file_get_contents方法打开模板文件，取其内容赋值给变量</strong></p>
<pre class="chili"><code class="php">&lt;?php
   $cont = file_get_contents(&quot;filePath&quot;);
?&gt;
</code></pre>
<p>如果不放心模板文件是否存在是否可读，还可以加入判断</p>
<pre class="chili"><code class="php">&lt;?php
   if (file_exists($filename) &amp;&amp; is_readable ($filename)) {
      ...
   }
?&gt;
</code></pre>
<p><strong>3.输出内容</strong></p>
<pre class="chili"><code class="php">handleName = &#039;&lt;?php echo(contFilter($cont));?&gt;&#039;;
</code></pre>
<p>&nbsp;</p>
<h3>成果</h3>
<pre class="chili"><code class="js">handleName = &#039;&lt;div class=\&quot;xxx\&quot;&gt;&lt;h3&gt;something&lt;/h3&gt;&lt;div class=\&quot;xxx\&quot;&gt;
 she\&#039;s beautiful&lt;/div&gt;&lt;/div&gt;&#039;;
</code></pre>
<p>所有内容合并为一行，引号也做好转义，不必再担心不可控的问题引起脚本错误。</p>
<h3>结言</h3>
<p>此举关键是要获取外部文件内容，并能对之进行控制，<strong>file_get_contents</strong>很好用!</p>
<p>参考文献：<a href="http://www.ibm.com/developerworks/cn/opensource/os-php-readfiles/index.html">http://www.ibm.com/developerworks/cn/opensource/os-php-readfiles/index.html</a></p>
<hr /><h2>Comments</h2><ul><li><a href="http://blog.silentash.com/2010/07/php-make-html-into-jsonp/?fuckgfw#comment-752">2010年08月24日</a>, <a href='http://ghsky.com' rel='external nofollow' class='url'>gonghao</a> writes: 哈哈，这个东西我也是刚刚做一个需求的时候用到啊，前面的步骤基本一样哈，只是在处理引号的时候，用了addslashes这个函数直接来处理哈~</li><li><a href="http://blog.silentash.com/2010/07/php-make-html-into-jsonp/?fuckgfw#comment-753">2010年08月24日</a>, <a href='http://www.kangre.com' rel='external nofollow' class='url'>狂热</a> writes: 来支持朋友你的好文章！</li></ul><hr /><small>Copyright &copy; 2008-2010<br /> This feed is for personal, non-commercial use only. <br /> </small>]]></content:encoded>
			<wfw:commentRss>http://blog.silentash.com/2010/07/php-make-html-into-jsonp/?fuckgfw/feed</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Embed标签src重载</title>
		<link>http://blog.silentash.com/2010/05/embed-tag-src-reload/?fuckgfw</link>
		<comments>http://blog.silentash.com/2010/05/embed-tag-src-reload/?fuckgfw#comments</comments>
		<pubDate>Tue, 25 May 2010 07:20:37 +0000</pubDate>
		<dc:creator>nunumick</dc:creator>
				<category><![CDATA[XHTML/CSS]]></category>
		<category><![CDATA[embed]]></category>
		<category><![CDATA[flash]]></category>
		<category><![CDATA[reflow]]></category>
		<category><![CDATA[reload]]></category>
		<category><![CDATA[兼容性]]></category>
		<category><![CDATA[标签重载]]></category>
		<category><![CDATA[测试]]></category>
		<category><![CDATA[浏览器]]></category>

		<guid isPermaLink="false">http://blog.silentash.com/?p=650</guid>
		<description><![CDATA[&#60;embed&#62;标签可用于在页面内嵌入 flash 文件，比较常见的就是在博客内嵌入视频，如嵌入<a href="http://blog.silentash.com/2010/03/the-2010-world-cup-anthem-waving-flag/">世界杯主题曲</a>：
<code>&#60;embed src="http://player.youku.com/player.php/sid/XMTU3NzUyMDUy/v.swf"
 quality="high" width="480" height="400" allowscriptaccess="sameDomain"
 type="application/x-shockwave-flash"&#62;&#60;/embed&#62;
</code>

接到一个小需求：需要动态更新 embed 标签的 src 属性，拿上面的代码为例，很容易找到思路：
<code>1.获取embed标签
2.setAttribute('src')
</code>
类似于对待 img 标签。

遗憾的是，此法对于 ie 浏览器并不奏效，给 src 加上时间戳也无济于事。
最后无奈用更新dom节点的方式才得以实现。
各浏览器在处理 embed 重载时并不尽相同，在此简单做了测试：<a href="http://lab.silentash.com/201005/embed.html" target="_blank">Demo</a>

<strong>测试结果：</strong>
Y：响应重载
N：不响应重载
<style>.embed-table td{border:1px solid #ccc;padding:3px;}.embed-table td.yes{color:green;font-weight:700;}.embed-table td.no{color:#999}</style>
<table class="embed-table" width="100%" border="1" cellspacing="0" cellpadding="0">
  <tr>
    <td width="40%">&#160;</td>
    <td align="center">IE(6/7/8)</td>
    <td align="center">Firefox</td>
    <td align="center">Chrome</td>
    <td align="center">Safari</td>
    <td align="center">Opera</td>
  </tr>
  <tr>
    <td>重载(refresh movie)</td>
    <td align="center">N</td>
    <td align="center" class="yes">Y</td>
    <td align="center">N</td>
    <td align="center">N</td>
    <td align="center" class="yes">Y</td>
  </tr>
  <tr>
    <td>更换(change movie)</td>
    <td align="center">N</td>
    <td align="center" class="yes">Y</td>
    <td align="center">N</td>
    <td align="center">N</td>
    <td align="center" class="yes">Y</td>
  </tr>
  <tr>
    <td>Display显示/隐藏</td>
    <td align="center">N</td>
    <td align="center" class="yes">Y</td>
    <td align="center" class="yes">Y</td>
    <td align="center" class="yes">Y</td>
    <td align="center" class="yes">Y</td>
  </tr>
  <tr>
    <td>Visibility显示/隐藏</td>
    <td align="center">N</td>
    <td align="center">N</td>
    <td align="center">N</td>
    <td align="center">N</td>
    <td align="center">N</td>
  </tr>
  <tr>
    <td>设置innerHTML</td>
    <td align="center" class="yes">Y</td>
    <td align="center" class="yes">Y</td>
    <td align="center" class="yes">Y</td>
    <td align="center" class="yes">Y</td>
    <td align="center" class="yes">Y</td>
  </tr>
  <tr>
    <td>Display hide &#62; Change movie &#62; Display show</td>
    <td align="center">N</td>
    <td align="center" class="yes">Y</td>
    <td align="center" class="yes">Y</td>
    <td align="center" class="yes">Y</td>
    <td align="center" class="yes">Y</td>
  </tr>
</table>
]]></description>
			<content:encoded><![CDATA[<p>&lt;embed&gt;标签可用于在页面内嵌入 flash 文件，比较常见的就是在博客内嵌入视频，如嵌入<a href="http://blog.silentash.com/2010/03/the-2010-world-cup-anthem-waving-flag/">世界杯主题曲</a>：</p>
<pre class="chili"><code class="html">&lt;embed src=&quot;http://player.youku.com/player.php/sid/XMTU3NzUyMDUy/v.swf&quot;
 quality=&quot;high&quot; width=&quot;480&quot; height=&quot;400&quot; allowscriptaccess=&quot;sameDomain&quot;
 type=&quot;application/x-shockwave-flash&quot;&gt;&lt;/embed&gt;
</code></pre>
<p>接到一个小需求：需要动态更新 embed 标签的 src 属性，拿上面的代码为例，很容易找到思路：</p>
<pre class="chili"><code>1.获取embed标签
2.setAttribute(&#039;src&#039;)
</code></pre>
<p>类似于对待 img 标签。</p>
<p>遗憾的是，此法对于 ie 浏览器并不奏效，给 src 加上时间戳也无济于事。<br />
最后无奈用更新dom节点的方式才得以实现。<br />
各浏览器在处理 embed 重载时并不尽相同，在此简单做了测试：<a href="http://lab.silentash.com/201005/embed.html" target="_blank">Demo</a></p>
<p><strong>测试结果：</strong><br />
Y：响应重载<br />
N：不响应重载</p>
<style>.embed-table td{border:1px solid #ccc;padding:3px;}.embed-table td.yes{color:green;font-weight:700;}.embed-table td.no{color:#999}</style>
<table class="embed-table" width="100%" border="1" cellspacing="0" cellpadding="0">
<tr>
<td width="40%">&nbsp;</td>
<td align="center">IE(6/7/8)</td>
<td align="center">Firefox</td>
<td align="center">Chrome</td>
<td align="center">Safari</td>
<td align="center">Opera</td>
</tr>
<tr>
<td>重载(refresh movie)</td>
<td align="center">N</td>
<td align="center" class="yes">Y</td>
<td align="center">N</td>
<td align="center">N</td>
<td align="center" class="yes">Y</td>
</tr>
<tr>
<td>更换(change movie)</td>
<td align="center">N</td>
<td align="center" class="yes">Y</td>
<td align="center">N</td>
<td align="center">N</td>
<td align="center" class="yes">Y</td>
</tr>
<tr>
<td>Display显示/隐藏</td>
<td align="center">N</td>
<td align="center" class="yes">Y</td>
<td align="center" class="yes">Y</td>
<td align="center" class="yes">Y</td>
<td align="center" class="yes">Y</td>
</tr>
<tr>
<td>Visibility显示/隐藏</td>
<td align="center">N</td>
<td align="center">N</td>
<td align="center">N</td>
<td align="center">N</td>
<td align="center">N</td>
</tr>
<tr>
<td>设置innerHTML</td>
<td align="center" class="yes">Y</td>
<td align="center" class="yes">Y</td>
<td align="center" class="yes">Y</td>
<td align="center" class="yes">Y</td>
<td align="center" class="yes">Y</td>
</tr>
<tr>
<td>Display hide &gt; Change movie &gt; Display show</td>
<td align="center">N</td>
<td align="center" class="yes">Y</td>
<td align="center" class="yes">Y</td>
<td align="center" class="yes">Y</td>
<td align="center" class="yes">Y</td>
</tr>
</table>
<hr /><h2>Comments</h2><ul><li><a href="http://blog.silentash.com/2010/05/embed-tag-src-reload/?fuckgfw#comment-520">2010年05月25日</a>, <a href='http://www.xintend.com/' rel='external nofollow' class='url'>龙藏</a> writes: 很好~~~  转至本人blog</li><li><a href="http://blog.silentash.com/2010/05/embed-tag-src-reload/?fuckgfw#comment-528">2010年05月26日</a>, <a href='http://www.waihuiblog.com' rel='external nofollow' class='url'>博客外汇</a> writes: 这。。。到底那里是原来的呢？</li><li><a href="http://blog.silentash.com/2010/05/embed-tag-src-reload/?fuckgfw#comment-531">2010年05月26日</a>, <a href='http://www.silentash.com' rel='external nofollow' class='url'>nunumick</a> writes: @博客外汇，什么情况？</li><li><a href="http://blog.silentash.com/2010/05/embed-tag-src-reload/?fuckgfw#comment-545">2010年05月27日</a>, <a href='http://www.kangre.com/' rel='external nofollow' class='url'>狂热</a> writes: 嗯，学习了，以后收藏来用！</li></ul><hr /><small>Copyright &copy; 2008-2010<br /> This feed is for personal, non-commercial use only. <br /> </small>]]></content:encoded>
			<wfw:commentRss>http://blog.silentash.com/2010/05/embed-tag-src-reload/?fuckgfw/feed</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>容易被忽略的JS脚本特性</title>
		<link>http://blog.silentash.com/2010/05/little-js-properties-that-you-normally-would-not-notice/?fuckgfw</link>
		<comments>http://blog.silentash.com/2010/05/little-js-properties-that-you-normally-would-not-notice/?fuckgfw#comments</comments>
		<pubDate>Tue, 18 May 2010 18:52:17 +0000</pubDate>
		<dc:creator>nunumick</dc:creator>
				<category><![CDATA[JS/Ajax/AS/Flex]]></category>
		<category><![CDATA[ECMA]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[全局]]></category>
		<category><![CDATA[变量]]></category>
		<category><![CDATA[局部]]></category>
		<category><![CDATA[特性]]></category>

		<guid isPermaLink="false">http://blog.silentash.com/?p=633</guid>
		<description><![CDATA[<strong>一、容易被忽略的局部变量</strong>
<code>var a = 5;
(function(){
   alert(a);
   var a = a ++;
   alert(a);
})()
alert(a);
</code>
思考这段代码的执行结果。

执行后，看看是否和你想象的一致？

ok，这段代码里核心的知识点是 var a = a++，其中两个变量 a 都是匿名函数内部的局部变量，是同一个，和全局变量 a 是不一样的。

为什么？我们来看看ECMA规范对变量声明语句的定义：
<code>Description
If the variable statement occurs inside a FunctionDeclaration, the 
variables are defined with function-local scope in that function, as 
described in s10.1.3. Otherwise, they are defined with global scope 
(that is, they are created as members of the global object, as described 
in 10.1.3) using property attributes { DontDelete }. Variables are 
created when the execution scope is entered. A Block does not define a new 
execution scope. Only Program and FunctionDeclaration produce a new 
scope. Variables are initialised to undefined when created. A variable with 
an Initialiser is assigned the value of its AssignmentExpression when the 
VariableStatement is executed, not when the variable is created.
</code>

声明中提到：进入作用域环境后，变量就会被创建，并赋予初始值undefined。在变量声明语句执行时才会把赋值表达式的值指派给该变量，而并不是在该变量被创建时。

因此上面的代码可以等价于...

]]></description>
			<content:encoded><![CDATA[<p><strong>一、容易被忽略的局部变量</strong></p>
<pre class="chili"><code class="js">var a = 5;
(function(){
   alert(a);
   var a = a ++;
   alert(a);
})()
alert(a);
</code></pre>
<p>思考这段代码的执行结果。</p>
<p>执行后，看看是否和你想象的一致？</p>
<p>ok，这段代码里核心的知识点是 var a = a++，其中两个变量 a 都是匿名函数内部的局部变量，是同一个，和全局变量 a 是不一样的。</p>
<p>为什么？我们来看看ECMA规范对变量声明语句的定义：</p>
<pre class="chili"><code>Description
If the variable statement occurs inside a FunctionDeclaration, the
variables are defined with function-local scope in that function, as
described in s10.1.3. Otherwise, they are defined with global scope
(that is, they are created as members of the global object, as described
in 10.1.3) using property attributes { DontDelete }. Variables are
created when the execution scope is entered. A Block does not define a new
execution scope. Only Program and FunctionDeclaration produce a new
scope. Variables are initialised to undefined when created. A variable with
an Initialiser is assigned the value of its AssignmentExpression when the
VariableStatement is executed, not when the variable is created.
</code></pre>
<p>声明中提到：进入作用域环境后，变量就会被创建，并赋予初始值undefined。在变量声明语句执行时才会把赋值表达式的值指派给该变量，而并不是在该变量被创建时。</p>
<p>因此上面的代码可以等价于:</p>
<pre class="chili"><code class="js">var a;
a = 5;
(function(){
   var a;
   alert(a);
   a = a ++;
   alert(a);
})()
alert(a);
</code></pre>
<p>这样应该会更容易理解了吧。</p>
<p><strong>二、容易被忽略的全局变量</strong></p>
<pre class="chili"><code class="js">(function(){
   var a = b = 5;
})()
alert(b);
</code></pre>
<p>这是<a href="http://lifesinger.org/blog/">玉伯</a>几天前分享到的知识点，蛮有意义的，在此也做个分析。</p>
<p>首先，考虑执行结果为什么是：5。</p>
<p>ok,原因出在 var a = b = 5 这句。</p>
<p>为深入分析这个语句，我们继续要参照ECMA规范对声明语句的定义：</p>
<p>var a = b = 5;等同为 var a; a = b = 5;两条语句，后者是赋值表达式，其在ECMA中的定义是这样的：</p>
<pre class="chili"><code>Simple Assignment ( = )
The production AssignmentExpression : LeftHandSideExpression =
AssignmentExpression is evaluated as follows:
1. Evaluate LeftHandSideExpression.
2. Evaluate AssignmentExpression.
3. Call GetValue(Result(2)).
4. Call PutValue(Result(1), Result(3)).
5. Return Result(3).
</code></pre>
<p>对于a = b = 5;先执行左边表达式 a，这是一个标识符表达式，根据规范第 10.1.4，其执行方式如下：</p>
<pre class="chili"><code>
During execution, the syntactic production PrimaryExpression : Identifier
is evaluated using the following algorithm:
1. Get the next object in the scope chain. If there isn&#039;t one, go to step 5.
2. Call the [[HasProperty]] method of Result(1), passing the Identifier as
the property.
3. If Result(2) is true, return a value of type Reference whose base
object is Result(1) and whose property name is the Identifier.
4. Go to step 1.
5. Return a value of type Reference whose base object is null and whose
property name is the Identifier.
</code></pre>
<p>搜寻作用域链，找到最近的一个 a 的引用，很明显，在匿名函数内部作用域就可以找到，于是变量 a 确定下来。</p>
<p>接着再执行右边的表达式 b = 5 ，还是一个赋值表达式，重复赋值规则第一步，因为变量 b 在匿名函数环境内未声明过，所以接着去 window 全局环境下去找 window.b ，被隐式声明为全局变量，最后赋值为 5，根据规则第五步，表达式的结果也会再赋值给 a。最终达到 a 和 b 都为 5 ，区别是 a 是局部变量，而 b 是全局变量。</p>
<p>我们再来理一下 (function(){var a = b = 5})() 表达式内部整体的执行顺序：</p>
<pre class="chili"><code>1.匿名函数内创建变量a;
2.赋予初始值undefined;
3.取得变量a的引用;   //a
4.取得变量b的引用;   //window.b
5.对数字5求值;
6.赋值5给b的引用：window.b;
7.返回b = 5的结果5给a的引用：a;
8.返回a = 5的结果5；
</code></pre>
<p>很明显，中间的一个步骤使得变量 b 被声明为全局变量，明白之后，我们不难找到代码的优化点：只需将变量 b 显式声明为局部变量：</p>
<pre class="chili"><code class="js">(function(){
   var a,b;
   a = b = 5;
})()
</code></pre>
<hr /><h2>Comments</h2><ul><li><a href="http://blog.silentash.com/2010/05/little-js-properties-that-you-normally-would-not-notice/?fuckgfw#comment-495">2010年05月19日</a>, <a href='http://www.xiaoxiaozi.com' rel='external nofollow' class='url'>simaopig</a> writes: 呵呵，拿来当面试题不错。

喜欢你们这种去查ECMA手册的方法，我就比较懒。

知道结果，解释起来却费劲的很。</li><li><a href="http://blog.silentash.com/2010/05/little-js-properties-that-you-normally-would-not-notice/?fuckgfw#comment-498">2010年05月19日</a>, <a href='http://www.f2e-arsenal.com' rel='external nofollow' class='url'>涵宇</a> writes: 好文！
包含了很多知识点，解释的简明易懂，佩服！
究其所以然的方式方法值得学习</li></ul><hr /><small>Copyright &copy; 2008-2010<br /> This feed is for personal, non-commercial use only. <br /> </small>]]></content:encoded>
			<wfw:commentRss>http://blog.silentash.com/2010/05/little-js-properties-that-you-normally-would-not-notice/?fuckgfw/feed</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>慎用通配符选择器</title>
		<link>http://blog.silentash.com/2010/04/caution-in-using-css-universal-selector/?fuckgfw</link>
		<comments>http://blog.silentash.com/2010/04/caution-in-using-css-universal-selector/?fuckgfw#comments</comments>
		<pubDate>Tue, 06 Apr 2010 13:53:38 +0000</pubDate>
		<dc:creator>nunumick</dc:creator>
				<category><![CDATA[XHTML/CSS]]></category>
		<category><![CDATA[block]]></category>
		<category><![CDATA[script]]></category>
		<category><![CDATA[selector]]></category>
		<category><![CDATA[style]]></category>
		<category><![CDATA[universal]]></category>
		<category><![CDATA[优先级]]></category>
		<category><![CDATA[选择器]]></category>
		<category><![CDATA[通配符]]></category>

		<guid isPermaLink="false">http://blog.silentash.com/?p=625</guid>
		<description><![CDATA[<h3>一、通配符选择器没有优先级</h3>
<code>   div{background:#f00}
   *{background:#000}
</code>
前者优先级更高。
<code>   *.hello{color:#f00}
   .hello{color:#000}
</code>
两者优先级一样，后来至上。

<h3>二、通配符选择器样式污染</h3>
<code>   #showEveryThing * {display:block}
</code>
将使 showEveryThing 内部所有元素显示为块元素，包括 &#60;style&#62; &#60;script&#62; &#60;noscript&#62;标签。这会破坏这些标签的本来面目，造成不必要的麻烦。

&#60;style&#62; &#60;script&#62; &#60;head&#62; 等元素本不可见，如果被强制加上样式，多多少少都会有问题，区别：
<ol>
<li>
<strong>IE</strong>
 不会输出内容，但可以控制边框。
</li>
<li>
<strong>非IE</strong>
 基本可以当作普通元素对待，但不影响原有标签功能。如出现样式被修改情况，可以反方向重置。
</li>
</ol>

因此，建议大家在使用通配符选择器时特别需要注意上下文环境，<strong>确认不会造成标签样式污染之后再使用</strong>
]]></description>
			<content:encoded><![CDATA[<h3>一、通配符选择器没有优先级</h3>
<pre class="chili"><code>   div{background:#f00}
   *{background:#000}
</code></pre>
<p>前者优先级更高。</p>
<pre class="chili"><code>   *.hello{color:#f00}
   .hello{color:#000}
</code></pre>
<p>两者优先级一样，后来至上。</p>
<h3>二、通配符选择器样式污染</h3>
<pre class="chili"><code>   #showEveryThing * {display:block}
</code></pre>
<p>将使 showEveryThing 内部所有元素显示为块元素，包括 &lt;style&gt; &lt;script&gt; &lt;noscript&gt;标签。这会破坏这些标签的本来面目，造成不必要的麻烦。</p>
<p>&lt;style&gt; &lt;script&gt; &lt;head&gt; 等元素本不可见，如果被强制加上样式，多多少少都会有问题，区别：</p>
<ol>
<li>
<strong>IE</strong><br />
 不会输出内容，但可以控制边框。
</li>
<li>
<strong>非IE</strong><br />
 基本可以当作普通元素对待，但不影响原有标签功能。如出现样式被修改情况，可以反方向重置。
</li>
</ol>
<p>因此，建议大家在使用通配符选择器时特别需要注意上下文环境，<strong>确认不会造成标签样式污染之后再使用</strong></p>
<hr /><small>Copyright &copy; 2008-2010<br /> This feed is for personal, non-commercial use only. <br /> </small>]]></content:encoded>
			<wfw:commentRss>http://blog.silentash.com/2010/04/caution-in-using-css-universal-selector/?fuckgfw/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>如何以get方式传递表单action中的额外参数</title>
		<link>http://blog.silentash.com/2010/03/form-get-method-and-uri-transmission/?fuckgfw</link>
		<comments>http://blog.silentash.com/2010/03/form-get-method-and-uri-transmission/?fuckgfw#comments</comments>
		<pubDate>Fri, 19 Mar 2010 15:35:43 +0000</pubDate>
		<dc:creator>nunumick</dc:creator>
				<category><![CDATA[JS/Ajax/AS/Flex]]></category>
		<category><![CDATA[XHTML/CSS]]></category>
		<category><![CDATA[form]]></category>
		<category><![CDATA[get]]></category>
		<category><![CDATA[post]]></category>
		<category><![CDATA[uri]]></category>

		<guid isPermaLink="false">http://blog.silentash.com/?p=602</guid>
		<description><![CDATA[<h3>问题及背景</h3>
今天项目组的开发同学急冲冲地叫上我看一个他写的JS脚本，好端端的一个form提交时参数无法正常传递。代码是这样的
<code>&#60;form method="get" name="xxx" id="xxx" action="uri?xxx=xxx&#038;yyy=yyy" &#62;
   &#60;input name="zzz"  type="text" value="zzz" /&#62;
   &#60;input id="submit" type="button" value="提交" /&#62;
&#60;/form>
&#60;script>
   document.getElementById('submit').onclick = function(){
       var form = document.xxx;
       form.action = form.action + 
           (form.action.indexOf('?') &#62; -1 ? '&#038;' : '?') + form.zzz.value;
       form.submit();
   }
&#60;/script&#62;
</code>

其本意是在提交是要同时提交xxx、yyy、zzz三个参数，但最终提交的参数只有zzz，即uri只是 uri?zzz=zzz。

<h3>分析</h3>
这是为什么呢？脚本没有问题呀，感觉方法也没什么问题，在调试了多次无果之后，我把注意点移到了form本身：在禁用了脚本之后，form同样只提交了zzz参数。

<strong>最后，终于知道原因是form使用了get方法。</strong>

<a href="http://www.w3.org/TR/REC-html40/">HTML 4.01 specification</a> 的解释
<code>If the method is "get" - -, the user agent takes the value of action, 
appends a ? to it, then appends the form data set, 
encoded using the application/x-www-form-urlencoded content type. 
The user agent then traverses the link to this URI. In this scenario, 
form data are restricted to ASCII codes.
</code>

get方式是method的默认值，其方式是将form表单中的数据集值对组织到action中的uri之后，不过其组织方式是有讲究的：
<ol>
   <li>uri在submit最后才进行组织</li>
   <li>在添加'?'时，uri中额外参数会被舍弃，接着只拼接表单内的域值</li>
   <li>uri hash值会被保留:uri?xxx=xxx#here，#here会被保留</li>
</ol>
]]></description>
			<content:encoded><![CDATA[<h3>问题及背景</h3>
<p>今天项目组的开发同学急冲冲地叫上我看一个他写的JS脚本，好端端的一个form提交时参数无法正常传递。代码是这样的</p>
<pre class="chili"><code class="html">&lt;form method=&quot;get&quot; name=&quot;xxx&quot; id=&quot;xxx&quot; action=&quot;uri?xxx=xxx&amp;yyy=yyy&quot; &gt;
   &lt;input name=&quot;zzz&quot;  type=&quot;text&quot; value=&quot;zzz&quot; /&gt;
   &lt;input id=&quot;submit&quot; type=&quot;button&quot; value=&quot;提交&quot; /&gt;
&lt;/form&gt;
&lt;script&gt;
   document.getElementById(&#039;submit&#039;).onclick = function(){
       var form = document.xxx;
       form.action = form.action +
           (form.action.indexOf(&#039;?&#039;) &gt; -1 ? &#039;&amp;&#039; : &#039;?&#039;) + form.zzz.value;
       form.submit();
   }
&lt;/script&gt;
</code></pre>
<p>其本意是在提交是要同时提交xxx、yyy、zzz三个参数，但最终提交的参数只有zzz，即uri只是 uri?zzz=zzz。</p>
<h3>分析</h3>
<p>这是为什么呢？脚本没有问题呀，感觉方法也没什么问题，在调试了多次无果之后，我把注意点移到了form本身：在禁用了脚本之后，form同样只提交了zzz参数。</p>
<p><strong>最后，终于知道原因是form使用了get方法。</strong></p>
<p><a href="http://www.w3.org/TR/REC-html40/">HTML 4.01 specification</a> 的解释</p>
<pre class="chili"><code>If the method is &quot;get&quot; - -, the user agent takes the value of action,
appends a ? to it, then appends the form data set,
encoded using the application/x-www-form-urlencoded content type.
The user agent then traverses the link to this URI. In this scenario,
form data are restricted to ASCII codes.
</code></pre>
<p>get方式是method的默认值，其方式是将form表单中的数据集值对组织到action中的uri之后，不过其组织方式是有讲究的：</p>
<ol>
<li>uri在submit最后才进行组织</li>
<li>在添加&#8217;?'时，uri中额外参数会被舍弃，接着只拼接表单内的域值</li>
<li>uri hash值会被保留:uri?xxx=xxx#here，#here会被保留</li>
</ol>
<h3>改进</h3>
<p>因此，get方法需要传递额外参数时，可以选择在form表单内动态创建额外参数域，再提交</p>
<pre class="chili"><code class="js">&lt;script&gt;
   var oInput = document.createElement(&#039;input&#039;);
   var oForm = document.xxx;
   oInput.name = &#039;yyy&#039;;
   oInput.value = &#039;yyy&#039;;
   oForm.appendChild(oInput);
   oForm.submit();
&lt;/script&gt;
</code></pre>
<p>当然，用post方式会更方便，看你如何选择</p>
<pre class="chili"><code class="html">&lt;form method=&quot;post&quot; name=&quot;xxx&quot; id=&quot;xxx&quot; action=&quot;uri?xxx=xxx&amp;yyy=yyy&quot; &gt;
   &lt;input name=&quot;zzz&quot;  type=&quot;text&quot; value=&quot;zzz&quot; /&gt;
   &lt;input id=&quot;submit&quot; type=&quot;button&quot; value=&quot;提交&quot; /&gt;
&lt;/form&gt;
</code></pre>
<h3>更多关于post和get的区别</h3>
<p><strong>编码</strong><br />
HTML 4.01 specification指出，get只能向服务器发送ASCII字符，而post则可以发送整个<a href="http://www.w3.org/TR/REC-html40/references.html#ref-ISO10646">ISO10646</a>中的字符（如果同时指定<a href="http://www.w3.org/TR/REC-html40/interact/forms.html#adef-enctype">enctype</a>=&#8221;multipart/form-data&#8221;的话）。</p>
<p>注意get和post对应的enctype属性有区别。enctype有两个值，默认值为application/x-www-form-urlencoded，而另一个值multipart/form-data只能用于post。</p>
<p><strong>提交的数据的长度</strong><br />
HTTP specification并没有对URL长度进行限制，但是IE将请求的<a href="http://support.microsoft.com/kb/208427/en-us">URL长度限制为2083</a>个字符，从而限制了get提交的数据长度。测试表明如果URL超出这个限制，提交form时IE不会有任何响应。其它浏览器则没有URL的长度限制，因此其它浏览器能通过get提交的数据长度仅受限于服务器的设置。</p>
<p>而对于post，因为提交的数据不在url中，所以通常可以简单地认为数据长度限制仅受限于服务器的设置。</p>
<p><strong>缓存</strong><br />
由于一个get得到的结果直接对应到一个URI，所以get的结果页面有可能被浏览器缓存。而post一般则不能。</p>
<p><strong>引用和SEO</strong><br />
出于和上面相同的原因，我们可以用一个URI引用一个get的结果页面，而post的结果则不能，所以必然不能被搜索引擎搜到。</p>
<p><strong>使用场景</strong><br />
<a href="http://www.w3.org/">W3C</a>的官方建议是：当且仅当form是幂等（idempotent）的时候，才使用get，比如搜索结果。其他情况则使用post方式。</p>
<h3>参考文献</h3>
<p><a href="http://www.cs.tut.fi/~jkorpela/forms/methods.html">Methods GET and POST in HTML forms &#8211; what&#8217;s the difference?</a></p>
<p><a href="http://www.htmlhelp.com/faq/cgifaq.2.html#8">What is the difference between GET and POST?</a></p>
<hr /><h2>Comments</h2><ul><li><a href="http://blog.silentash.com/2010/03/form-get-method-and-uri-transmission/?fuckgfw#comment-332">2010年03月21日</a>, <a href='http://www.12sui.cn' rel='external nofollow' class='url'>我才12岁</a> writes: 我顶~</li></ul><hr /><small>Copyright &copy; 2008-2010<br /> This feed is for personal, non-commercial use only. <br /> </small>]]></content:encoded>
			<wfw:commentRss>http://blog.silentash.com/2010/03/form-get-method-and-uri-transmission/?fuckgfw/feed</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>南非世界杯主题曲《旗帜飘扬》MV</title>
		<link>http://blog.silentash.com/2010/03/the-2010-world-cup-anthem-waving-flag/?fuckgfw</link>
		<comments>http://blog.silentash.com/2010/03/the-2010-world-cup-anthem-waving-flag/?fuckgfw#comments</comments>
		<pubDate>Thu, 18 Mar 2010 14:20:38 +0000</pubDate>
		<dc:creator>nunumick</dc:creator>
				<category><![CDATA[杂七杂八]]></category>
		<category><![CDATA[世界杯]]></category>
		<category><![CDATA[主题曲]]></category>
		<category><![CDATA[南非]]></category>
		<category><![CDATA[旗帜飘扬]]></category>

		<guid isPermaLink="false">http://blog.silentash.com/?p=591</guid>
		<description><![CDATA[这么具有非洲特色的MV能否让你紧张了一天的心情放松下来呢? 朋友，来杯啤酒，一起欢畅！

<embed src="http://player.youku.com/player.php/sid/XMTU3NzUyMDUy/v.swf" quality="high" width="480" height="400" align="middle" allowScriptAccess="sameDomain" type="application/x-shockwave-flash"></embed>

<strong>歌词大意：</strong>
  给我自由，给我激情，给我个理由，让我飞得更高
  向着冠军，现在就上场吧，你让我明确，让我们自豪
  在街道上，当我们失去了束缚
  在我们身边庆祝吧，每个国家，在我们身边
  歌唱永远的年轻，在太阳下歌唱
  让我们在这美丽的运动中欢庆吧
  相聚在这天的到结束
  我们一起说
  当我长大，我会变得更强
  他们让我们自由，就像那旗帜飘扬
  一切都回归
  ...

附：<a href="http://v.youku.com/v_show/id_XMTM2MjMzMzI0.html" target="_blank">旗帜飘扬完整版</a>]]></description>
			<content:encoded><![CDATA[<p>这么具有非洲特色的MV能否让你紧张了一天的心情放松下来呢? 朋友，来杯啤酒，一起欢畅！</p>
<p><embed src="http://player.youku.com/player.php/sid/XMTU3NzUyMDUy/v.swf" quality="high" width="480" height="400" align="middle" allowScriptAccess="sameDomain" type="application/x-shockwave-flash"></embed></p>
<p><strong>歌词大意：</strong><br />
  给我自由，给我激情，给我个理由，让我飞得更高<br />
  向着冠军，现在就上场吧，你让我明确，让我们自豪<br />
  在街道上，当我们失去了束缚<br />
  在我们身边庆祝吧，每个国家，在我们身边<br />
  歌唱永远的年轻，在太阳下歌唱<br />
  让我们在这美丽的运动中欢庆吧<br />
  相聚在这天的到结束<br />
  我们一起说<br />
  当我长大，我会变得更强<br />
  他们让我们自由，就像那旗帜飘扬<br />
  一切都回归<br />
  &#8230;</p>
<p>附：<a href="http://v.youku.com/v_show/id_XMTM2MjMzMzI0.html" target="_blank">旗帜飘扬完整版</a></p>
<hr /><h2>Comments</h2><ul><li><a href="http://blog.silentash.com/2010/03/the-2010-world-cup-anthem-waving-flag/?fuckgfw#comment-517">2010年05月25日</a>, <a href='http://blog.silentash.com/2010/05/embed-tag-src-reload/' rel='external nofollow' class='url'>Silentash-默尘 &raquo; Embed标签src重载</a> writes: [...] &lt;embed&gt;标签可用于在页面内嵌入 flash 文件，比较常见的就是在博客内嵌入视频，如嵌入世界杯主题曲： [...]</li></ul><hr /><small>Copyright &copy; 2008-2010<br /> This feed is for personal, non-commercial use only. <br /> </small>]]></content:encoded>
			<wfw:commentRss>http://blog.silentash.com/2010/03/the-2010-world-cup-anthem-waving-flag/?fuckgfw/feed</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>纯炫耀贴-我的世界杯吉祥物扎库米</title>
		<link>http://blog.silentash.com/2010/03/zakumi/?fuckgfw</link>
		<comments>http://blog.silentash.com/2010/03/zakumi/?fuckgfw#comments</comments>
		<pubDate>Sun, 14 Mar 2010 15:42:09 +0000</pubDate>
		<dc:creator>nunumick</dc:creator>
				<category><![CDATA[杂七杂八]]></category>
		<category><![CDATA[zakumi]]></category>
		<category><![CDATA[世界杯]]></category>
		<category><![CDATA[南非]]></category>
		<category><![CDATA[扎库米]]></category>
		<category><![CDATA[生日礼物]]></category>

		<guid isPermaLink="false">http://blog.silentash.com/?p=580</guid>
		<description><![CDATA[昨日收到老婆大人送的生日礼物，感动到泪牛满面！<a href="http://en.wikipedia.org/wiki/Zakumi" target="_blank">扎库米</a>是我一直想要的世界杯吉祥物，模样真太帅呆了！于是拍照炫耀！

PS：晚上光线不是很好，毕竟是纯炫耀贴，请大家无视我的拍照技巧=.=!

<img src="http://photo.silentash.com/zakumi/zakumi_22_small.png" alt="zakumi" />

<img src="http://photo.silentash.com/zakumi/zakumi_27_small.png" alt="zakumi" />

<img src="http://photo.silentash.com/zakumi/zakumi_30_small.png" alt="zakumi" />

以扎库米的名义，期待世界杯早日到来！

附：<a href="http://blog.silentash.com/2009/12/2010-south-africa-world-cup-schedule" target="_blank">南非世界杯对阵&#038;比分统计表</a>]]></description>
			<content:encoded><![CDATA[<p>昨日收到老婆大人送的生日礼物，感动到泪牛满面！<a href="http://en.wikipedia.org/wiki/Zakumi" target="_blank">扎库米</a>是我一直想要的世界杯吉祥物，模样真太帅呆了！于是拍照炫耀！</p>
<p>PS：晚上光线不是很好，毕竟是纯炫耀贴，请大家无视我的拍照技巧=.=!</p>
<p><img src="http://photo.silentash.com/zakumi/zakumi_22_small.png" alt="zakumi" /></p>
<p><img src="http://photo.silentash.com/zakumi/zakumi_27_small.png" alt="zakumi" /></p>
<p><img src="http://photo.silentash.com/zakumi/zakumi_30_small.png" alt="zakumi" /></p>
<p>以扎库米的名义，期待世界杯早日到来！</p>
<p>附：<a href="http://blog.silentash.com/2009/12/2010-south-africa-world-cup-schedule" target="_blank">南非世界杯对阵&#038;比分统计表</a></p>
<hr /><small>Copyright &copy; 2008-2010<br /> This feed is for personal, non-commercial use only. <br /> </small>]]></content:encoded>
			<wfw:commentRss>http://blog.silentash.com/2010/03/zakumi/?fuckgfw/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>有趣的兼容性测试-iframe文档对象获取</title>
		<link>http://blog.silentash.com/2010/03/iframe-content-document-compatibility/?fuckgfw</link>
		<comments>http://blog.silentash.com/2010/03/iframe-content-document-compatibility/?fuckgfw#comments</comments>
		<pubDate>Fri, 05 Mar 2010 16:59:59 +0000</pubDate>
		<dc:creator>nunumick</dc:creator>
				<category><![CDATA[JS/Ajax/AS/Flex]]></category>
		<category><![CDATA[document]]></category>
		<category><![CDATA[dom]]></category>
		<category><![CDATA[iframe]]></category>
		<category><![CDATA[window]]></category>
		<category><![CDATA[兼容]]></category>

		<guid isPermaLink="false">http://blog.silentash.com/?p=564</guid>
		<description><![CDATA[前日对iframe的几种文档对象获取方式做了测试，发现一些有趣现象，与大家分享！
假设在页面嵌入如下iframe:
<code>   &#60;iframe id="testFrame" name="testFrame" src="#" frameborder="0" border="0" scrolling="no" style="display:none"&#62;&#60;/iframe&#62; 
</code>
众所周知，iframe是内嵌窗口，我们可以通过多种方式获取iframe对象及其window\document对象（同域前提），不过哪些是哪些有时会搞不清，测试目的也是为了加深记忆。
比较常见的方法有以下几种，分别测试：
<ul>
<li>A:document.getElementById('testFrame')</li>
<li>B:window.frames['testFrame'];</li>
<li>C:document.getElementById('testFrame').contentWindow</li>
</ul>
<strong>测试结果(非IE浏览器及IE8)</strong>
<img src="http://lab.silentash.com/201003/2010-03-05_235442.png" alt="" style="max-width:613px"  />
<br />
从测试结果及其比对结果可以看出，A得到的是iframe这个html标签对象，B和C得到的是iframe浏览器对象(window)，有意思的是<strong>IE7及以下版本浏览器认为这两者是不恒等的</strong>
...]]></description>
			<content:encoded><![CDATA[<p>前日对iframe的几种文档对象获取方式做了测试，发现一些有趣现象，与大家分享！<br />
假设在页面嵌入如下iframe:<br />
<code>   &lt;iframe id="testFrame" name="testFrame" src="#" frameborder="0" border="0" scrolling="no" style="display:none"&gt;&lt;/iframe&gt;<br />
</code><br />
众所周知，iframe是内嵌窗口，我们可以通过多种方式获取iframe对象及其window\document对象（同域前提），不过哪些是哪些有时会搞不清，测试目的也是为了加深记忆。<br />
比较常见的方法有以下几种，分别测试：</p>
<ul>
<li>A:document.getElementById(&#8216;testFrame&#8217;)</li>
<li>B:window.frames['testFrame'];</li>
<li>C:document.getElementById(&#8216;testFrame&#8217;).contentWindow</li>
</ul>
<p><strong>测试结果(非IE浏览器及IE8)</strong><br />
<img src="http://lab.silentash.com/201003/2010-03-05_235442.png" alt="" style="max-width:613px"  /><br />
<br />
从测试结果及其比对结果可以看出，A得到的是iframe这个html标签对象，B和C得到的是iframe浏览器对象(window)，有意思的是<strong>IE7及以下版本浏览器认为这两者是不恒等的</strong><br />
<br />
<strong>测试结果(IE7&#038;IE6-)</strong><br />
<img src="http://lab.silentash.com/201003/2010-03-05_235720.png" alt=""  style="max-width:513px" /><br />
<br />
有趣吧，从B==C可以看出，证明两者是同一类型及同一引用，参考<a href="http://blog.silentash.com/2010/03/equals-operator-and-strict-equals-operator/" target="_blank">设计规范</a>，理应恒等（===）。只能说，M$遵循的不是规范，是寂寞！好在IE8现在已经玩不起寂寞了。<br />
<br />
接着测试浏览器对contentDocument的支持情况：</p>
<ul>
<li>D:window.frames['testFrame'].document</li>
<li>E:document.getElementById(&#8216;testFrame&#8217;).contentWindow.document</li>
<li>F:document.getElementById(&#8216;testFrame&#8217;).contentDocument</li>
</ul>
<p><strong>测试结果(非IE浏览器及IE8):</strong><br />
<img src="http://lab.silentash.com/201003/2010-03-05_235507.png" alt="" style="max-width:682px" /><br />
<br />
测试结果表明:D和E得到的是同一对象，IE7及以下版本浏览器不支持contentDocument属性</p>
<p><strong>测试结果(IE7&#038;IE6-)</strong><br />
<img src="http://lab.silentash.com/201003/2010-03-05_235805.png" alt="" style="max-width:545px" /><br />
<br />
在使用contentDocument属性时需要考虑兼容性：<br />
<code>   function getFrameDocument(frame){<br />
            return frame &#038;&#038; typeof(frame)=='object' &#038;&#038; frame.contentDocument || frame.contentWindow &#038;&#038; frame.contentWindow.document || frame.document;<br />
}<br />
</code><br />
<strong>调整后的测试结果(IE7&#038;IE6-)：</strong><br />
<img src="http://lab.silentash.com/201003/2010-03-05_235821.png" alt="" style="max-width:558px" /><br />
<br />
附：<a href="http://lab.silentash.com/201003/iframe_content.html" target="_blank">测试页面</a></p>
<hr /><h2>Comments</h2><ul><li><a href="http://blog.silentash.com/2010/03/iframe-content-document-compatibility/?fuckgfw#comment-318">2010年03月13日</a>, <a href='http://www.kangre.com/' rel='external nofollow' class='url'>kanger</a> writes: 太深奥了！慢慢看</li></ul><hr /><small>Copyright &copy; 2008-2010<br /> This feed is for personal, non-commercial use only. <br /> </small>]]></content:encoded>
			<wfw:commentRss>http://blog.silentash.com/2010/03/iframe-content-document-compatibility/?fuckgfw/feed</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Javascript 等同(==)与恒等(===)运算符</title>
		<link>http://blog.silentash.com/2010/03/equals-operator-and-strict-equals-operator/?fuckgfw</link>
		<comments>http://blog.silentash.com/2010/03/equals-operator-and-strict-equals-operator/?fuckgfw#comments</comments>
		<pubDate>Tue, 02 Mar 2010 17:38:45 +0000</pubDate>
		<dc:creator>nunumick</dc:creator>
				<category><![CDATA[JS/Ajax/AS/Flex]]></category>
		<category><![CDATA[ECMA]]></category>
		<category><![CDATA[equals]]></category>
		<category><![CDATA[identical]]></category>
		<category><![CDATA[javascirpt]]></category>
		<category><![CDATA[strict]]></category>
		<category><![CDATA[恒等]]></category>
		<category><![CDATA[操作符]]></category>
		<category><![CDATA[等同]]></category>
		<category><![CDATA[规范]]></category>

		<guid isPermaLink="false">http://blog.silentash.com/?p=544</guid>
		<description><![CDATA[Javascript开发中，需要与0,undefined,null,false进行等同比较时，我们知道，用'==='(恒等)比较靠谱，我是在第一次使用jslint时知道这点的，例如在<a href="http://www.jslint.com" target="_blank">Jslint</a>中验证
<code>   var test = '';
   alert(test==0);
</code>
会得到提示：
<code>   Use '===' to compare with '0'
</code>

看看ECMA规范中是如何对==和===操作符进行定义的，了解其深层的规则以及jslint提示的缘由

<strong>首先介绍==</strong>
11.9.1 等同运算符( == )
<blockquote>
运算符规则如下所示：
1. 计算运算符左侧表达式;
2. 对第1步的结果调用GetValue;
3. 计算运算符右侧表达式;
4. 对第1步的结果调用GetValue;
5. 对第4步的结果与第2步结果执行比对（参考 11.9.3）;
6. 返回第5步结果;
</blockquote>

<strong>再来详细了解比对过程(11.9.3)</strong>
11.9.3 抽象的等同比对算法...
]]></description>
			<content:encoded><![CDATA[<p>Javascript开发中，需要与0,undefined,null,false进行等同比较时，我们知道，用&#8217;===&#8217;(恒等)比较靠谱，我是在第一次使用jslint时知道这点的，例如在<a href="http://www.jslint.com" target="_blank">Jslint</a>中验证<br />
<code>   var test = '';<br />
   alert(test==0);<br />
</code><br />
会得到提示：<br />
<code>   Use '===' to compare with '0'<br />
</code></p>
<p>看看ECMA规范中是如何对==和===操作符进行定义的，了解其深层的规则和jslint提示的缘由</p>
<p><strong>首先介绍==</strong><br />
11.9.1 等同运算符( == )</p>
<blockquote><p>
运算符规则如下所示：<br />
1. 计算运算符左侧表达式;<br />
2. 对第1步的结果调用GetValue;<br />
3. 计算运算符右侧表达式;<br />
4. 对第1步的结果调用GetValue;<br />
5. 对第4步的结果与第2步结果执行比对（参考 11.9.3）;<br />
6. 返回第5步结果;
</p></blockquote>
<p><strong>再来详细了解比对过程(11.9.3)</strong><br />
11.9.3 抽象的等同比对算法</p>
<blockquote><p>
假设有 x,y 进行比较 ，则有 x == y;<br />
1. 如果xy类型不同，转至第14步;<br />
2. 如果xy类型均为Undefined，返回 true;<br />
3. 如果xy类型均为Null，返回 true;<br />
4. 如果xy类型均不是Number(数值类型)，转至第11步;<br />
5. 如果x的值为NaN，返回 false;<br />
6. 如果y的值为NaN，返回 false;<br />
7. 如果x与y的数值相同，返回 true;<br />
8. 如果x是+0并且y是−0，返回 true;<br />
9. 如果x是−0并且y是+0，返回 true;<br />
10. 返回 false.<br />
11. 如果xy类型均为String(字符串类型)，判断x与y是否有相同的字符（对应位置字符相同），是则返回 true，否则返回 false;<br />
12. 如果xy类型均为Boolean(布尔类型)，xy均为true或均为false则返回 true，否则返回 false;<br />
13. 如果x与y引用同一个对象(object)或者xy引用的对象是Joined关系（参考13.1.2）则返回 true，否则返回 false;<br />
14. 如果x为null且y为undefined，返回 true;<br />
15. 如果x为undefined且y为null，返回 true;<br />
16. 如果x类型为Number，y类型为String，先将y转换为Number类型，再进行比对，返回结果;<br />
17. 如果x类型为String，y类型为Number，先将x转换为Number类型，在进行比对，返回结果;<br />
18. 如果x类型为Boolean，先将x转换为Number类型，再进行比对，返回结果;<br />
19. 如果y类型为Boolean，先将y转换为Number类型，再进行比对，返回结果;<br />
20. 如果x类型是String或者Number且y类型为Object，先将y转换为基本类型(ToPrimitive)，再进行比对，返回结果。<br />
21. 如果x类型为Object且y类型为String或者Number，先将x转换为基本类型(ToPrimitive)，再进行比对，返回结果。<br />
22. 返回 false.
</p></blockquote>
<p><strong>接着看恒等运算符（===）</strong><br />
11.9.4 严格等同运算符( === )</p>
<blockquote><p>
运算符规则如下所示：<br />
1. 计算运算符左侧表达式;<br />
2. 对第1步的结果调用GetValue;<br />
3. 计算运算符右侧表达式;<br />
4. 对第1步的结果调用GetValue;<br />
5. 对第4步的结果与第2步结果执行比对（参考 11.9.6）;<br />
6. 返回第5步结果;
</p></blockquote>
<p><strong>这几步和==运算符是一样的，我们着重来看第5步的比对过程：</strong><br />
11.9.6 严格性等同运算比对算法</p>
<blockquote><p>
假设有 x,y 进行比较 ，则有 x === y;<br />
1.如果xy类型不相同，返回 false;<br />
2. 如果xy类型均为Undefined，返回 true;<br />
3. 如果xy类型均为Null，返回 true;<br />
4. 如果xy类型均不是Number(数值类型)，转至第11步;<br />
5. 如果x的值为NaN，返回 false;<br />
6. 如果y的值为NaN，返回 false;<br />
7. 如果x与y的数值相同，返回 true;<br />
8. 如果x是+0并且y是−0，返回 true;<br />
9. 如果x是−0并且y是+0，返回 true;<br />
10. 返回 false.<br />
11. 如果xy类型均为String(字符串类型)，判断x与y是否有相同的字符（对应位置字符相同），是则返回 true，否则返回 false;<br />
12. 如果xy类型均为Boolean(布尔类型)，xy均为true或均为false则返回 true，否则返回 false;<br />
13. 如果x与y引用同一个对象(object)或者xy引用的对象是Joined关系（参考13.1.2）则返回 true，否则返回 false;
</p></blockquote>
<p><strong>可以做如下概括：</strong><br />
==运算符在做比对时存在类型转换的可能，而===运算符只在同类型之间比对，是==的严格模式。<br />
1.类型相同：进行===比对。<br />
2.类型不同：基本类型Boolean、Number、String这三者之间做比较时，总是向Number进行类型转换，然后再比较；如果类型有Object，那么将Object转化成基本类型，再进行比较；null仅和undefined匹配；其他都为false。<br />
<br />
根据规范和概括，我们不难明白：</p>
<ol>
<li>undefined只等于(==)undefined或null，null亦然</li>
<li>空字串(&#8221;) == 0 == false ，因为Number(&#8221;),Number(false) : 0</li>
<li>true == 1 ，因为Number(true) : 1</li>
<li>false===0 一定返回flase ，因为类型不同</li>
</ol>
<p><strong>恒等必定等同，等同未必恒等，需择之而用！</strong><br />
<br />
相关资源：<a href="http://www.jibbering.com/faq/faq_notes/type_convert.html#tcNumber" target="_blank">Javascript Type-Conversion</a><br />
<br />
&nbsp;</p>
<hr /><h2>Comments</h2><ul><li><a href="http://blog.silentash.com/2010/03/equals-operator-and-strict-equals-operator/?fuckgfw#comment-283">2010年03月3日</a>, <a href='http://www.xiaoxiaozi.com' rel='external nofollow' class='url'>simaopig</a> writes: 最后的总结很到位，呵呵。。恒等必定等同，等同未必恒等，需择之而用！

PS:JSLint只是听过，从未用过。。一会儿一定好好看看。。</li><li><a href="http://blog.silentash.com/2010/03/equals-operator-and-strict-equals-operator/?fuckgfw#comment-292">2010年03月4日</a>, <a href='http://www.kangre.com/' rel='external nofollow' class='url'>kangre</a> writes: 好详细哦！多谢！</li><li><a href="http://blog.silentash.com/2010/03/equals-operator-and-strict-equals-operator/?fuckgfw#comment-302">2010年03月6日</a>, <a href='http://blog.silentash.com/2010/03/iframe-content-document-compatibility/' rel='external nofollow' class='url'>Silentash-默尘 &raquo; iframe兼容性测试-文档内容获取</a> writes: [...] 测试结果(非IE浏览器及IE8)   从测试结果及其比对结果可以看出，A得到的是iframe这个html标签对象，B和C得到的是iframe浏览器对象(window)，有意思的是IE7及以下版本浏览器认为这两者是不恒等的  测试结果(IE7&amp;IE6-)  有趣吧，从B==C可以看出，证明两者是同一类型及同一引用，参考设计规范，理应恒等（===）。只能说，M$遵循的不是规范，是寂寞！好在IE8现在已经玩不起寂寞了。  接着测试浏览器对contentDocument的支持情况： [...]</li><li><a href="http://blog.silentash.com/2010/03/equals-operator-and-strict-equals-operator/?fuckgfw#comment-492">2010年05月18日</a>, <a href='http://wanz.im' rel='external nofollow' class='url'>丸子</a> writes: 嘿嘿，之前也写过一篇类似的。。。</li></ul><hr /><small>Copyright &copy; 2008-2010<br /> This feed is for personal, non-commercial use only. <br /> </small>]]></content:encoded>
			<wfw:commentRss>http://blog.silentash.com/2010/03/equals-operator-and-strict-equals-operator/?fuckgfw/feed</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
	</channel>
</rss>
