<?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"
	>

<channel>
	<title>xhlv's blog</title>
	<atom:link href="http://blog.xhlv.com/index.php/feed" rel="self" type="application/rss+xml" />
	<link>http://blog.xhlv.com</link>
	<description>xhlv's blog</description>
	<pubDate>Wed, 28 Sep 2011 13:36:02 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.6.2</generator>
	<language>en</language>
			<item>
		<title>十一</title>
		<link>http://blog.xhlv.com/index.php/2011/09/28/1001/</link>
		<comments>http://blog.xhlv.com/index.php/2011/09/28/1001/#comments</comments>
		<pubDate>Wed, 28 Sep 2011 13:35:24 +0000</pubDate>
		<dc:creator>xhlv</dc:creator>
		
		<category><![CDATA[我的生活]]></category>

		<guid isPermaLink="false">http://blog.xhlv.com/index.php/2011/09/28/%e5%8d%81%e4%b8%80/</guid>
		<description><![CDATA[
又十一了，还没想好去哪玩&#8230;&#8230;
转眼来TX两年了，好久没写博客了，后面争取多写写吧 ：）
]]></description>
			<content:encoded><![CDATA[<div>
<p>又十一了，还没想好去哪玩&#8230;&#8230;</p>
<p>转眼来TX两年了，好久没写博客了，后面争取多写写吧 ：）</p></div>
]]></content:encoded>
			<wfw:commentRss>http://blog.xhlv.com/index.php/2011/09/28/1001/feed/</wfw:commentRss>
		</item>
		<item>
		<title>IE href bug</title>
		<link>http://blog.xhlv.com/index.php/2010/08/11/ie-href-bug/</link>
		<comments>http://blog.xhlv.com/index.php/2010/08/11/ie-href-bug/#comments</comments>
		<pubDate>Wed, 11 Aug 2010 16:40:03 +0000</pubDate>
		<dc:creator>xhlv</dc:creator>
		
		<category><![CDATA[JS/Ajax]]></category>

		<category><![CDATA[前端代码]]></category>

		<category><![CDATA[iebug]]></category>

		<guid isPermaLink="false">http://blog.xhlv.com/index.php/2010/08/11/ie-href-bug/</guid>
		<description><![CDATA[在IE中，如果修改a标签的href，某些情况下，a标签的innerHTML也会被修改&#8230;&#8230;
很诡异的bug，貌似跟a标签里的内容有关系。
解决方法是在修改href时，赋值前面加一个空格，如：
el.herf = &#8216; &#8216; + &#8216;http://blog.xhlv.com&#8217;;

http://url.cn/3mAAJj

url.cn/3mAAJj


function edit(id){
var el = document.getElementById('t'+id);
el.href='http://blog.xhlv.com'
alert(el.innerHTML);
}


]]></description>
			<content:encoded><![CDATA[<p>在IE中，如果修改a标签的href，某些情况下，a标签的innerHTML也会被修改&#8230;&#8230;<br />
很诡异的bug，貌似跟a标签里的内容有关系。</p>
<p>解决方法是在修改href时，赋值前面加一个空格，如：<br />
el.herf = &#8216; &#8216; + &#8216;http://blog.xhlv.com&#8217;;</p>
<pre><textarea name="code" class="html">
<a id="t1" href="http://url.cn/3mAAJj">http://url.cn/3mAAJj</a>
<input type="button" onclick="edit(1)" value="修改" />
<a id="t2" href="http://url.cn/3mAAJj">url.cn/3mAAJj</a>
<input type="button" onclick="edit(2)" value="修改" />
<script type="text/javascript">
function edit(id){
var el = document.getElementById('t'+id);
el.href='http://blog.xhlv.com'
alert(el.innerHTML);
}
</script>
</textarea></pre>
]]></content:encoded>
			<wfw:commentRss>http://blog.xhlv.com/index.php/2010/08/11/ie-href-bug/feed/</wfw:commentRss>
		</item>
		<item>
		<title>腾讯微博API</title>
		<link>http://blog.xhlv.com/index.php/2010/07/11/tencent-microblog/</link>
		<comments>http://blog.xhlv.com/index.php/2010/07/11/tencent-microblog/#comments</comments>
		<pubDate>Sun, 11 Jul 2010 12:06:54 +0000</pubDate>
		<dc:creator>xhlv</dc:creator>
		
		<category><![CDATA[JS/Ajax]]></category>

		<category><![CDATA[PHP/Mysql]]></category>

		<category><![CDATA[前端代码]]></category>

		<guid isPermaLink="false">http://blog.xhlv.com/index.php/2010/07/11/%e8%85%be%e8%ae%af%e5%be%ae%e5%8d%9aapi/</guid>
		<description><![CDATA[（请勿用于商业用途，谢谢）
我也来玩腾讯微博API，简单封装了一下。
PHP方法：


Javascript方法：


function microblog(data){
}



]]></description>
			<content:encoded><![CDATA[<p>（请勿用于商业用途，谢谢）</p>
<p>我也来玩腾讯微博API，简单封装了一下。</p>
<p>PHP方法：</p>
<pre><textarea name="code" class="php"><?php
$json_str = file_get_contents('http://blog.xhlv.com/t?u=xhlv');
$arr = json_decode($json_str);
$i = 0;
foreach ($arr as $value) {
	$message = get_object_vars($value);
	if($i < 10) echo '
<li class="twitter-item">'.preg_replace('/href="\//i','target="_blank" href="http://t.qq.com\/',$message['content']).'<a href="http://t.qq.com/p/t/'.$message['id'].'" target="_blank">'.$message['time'].'</a> '.$message['from'].'</li>

';
	$i++;
}
?>
</textarea></pre>
<p>Javascript方法：</p>
<pre><textarea name="code" class="html">
<script type="text/javascript">
function microblog(data){
}
</script>
<script type="text/javascript" src="http://blog.xhlv.com/t/?u=xhlv&#038;call=microblog"></script>
</textarea></pre>
]]></content:encoded>
			<wfw:commentRss>http://blog.xhlv.com/index.php/2010/07/11/tencent-microblog/feed/</wfw:commentRss>
		</item>
		<item>
		<title>“千分位”格式化数据的正则</title>
		<link>http://blog.xhlv.com/index.php/2009/09/15/parsedata-regexp/</link>
		<comments>http://blog.xhlv.com/index.php/2009/09/15/parsedata-regexp/#comments</comments>
		<pubDate>Tue, 15 Sep 2009 05:15:54 +0000</pubDate>
		<dc:creator>xhlv</dc:creator>
		
		<category><![CDATA[JS/Ajax]]></category>

		<category><![CDATA[正则]]></category>

		<guid isPermaLink="false">http://blog.xhlv.com/2009/09/%e6%a0%bc%e5%bc%8f%e5%8c%96%e6%95%b0%e6%8d%ae%e7%9a%84%e6%ad%a3%e5%88%99/</guid>
		<description><![CDATA[把12345678此类格式的数据换成 12,345,678 格式？

据说是腾讯面试的一道题，还是蛮有意思的。
可以选择用循环来进行处理，但效率显然没有正则来得高。
&#34;12345678&#34;.replace(/(?=(?:\w{3})+$)/g,&#34;,&#34;) //这是网上找的一个正则，有点缺陷，在后面再修正～
这个正则是怎么进行工作的？
研究了一下，它是非常巧妙的利用?=和?:来完成匹配。
?=和?:的功能可以看下面的例子，就应该明白他们的作用了：
&#34;IE 6,IE 7,IE 8&#34;.match(/IE (?:7&#124;8)/gi); //[&#34;IE 7&#34;, &#34;IE 8&#34;]
&#34;IE 6,IE 7,IE 8&#34;.match(/IE (?=7&#124;8)/gi); //[&#34;IE &#34;, &#34;IE &#34;]
&#34;IE 6,IE 7,IE 8&#34;.match(/IE (?!7&#124;8)/gi); //[&#34;IE &#34;]，这个其实相当于匹配：&#34;IE 6,IE 7,IE 8&#34;.match(/IE (?=6)/gi);
这个正则，可以分成两部分：(?=) 和 (?:\w{3})+$
首先，(?:\w{3})+$，从最后开始匹配3的整数倍个数字；
然后，(?=)，预搜索符合上述条件的匹配：678、345678所在左侧缝隙的空字符串（&#34;12缝隙345缝隙678&#34;），[&#34;&#34;,&#34;&#34;]；
最后，将匹配到的空字符串替换成&#34;,&#34;。
实际上，/(?=(?:\w{3})+$)/g 和 /(?=((?:\w{3})+$))/g 效果是一样的。
这个正则有什么缺陷？
有，比如&#34;123456789&#34;会被替换成&#34;,123,456,789&#34;，多出来一个逗号。
可以这样来完善这个正则：
&#34;123456789&#34;.replace(/(?=(?!\b)(?:\w{3})+$)/g,&#34;,&#34;)
加一个(?!\b)，让(?:\w{3})+$的匹配前面不是边界，就不会包含&#34;123456789&#34;了。
]]></description>
			<content:encoded><![CDATA[<blockquote><p>把12345678此类格式的数据换成 12,345,678 格式？</p>
</blockquote>
<p>据说是腾讯面试的一道题，还是蛮有意思的。<br />
可以选择用循环来进行处理，但效率显然没有正则来得高。</p>
<p>&quot;12345678&quot;.replace(<span style="color:red;">/(?=(?:\w{3})+$)/g</span>,&quot;,&quot;) //这是网上找的一个正则，有点缺陷，在后面再修正～</p>
<p><strong>这个正则是怎么进行工作的？</strong></p>
<p>研究了一下，它是非常巧妙的利用?=和?:来完成匹配。<br />
?=和?:的功能可以看下面的例子，就应该明白他们的作用了：<br />
<span style="color:#808080">&quot;IE 6,IE 7,IE 8&quot;.match(/IE (?:7|8)/gi); //[&quot;IE 7&quot;, &quot;IE 8&quot;]<br />
&quot;IE 6,IE 7,IE 8&quot;.match(/IE (?=7|8)/gi); //[&quot;IE &quot;, &quot;IE &quot;]<br />
&quot;IE 6,IE 7,IE 8&quot;.match(/IE (?!7|8)/gi); //[&quot;IE &quot;]，这个其实相当于匹配：&quot;IE 6,IE 7,IE 8&quot;.match(/IE (?=6)/gi);</span></p>
<p>这个正则，可以分成两部分：(?=) 和 (?:\w{3})+$<br />
首先，(?:\w{3})+$，从最后开始匹配3的整数倍个数字；<br />
然后，(?=)，预搜索符合上述条件的匹配：678、345678所在左侧缝隙的空字符串（&quot;12缝隙345缝隙678&quot;），[&quot;&quot;,&quot;&quot;]；<br />
最后，将匹配到的空字符串替换成&quot;,&quot;。</p>
<p>实际上，/(?=(?:\w{3})+$)/g 和 /(?=((?:\w{3})+$))/g 效果是一样的。</p>
<p><strong>这个正则有什么缺陷？</strong><br />
有，比如&quot;123456789&quot;会被替换成&quot;,123,456,789&quot;，多出来一个逗号。</p>
<p>可以这样来完善这个正则：<br />
&quot;123456789&quot;.replace(<span style="color:red;">/(?=(?!\b)(?:\w{3})+$)/g</span>,&quot;,&quot;)</p>
<p>加一个(?!\b)，让(?:\w{3})+$的匹配前面不是边界，就不会包含&quot;123456789&quot;了。</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.xhlv.com/index.php/2009/09/15/parsedata-regexp/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Maxthon,TencentTraveler绑架鼠标右键</title>
		<link>http://blog.xhlv.com/index.php/2009/09/13/maxthon-tencenttraveler-abduct-right-click/</link>
		<comments>http://blog.xhlv.com/index.php/2009/09/13/maxthon-tencenttraveler-abduct-right-click/#comments</comments>
		<pubDate>Sun, 13 Sep 2009 10:22:15 +0000</pubDate>
		<dc:creator>xhlv</dc:creator>
		
		<category><![CDATA[JS/Ajax]]></category>

		<category><![CDATA[bug]]></category>

		<guid isPermaLink="false">http://blog.xhlv.com/2009/09/maxthontencenttraveler%e7%bb%91%e6%9e%b6%e9%bc%a0%e6%a0%87%e5%8f%b3%e9%94%ae/</guid>
		<description><![CDATA[正常情况下，当用户右键按下时会触发mousedown事件，然后右键弹起时触发mouseup事件。
而在Maxthon,TencentTraveler中，为了达到鼠标动作的功能，强行把鼠标右键给截获了，也就是说：
当右键按下时并不会立刻触发mousedown事件；
当右键弹起时，先后触发mousedown和mouseup；
在右键弹起之前，如果鼠标移动，那么就会被视为“鼠标动作”的功能，mousedown和mouseup都不会触发。
当然，在这两种浏览器中，右键按下时contextmenu事件也是被截获了。
当无法避开这个问题时，可以通过判别浏览器，然后通过event.button的值来进行区分：
在这两种浏览器中，右键弹起触发mousedown时，event.button为0（其他浏览器都为2）
]]></description>
			<content:encoded><![CDATA[<p>正常情况下，当用户右键按下时会触发mousedown事件，然后右键弹起时触发mouseup事件。</p>
<p>而在Maxthon,TencentTraveler中，为了达到鼠标动作的功能，强行把鼠标右键给截获了，也就是说：<br />
<strong>当右键按下时并不会立刻触发mousedown事件；<br />
当右键弹起时，先后触发mousedown和mouseup；<br />
在右键弹起之前，如果鼠标移动，那么就会被视为“鼠标动作”的功能，mousedown和mouseup都不会触发。</strong></p>
<p>当然，在这两种浏览器中，右键按下时contextmenu事件也是被截获了。</p>
<p>当无法避开这个问题时，可以通过判别浏览器，然后通过event.button的值来进行区分：<br />
在这两种浏览器中，<strong style="color:red;">右键弹起触发mousedown时，event.button为0（其他浏览器都为2）</strong></p>
]]></content:encoded>
			<wfw:commentRss>http://blog.xhlv.com/index.php/2009/09/13/maxthon-tencenttraveler-abduct-right-click/feed/</wfw:commentRss>
		</item>
		<item>
		<title>JS判断是不是Maxthon浏览器</title>
		<link>http://blog.xhlv.com/index.php/2009/09/12/javascript-identify-maxthon/</link>
		<comments>http://blog.xhlv.com/index.php/2009/09/12/javascript-identify-maxthon/#comments</comments>
		<pubDate>Sat, 12 Sep 2009 03:31:09 +0000</pubDate>
		<dc:creator>xhlv</dc:creator>
		
		<category><![CDATA[JS/Ajax]]></category>

		<guid isPermaLink="false">http://blog.xhlv.com/2009/09/js%e5%88%a4%e6%96%ad%e6%98%af%e4%b8%8d%e6%98%afmaxthon%e6%b5%8f%e8%a7%88%e5%99%a8/</guid>
		<description><![CDATA[Maxthon 和 IE 的navigator.userAgent居然是一样的&#8230;.
所以只能另外想办法了，找了一下，原来Maxthon的版本信息是放在window['external']['max_version']中的，那么就可以这样来判断了：
isMaxthon = !!(window['external'] &#038;&#038; window['external']['max_version']);
]]></description>
			<content:encoded><![CDATA[<p>Maxthon 和 IE 的navigator.userAgent居然是一样的&#8230;.</p>
<p>所以只能另外想办法了，找了一下，原来Maxthon的版本信息是放在window['external']['max_version']中的，那么就可以这样来判断了：<br />
<strong>isMaxthon = !!(window['external'] &#038;&#038; window['external']['max_version']);</strong></p>
]]></content:encoded>
			<wfw:commentRss>http://blog.xhlv.com/index.php/2009/09/12/javascript-identify-maxthon/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Editplus 调用 TortoiseSVN</title>
		<link>http://blog.xhlv.com/index.php/2009/09/10/editplus-use-tortoisesvn/</link>
		<comments>http://blog.xhlv.com/index.php/2009/09/10/editplus-use-tortoisesvn/#comments</comments>
		<pubDate>Thu, 10 Sep 2009 03:40:54 +0000</pubDate>
		<dc:creator>xhlv</dc:creator>
		
		<category><![CDATA[前端工具]]></category>

		<category><![CDATA[插件/小软件]]></category>

		<guid isPermaLink="false">http://blog.xhlv.com/2009/09/editplus-%e8%b0%83%e7%94%a8-tortoisesvn/</guid>
		<description><![CDATA[
不断的在Editplus和文件夹之间切换，挺麻烦的，网上找了个Editplus调用svn的方法，还是挺好用的～
可以把常用的几个命令绑定到Ctrl + 1~4

edtiplus 工具-用户工具-添加工具-程序
菜单文本：SVN Commit
命令: C:\Program Files\TortoiseSVN\bin\TortoiseProc.exe
参数: /command:commit /path:&#34;$(FilePath)&#34; /notempfile /closeonend:0
初始目录: $(FileDir)
Check: &#34;Capture output&#34;, &#34;Save open files&#34;
其他方法：只需要把上面的&#34;参数&#34;里的：/command:commit 用下面的替换（例如：/command:about）
:about 显示关于对话框
:log 打开日志对话框
:checkout 打开检出对话框
:import 打开导入对话框
:update 将工作副本的/path更新到HEAD，如果给定参数/rev，就会弹出一个对话框询问用户需要更新到哪个修订版本。为了避免指定修订版本号/rev:1234的对话框，需要加上/nonrecursive和/ignoreexternals参数（这2个参数我没加，还没遇到上述问题）
:commit 打开提交对话框
:add 将/path的文件添加到版本控制
:revert 撤消一个文件自上次更新后的所有的变更
:cleanup 递归清理工作拷贝，删除未完成的工作拷贝锁定
:resolve 将/path指定文件的冲突标示为解决，如果加上/noquestion，将不会提示确认操作。
:repocreate 在/path创建一个版本库
:switch 切换至分枝/标记
:export 将/path的工作副本导出到另一个目录
:merge 打开合并对话框
:mergeall 打开合并所有对话框
:copy 复制工作副本至URL
:settings 打开设置对话框
:remove 从版本控制里移除/path中的文件
:rename 重命名/path的文件
:diff 启动TortoiseSVN设置的外置比较程序
:help 打开帮助文件
:relocate 打开重定位对话框
:help 打开帮助文件
:repobrowser 打开版本库浏览器对话框
:ignore 将/path中的对象加入到忽略列表，仅对文件夹有效。
:blame 打开文件的追溯对话框
:createpatch 创建/path下的补丁文件。
:revisiongraph 显示/path目录下的版本变化图。
:lock 锁定一个文件，可以输入锁定的原因。
:rebuildiconcache 重建windows的图标缓存，当系统图标缓存出了问题才需要这样做（会导致桌面的图标会重新排列）
:properties 显示 /path 给出的路径之属性对话框。


]]></description>
			<content:encoded><![CDATA[<p>
不断的在Editplus和文件夹之间切换，挺麻烦的，网上找了个Editplus调用svn的方法，还是挺好用的～</p>
<p>可以把常用的几个命令绑定到Ctrl + 1~4</p>
<blockquote><p>
edtiplus 工具-用户工具-添加工具-程序<br />
菜单文本：SVN Commit<br />
命令: C:\Program Files\TortoiseSVN\bin\TortoiseProc.exe<br />
参数: /command:commit /path:&quot;$(FilePath)&quot; /notempfile /closeonend:0<br />
初始目录: $(FileDir)<br />
Check: &quot;Capture output&quot;, &quot;Save open files&quot;</p>
<p>其他方法：只需要把上面的&quot;参数&quot;里的：/command:commit 用下面的替换（例如：/command:about）<br />
:about 显示关于对话框<br />
:log 打开日志对话框<br />
:checkout 打开检出对话框<br />
:import 打开导入对话框<br />
:update 将工作副本的/path更新到HEAD，如果给定参数/rev，就会弹出一个对话框询问用户需要更新到哪个修订版本。为了避免指定修订版本号/rev:1234的对话框，需要加上/nonrecursive和/ignoreexternals参数（这2个参数我没加，还没遇到上述问题）<br />
:commit 打开提交对话框<br />
:add 将/path的文件添加到版本控制<br />
:revert 撤消一个文件自上次更新后的所有的变更<br />
:cleanup 递归清理工作拷贝，删除未完成的工作拷贝锁定<br />
:resolve 将/path指定文件的冲突标示为解决，如果加上/noquestion，将不会提示确认操作。<br />
:repocreate 在/path创建一个版本库<br />
:switch 切换至分枝/标记<br />
:export 将/path的工作副本导出到另一个目录<br />
:merge 打开合并对话框<br />
:mergeall 打开合并所有对话框<br />
:copy 复制工作副本至URL<br />
:settings 打开设置对话框<br />
:remove 从版本控制里移除/path中的文件<br />
:rename 重命名/path的文件<br />
:diff 启动TortoiseSVN设置的外置比较程序<br />
:help 打开帮助文件<br />
:relocate 打开重定位对话框<br />
:help 打开帮助文件<br />
:repobrowser 打开版本库浏览器对话框<br />
:ignore 将/path中的对象加入到忽略列表，仅对文件夹有效。<br />
:blame 打开文件的追溯对话框<br />
:createpatch 创建/path下的补丁文件。<br />
:revisiongraph 显示/path目录下的版本变化图。<br />
:lock 锁定一个文件，可以输入锁定的原因。<br />
:rebuildiconcache 重建windows的图标缓存，当系统图标缓存出了问题才需要这样做（会导致桌面的图标会重新排列）<br />
:properties 显示 /path 给出的路径之属性对话框。
</p>
</blockquote>
]]></content:encoded>
			<wfw:commentRss>http://blog.xhlv.com/index.php/2009/09/10/editplus-use-tortoisesvn/feed/</wfw:commentRss>
		</item>
		<item>
		<title>cssText在IE中的小bug</title>
		<link>http://blog.xhlv.com/index.php/2009/09/01/csstext-ie-bug/</link>
		<comments>http://blog.xhlv.com/index.php/2009/09/01/csstext-ie-bug/#comments</comments>
		<pubDate>Tue, 01 Sep 2009 09:56:53 +0000</pubDate>
		<dc:creator>xhlv</dc:creator>
		
		<category><![CDATA[JS/Ajax]]></category>

		<category><![CDATA[iebug]]></category>

		<guid isPermaLink="false">http://blog.xhlv.com/2009/09/csstext%e5%9c%a8ie%e4%b8%ad%e7%9a%84%e5%b0%8fbug/</guid>
		<description><![CDATA[Element.style.cssText

当需要批量赋予Element样式时，cssText是比较好的方式，可以减少reflow，如：

Element.style.cssText = 'width:100px;height:100px;top:100px;left:100px;'

但是，这样会有一个问题，会把原有的cssText清掉，比如原来的style中有&#8217;display:none;&#8217;，那么执行完上面的JS后，display就被删掉了。
为了解决这个问题，可以采用cssText累加的方法：

Element.style.cssText += 'width:100px;height:100px;top:100px;left:100px;'

但是，cssText（假如不为空）在IE中最后一个分号会被删掉，比较BT&#8230;.
因此，上面cssText累加的方法在IE中是无效的。
最后，可以在前面添加一个分号来解决这个问题：

Element.style.cssText += ';width:100px;height:100px;top:100px;left:100px;'

]]></description>
			<content:encoded><![CDATA[<blockquote><p>Element.style.cssText</p>
</blockquote>
<p>当需要批量赋予Element样式时，cssText是比较好的方式，可以减少reflow，如：</p>
<pre><textarea name="code" class="JScript">
Element.style.cssText = 'width:100px;height:100px;top:100px;left:100px;'
</textarea></pre>
<p>但是，这样会有一个问题，会把原有的cssText清掉，比如原来的style中有&#8217;display:none;&#8217;，那么执行完上面的JS后，display就被删掉了。<br />
为了解决这个问题，可以采用cssText累加的方法：</p>
<pre><textarea name="code" class="JScript">
Element.style.cssText += 'width:100px;height:100px;top:100px;left:100px;'
</textarea></pre>
<p>但是，<strong style="color:red;">cssText（假如不为空）在IE中最后一个分号会被删掉</strong>，比较BT&#8230;.<br />
因此，上面cssText累加的方法在IE中是无效的。</p>
<p>最后，可以在前面添加一个分号来解决这个问题：</p>
<pre><textarea name="code" class="JScript">
Element.style.cssText += ';width:100px;height:100px;top:100px;left:100px;'
</textarea></pre>
]]></content:encoded>
			<wfw:commentRss>http://blog.xhlv.com/index.php/2009/09/01/csstext-ie-bug/feed/</wfw:commentRss>
		</item>
		<item>
		<title>evalScripts的实现</title>
		<link>http://blog.xhlv.com/index.php/2009/07/22/evalscripts/</link>
		<comments>http://blog.xhlv.com/index.php/2009/07/22/evalscripts/#comments</comments>
		<pubDate>Wed, 22 Jul 2009 07:49:08 +0000</pubDate>
		<dc:creator>xhlv</dc:creator>
		
		<category><![CDATA[JS/Ajax]]></category>

		<guid isPermaLink="false">http://blog.xhlv.com/2009/07/evalscripts%e7%9a%84%e5%ae%9e%e7%8e%b0/</guid>
		<description><![CDATA[在XHR一个页面的时候，有时可能需要执行页面中的脚本，这就是evalScripts了。
在Prototype中，有一个evalScripts的方法来实现这个功能。
这里就借鉴了它的方法，来实现evalScripts功能：

&#60;html&#62;
&#60;body&#62;
&#60;script type="text/javascript"&#62;
evalScript('&#60;html&#62;&#60;body&#62;&#60;script type="text/javascript"&#62;alert("x");&#60;/' + 'script&#62;&#60;/body&#62;&#60;/html&#62;')

function evalScript(str){
	var reg = ']*>([\\S\\s]*?)';
	var str = str.match(new RegExp(reg,'img'));
	for (var i = 0,num = str.length;i < num;i++) {
		eval(str[i].match(new RegExp(reg,'im'))[1]);
	}
}
&#60;/script&#62;
&#60;/body&#62;
&#60;/html&#62;

]]></description>
			<content:encoded><![CDATA[<p>在XHR一个页面的时候，有时可能需要执行页面中的脚本，这就是evalScripts了。</p>
<p>在Prototype中，有一个evalScripts的方法来实现这个功能。</p>
<p>这里就借鉴了它的方法，来实现evalScripts功能：</p>
<pre><textarea name="code" class="javascript">
&lt;html&gt;
&lt;body&gt;
&lt;script type="text/javascript"&gt;
evalScript('&lt;html&gt;&lt;body&gt;&lt;script type="text/javascript"&gt;alert("x");&lt;/' + 'script&gt;&lt;/body&gt;&lt;/html&gt;')

function evalScript(str){
	var reg = '<script[^>]*>([\\S\\s]*?)<\/script>';
	var str = str.match(new RegExp(reg,'img'));
	for (var i = 0,num = str.length;i < num;i++) {
		eval(str[i].match(new RegExp(reg,'im'))[1]);
	}
}
&lt;/script&gt;
&lt;/body&gt;
&lt;/html&gt;
</textarea></pre>
]]></content:encoded>
			<wfw:commentRss>http://blog.xhlv.com/index.php/2009/07/22/evalscripts/feed/</wfw:commentRss>
		</item>
		<item>
		<title>等于比较符“==”解析过程</title>
		<link>http://blog.xhlv.com/index.php/2009/07/21/abstract-equality-comparison/</link>
		<comments>http://blog.xhlv.com/index.php/2009/07/21/abstract-equality-comparison/#comments</comments>
		<pubDate>Tue, 21 Jul 2009 09:55:42 +0000</pubDate>
		<dc:creator>xhlv</dc:creator>
		
		<category><![CDATA[JS/Ajax]]></category>

		<guid isPermaLink="false">http://blog.xhlv.com/2009/07/%e7%ad%89%e4%ba%8e%e6%af%94%e8%be%83%e7%ac%a6%e2%80%9c%e2%80%9d%e8%a7%a3%e6%9e%90%e8%bf%87%e7%a8%8b/</guid>
		<description><![CDATA[alert([] == false); //弹出的是true
一个空数组应该是true才对，如：if([]) alert(&#8217;[] is true&#8217;);
那为什么空数组会等于false呢？
既然空数组等于false，那为什么空对象不等于false呢？如：
var b = {};
alert(b == false); //弹出的是false
非常的好奇，查阅了官方资料，原来“==”的解析过程是这样的：
The Abstract Equality Comparison Algorithm
The comparison x == y,where x and y are values, produces true or false. Such a comparison is
performed as follows:
1. If Type(x) is different from Type(y), go to step 14.
2. If Type(x) is Undefined, return true.
3. If Type(x) is [...]]]></description>
			<content:encoded><![CDATA[<p>alert([] == false); //弹出的是true</p>
<p>一个空数组应该是true才对，如：if([]) alert(&#8217;[] is true&#8217;);<br />
那为什么空数组会等于false呢？</p>
<p>既然空数组等于false，那为什么空对象不等于false呢？如：<br />
var b = {};<br />
alert(b == false); //弹出的是false</p>
<p>非常的好奇，查阅了官方资料，原来“==”的解析过程是这样的：</p>
<blockquote><p>The Abstract Equality Comparison Algorithm<br />
The comparison x == y,where x and y are values, produces true or false. Such a comparison is<br />
performed as follows:<br />
1. If Type(x) is different from Type(y), go to step 14.<br />
2. If Type(x) is Undefined, return true.<br />
3. If Type(x) is Null, return true.<br />
4. If Type(x) is not Number, go to step 11.<br />
5. If x is NaN,return false.<br />
6. If y is NaN,return false.<br />
7. If x is the same number value as y,return true.<br />
8. If x is +0 and y is −0,return true.<br />
9. If x is −0 and y is +0,return true.<br />
10. Return false.<br />
11.If Type(x) is String, then return true if x and y are exactly the same sequence of characters (same<br />
length and same characters in corresponding positions). Otherwise, return false.<br />
12. If Type(x) is Boolean, return true if x and y are both true or both false.Otherwise,return false.<br />
13.Return true if x and y refer to the same object or if they refer to objects joined to each other (see<br />
13.1.2). Otherwise, return false.<br />
14. If x is null and y is undefined,return true.<br />
15. If x is undefined and y is null,return true.<br />
16.If Type(x) is Number and Type(y) is String,<br />
return the result of the comparison x == ToNumber(y).<br />
17.If Type(x) is String and Type(y) is Number,<br />
return the result of the comparison ToNumber(x)== y.<br />
18. If Type(x) is Boolean, return the result of the comparison ToNumber(x)== y.<br />
19. If Type(y) is Boolean, return the result of the comparison x == ToNumber(y).<br />
20.If Type(x) is either String or Number and Type(y) is Object,<br />
return the result of the comparison x == ToPrimitive(y).<br />
21.If Type(x) is Object and Type(y) is either String or Number,<br />
return the result of the comparison ToPrimitive(x)== y.<br />
22. Return false.</p>
</blockquote>
<p>那么，对一个空数组和空对象，直接跳到了14步。</p>
<p>然后在19步时，把false转成number，即0。</p>
<p>然后在21步时，将空数组和空对象转换成原始数据类型，与0进行比较；这是最关键的一步，空数组和空对象，转换成数值类型分别是0和NaN，转换成字符串分别是&#8221;和&#8217;[object Object]&#8216;，官方没说到底转成了哪种原始数据类型，但已经可以看到他们的区别了，0和&#8221;等于false，NaN或&#8217;[object Object]&#8216;不等于false。</p>
<p>因此空数组等于false，而空对象不等于false。</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.xhlv.com/index.php/2009/07/21/abstract-equality-comparison/feed/</wfw:commentRss>
		</item>
	</channel>
</rss>

