<?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/wp-feed.php/?feed=rss2" rel="self" type="application/rss+xml" />
	<link>http://blog.xhlv.com</link>
	<description>HTML CSS JS AS PHP Mysql</description>
	<pubDate>Sat, 27 Feb 2010 04:41:04 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.6.2</generator>
	<language>en</language>
			<item>
		<title>blog迁移成功</title>
		<link>http://blog.xhlv.com/2010/01/change-server-space-for-blog/</link>
		<comments>http://blog.xhlv.com/2010/01/change-server-space-for-blog/#comments</comments>
		<pubDate>Sat, 16 Jan 2010 15:13:15 +0000</pubDate>
		<dc:creator>admin</dc:creator>
		
		<category><![CDATA[我的生活]]></category>

		<guid isPermaLink="false">http://blog.xhlv.com/2010/01/blog%e8%bf%81%e7%a7%bb%e6%88%90%e5%8a%9f/</guid>
		<description><![CDATA[由于子域名没备案，原空间被服务商残忍的禁用了&#8230;&#8230;
倒腾了一天，终于在ISS上装了PHP+Mysql+URL Rewriting，并成功导入原有blog数据，真不容易～
期间碰到了很多麻烦的问题：
1.原先把PHP目录放到C盘，死活加载不成功php5isapi.dll，查了N多资料，改了N多次权限，重启了好多次，还是不行&#8230;&#8230;最后尝试了一下把PHP目录移到D盘，就OK了～
2.Mysql的乱码问题，原先的服务商的数据库编码是gb2312的，装完Mysql，改了编码设置，尝试了好几次将原先的sql数据导入到新的数据库中，可能是编码的问题，始终不行&#8230;&#8230;最后想起了Wordpress自带的功能导出的xml备份，成功避开了Mysql编码问题～
3.设置URL Rewriting，这个要容易些，查看了一些资料，将isapi_rwl_x86_0073.msi装到服务器上，添加到ISAPI中，然后将网上找的httpd.ini覆盖上去，最后根据自己的URL Rewriting需求改了一下httpd.ini中的正则匹配规则。
]]></description>
			<content:encoded><![CDATA[<p>由于子域名没备案，原空间被服务商残忍的禁用了&#8230;&#8230;</p>
<p>倒腾了一天，终于在ISS上装了PHP+Mysql+URL Rewriting，并成功导入原有blog数据，真不容易～</p>
<p>期间碰到了很多麻烦的问题：<br />
1.原先把PHP目录放到C盘，死活加载不成功php5isapi.dll，查了N多资料，改了N多次权限，重启了好多次，还是不行&#8230;&#8230;最后尝试了一下把PHP目录移到D盘，就OK了～</p>
<p>2.Mysql的乱码问题，原先的服务商的数据库编码是gb2312的，装完Mysql，改了编码设置，尝试了好几次将原先的sql数据导入到新的数据库中，可能是编码的问题，始终不行&#8230;&#8230;最后想起了Wordpress自带的功能导出的xml备份，成功避开了Mysql编码问题～</p>
<p>3.设置URL Rewriting，这个要容易些，查看了一些资料，将<a href="http://www.isapirewrite.com/download/isapi_rwl_x86_0073.msi">isapi_rwl_x86_0073.msi</a>装到服务器上，添加到ISAPI中，然后将网上找的httpd.ini覆盖上去，最后根据自己的URL Rewriting需求改了一下httpd.ini中的正则匹配规则。</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.xhlv.com/2010/01/change-server-space-for-blog/feed/</wfw:commentRss>
		</item>
		<item>
		<title>腾讯北京 招Web前端开发</title>
		<link>http://blog.xhlv.com/2009/12/job-from-tencent/</link>
		<comments>http://blog.xhlv.com/2009/12/job-from-tencent/#comments</comments>
		<pubDate>Wed, 16 Dec 2009 14:12:54 +0000</pubDate>
		<dc:creator>admin</dc:creator>
		
		<category><![CDATA[我的生活]]></category>

		<guid isPermaLink="false">http://blog.xhlv.com/2010/01/16/%e8%85%be%e8%ae%af%e5%8c%97%e4%ba%ac-%e6%8b%9bweb%e5%89%8d%e7%ab%af%e5%bc%80%e5%8f%91/</guid>
		<description><![CDATA[要求：
1.精通HTML、CSS、JS，有用户体验意识，对页面加速技术有了解；
2.懂AS者优先，懂PHP、CGI者优先，懂socket编程者优先，有海量服务开发经验者优先；
3.本科学历；
 有意向的同学请发简历及作品至xhlv#tencent.com (发邮件时请将#换成@)
]]></description>
			<content:encoded><![CDATA[<p>要求：<br />
1.精通HTML、CSS、JS，有用户体验意识，对页面加速技术有了解；<br />
2.懂AS者优先，懂PHP、CGI者优先，懂socket编程者优先，有海量服务开发经验者优先；<br />
3.本科学历；</p>
<p> 有意向的同学请发简历及作品至xhlv#tencent.com (发邮件时请将#换成@)</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.xhlv.com/2009/12/job-from-tencent/feed/</wfw:commentRss>
		</item>
		<item>
		<title>“千分位”格式化数据的正则</title>
		<link>http://blog.xhlv.com/2009/09/parsedata-regexp/</link>
		<comments>http://blog.xhlv.com/2009/09/parsedata-regexp/#comments</comments>
		<pubDate>Tue, 15 Sep 2009 05:15:54 +0000</pubDate>
		<dc:creator>admin</dc:creator>
		
		<category><![CDATA[JS/Ajax]]></category>

		<category><![CDATA[前端代码]]></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/2009/09/parsedata-regexp/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Maxthon,TencentTraveler绑架鼠标右键</title>
		<link>http://blog.xhlv.com/2009/09/maxthon-tencenttraveler-abduct-right-click/</link>
		<comments>http://blog.xhlv.com/2009/09/maxthon-tencenttraveler-abduct-right-click/#comments</comments>
		<pubDate>Sun, 13 Sep 2009 10:22:15 +0000</pubDate>
		<dc:creator>admin</dc:creator>
		
		<category><![CDATA[JS/Ajax]]></category>

		<category><![CDATA[前端代码]]></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/2009/09/maxthon-tencenttraveler-abduct-right-click/feed/</wfw:commentRss>
		</item>
		<item>
		<title>JS判断是不是Maxthon浏览器</title>
		<link>http://blog.xhlv.com/2009/09/javascript-identify-maxthon/</link>
		<comments>http://blog.xhlv.com/2009/09/javascript-identify-maxthon/#comments</comments>
		<pubDate>Sat, 12 Sep 2009 03:31:09 +0000</pubDate>
		<dc:creator>admin</dc:creator>
		
		<category><![CDATA[JS/Ajax]]></category>

		<category><![CDATA[前端代码]]></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/2009/09/javascript-identify-maxthon/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Editplus 调用 TortoiseSVN</title>
		<link>http://blog.xhlv.com/2009/09/editplus-use-tortoisesvn/</link>
		<comments>http://blog.xhlv.com/2009/09/editplus-use-tortoisesvn/#comments</comments>
		<pubDate>Thu, 10 Sep 2009 03:40:54 +0000</pubDate>
		<dc:creator>admin</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/2009/09/editplus-use-tortoisesvn/feed/</wfw:commentRss>
		</item>
		<item>
		<title>cssText在IE中的小bug</title>
		<link>http://blog.xhlv.com/2009/09/csstext-ie-bug/</link>
		<comments>http://blog.xhlv.com/2009/09/csstext-ie-bug/#comments</comments>
		<pubDate>Tue, 01 Sep 2009 09:56:53 +0000</pubDate>
		<dc:creator>admin</dc:creator>
		
		<category><![CDATA[JS/Ajax]]></category>

		<category><![CDATA[前端代码]]></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/2009/09/csstext-ie-bug/feed/</wfw:commentRss>
		</item>
		<item>
		<title>evalScripts的实现</title>
		<link>http://blog.xhlv.com/2009/07/evalscripts/</link>
		<comments>http://blog.xhlv.com/2009/07/evalscripts/#comments</comments>
		<pubDate>Wed, 22 Jul 2009 07:49:08 +0000</pubDate>
		<dc:creator>admin</dc:creator>
		
		<category><![CDATA[JS/Ajax]]></category>

		<category><![CDATA[前端代码]]></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/2009/07/evalscripts/feed/</wfw:commentRss>
		</item>
		<item>
		<title>等于比较符“==”解析过程</title>
		<link>http://blog.xhlv.com/2009/07/abstract-equality-comparison/</link>
		<comments>http://blog.xhlv.com/2009/07/abstract-equality-comparison/#comments</comments>
		<pubDate>Tue, 21 Jul 2009 09:55:42 +0000</pubDate>
		<dc:creator>admin</dc:creator>
		
		<category><![CDATA[JS/Ajax]]></category>

		<category><![CDATA[前端代码]]></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/2009/07/abstract-equality-comparison/feed/</wfw:commentRss>
		</item>
		<item>
		<title>计算某天是第几周</title>
		<link>http://blog.xhlv.com/2009/07/days-week-in-year/</link>
		<comments>http://blog.xhlv.com/2009/07/days-week-in-year/#comments</comments>
		<pubDate>Wed, 08 Jul 2009 14:21:27 +0000</pubDate>
		<dc:creator>admin</dc:creator>
		
		<category><![CDATA[JS/Ajax]]></category>

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

		<category><![CDATA[Date]]></category>

		<guid isPermaLink="false">http://blog.xhlv.com/2009/07/%e8%ae%a1%e7%ae%97%e6%9f%90%e5%a4%a9%e6%98%af%e7%ac%ac%e5%87%a0%e5%91%a8/</guid>
		<description><![CDATA[需求是：选中日历中的某一天，返回该天是在第几周。
原以为，将某天在一年中的总天数除以7，进行上舍入就可以，可惜没这么简单。
假设该年的第一天是周一，那么上面的算法是对的。但每年并不是都从星期一开始的，所以需要计算一下从星期几开始的。
具体算法如下：
1.计算出该天在一年中是第几天，记为Days；
2.计算该年第一天是星期几，记为FirstDay；
3.计算第几周：
   如果FirstDay是1，就比较好计算了，将Days/7进行向上舍入即可；
  如果FirstDay不是1，那么就需要这样计算，将(Days - (7 -FirstDay + 1))/7进行向上舍入，然后加1；
下面是获取今天是一年中第几周的JS代码：

&#60;script type="text/javascript"&#62;
var daysInMonth = [31,28,31,30,31,30,31,31,30,31,30,31];
if (((year%4 == 0)&#038;&#038;(year%100 != 0)) &#124;&#124; (year%400 == 0)) {
	daysInMonth[1] = 29;
}
var now = new Date();
var month = now.getMonth(),year = now.getFullYear(),days = now.getDate();
for (var i = 0;i < month;i++) {
	days += daysInMonth[i];
}
var firstDay = new Date(year,0,1).getDay();
if (firstDay == 0) firstDay [...]]]></description>
			<content:encoded><![CDATA[<p>需求是：选中日历中的某一天，返回该天是在第几周。</p>
<p>原以为，将某天在一年中的总天数除以7，进行上舍入就可以，可惜没这么简单。</p>
<p>假设该年的第一天是周一，那么上面的算法是对的。但每年并不是都从星期一开始的，所以需要计算一下从星期几开始的。</p>
<p>具体算法如下：<br />
1.计算出该天在一年中是第几天，记为Days；<br />
2.计算该年第一天是星期几，记为FirstDay；<br />
3.计算第几周：<br />
   如果FirstDay是1，就比较好计算了，将Days/7进行向上舍入即可；<br />
  如果FirstDay不是1，那么就需要这样计算，将(Days - (7 -FirstDay + 1))/7进行向上舍入，然后加1；</p>
<p>下面是获取今天是一年中第几周的JS代码：</p>
<pre><textarea name="code" class="html">
&lt;script type="text/javascript"&gt;
var daysInMonth = [31,28,31,30,31,30,31,31,30,31,30,31];
if (((year%4 == 0)&#038;&#038;(year%100 != 0)) || (year%400 == 0)) {
	daysInMonth[1] = 29;
}
var now = new Date();
var month = now.getMonth(),year = now.getFullYear(),days = now.getDate();
for (var i = 0;i < month;i++) {
	days += daysInMonth[i];
}
var firstDay = new Date(year,0,1).getDay();
if (firstDay == 0) firstDay = 7;
week = Math.ceil(( days - (firstDay != 1 ? 7 - firstDay + 1 : 0) )/7) + (firstDay != 1 ? 1 : 0);

document.write('今天是第' + week + '周');
&lt;/script&gt;
</textarea></pre>
]]></content:encoded>
			<wfw:commentRss>http://blog.xhlv.com/2009/07/days-week-in-year/feed/</wfw:commentRss>
		</item>
	</channel>
</rss>
