<?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>三水清chrome</title>
	<atom:link href="http://js8.in/tag/chrome/feed" rel="self" type="application/rss+xml" />
	<link>http://js8.in</link>
	<description>专注前端开发,分享Javascript/CSS/PHP等Web前端开发技巧</description>
	<lastBuildDate>Sat, 21 Apr 2012 02:50:09 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.6</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>chrome扩展应用开发教程之调试和打包上线</title>
		<link>http://js8.in/841.html</link>
		<comments>http://js8.in/841.html#comments</comments>
		<pubDate>Mon, 24 Oct 2011 01:10:02 +0000</pubDate>
		<dc:creator>三水清</dc:creator>
				<category><![CDATA[web前端开发]]></category>
		<category><![CDATA[APP]]></category>
		<category><![CDATA[chrome]]></category>
		<category><![CDATA[插件开发]]></category>

		<guid isPermaLink="false">http://www.js8.in/?p=841</guid>
		<description><![CDATA[今天的文章来说说chrome扩展开发的最后一步，代码调试和打包上线。
chrome扩展应用开发教程系列：《开发chrome应用基础》《天气预报应用开发》《调试和打包上线》
chrome应用代码调试
跟前端开发一样，chrome应用开发过程中也是需要代码调试的，用的调试工具自然是chrome的开发者工具，所以前端开发工程师应该很快就可以上手！
代码调试需要调出来chrome的扩展程序页面，有三种方式调出来chrome的扩展程序页面

chrome右上角“扳手图标”→工具→扩展程序
新开个chrome选项卡，然后在地址栏输入：chrome://extensions/回车
右键点击某个扩展，选择管理扩展程序

这样就会看到如下的扩展程序界面：
点击右上角的“开发者模式”，就会出现三个按钮，选择“载入正在开发中的扩展程序&#8230;”，在新开的窗口中找到自己开发的程序的路径，然后打开就可以导入开发中的chrome应用了。点击活动视窗，就可以打开chrome的开发中工具，前端开发工程师就可以进行调试了，跟调试前端页面一样哦。

如果chrome的扩展代码更新了可以点击“重新载入”就可以使用最新的代码了。
chrome扩展应用的打包
如果你使用 Chrome Developer Dashboard，发布你的扩展，你将无需自己打包。你自己打包一个crx的唯一原因是你需要发布一个非公开版本，比如一个alpha测试版本给测试用户。
当你打包一个扩展到时候。这个扩展获得唯一的一对密钥，其中的公共密钥用于标识这个扩展，私密密钥用于保存私密信息和给这个扩展的各个版本签名。当你需要更新版本只是，需要找个签名文件。
使用扩展程序打包
进入chrome的扩展程序页面，选择“打包扩展程序&#8230;”弹出窗口：
选择chrome扩展所在的文件路径，如果是更新chrome应用需要选择签名文件所在的地址，点击确定打包即可，打包成功会收到如下图的提示信息：
命令行打包chrome应用
chrome应用打包还支持命令行，只需要运行cmd，然后输入命令行参数即可完成打包过程。
&#8211;pack-extension指定扩展所在的文件夹，
&#8211;pack-extension-key指定私钥所在的文件位置，
如果你不想看到对话框，请使用 &#8211;no-message-box。
命令行打包示例：

chrome.exe --pack-extension=c:\\myext --pack-extension-key=c:\\myext.pem

到此一个chrome扩展就开发完成了。希望《chrome扩展应用开发教程》对你的chrome开发有帮助。

《开发chrome应用基础》
《天气预报应用开发》
《调试和打包上线》



声明：文章未声明为原创文章，本文链接 http://js8.in/841.html. 转载请注明转自 JS8.IN ™
随机文章

谷歌要退出中国大陆市场？！
jQuery选择器使用详解
页面设计的10免费图标组合
利用google博客的ping服务接口API加快网站收录
博客终于再次开通了
IE6中a标签location.href失效解决方法
开博两年了：换了主题 改了名
php、js两种不同方式根据关键词返回经纬度接口【基于Google map API】


© 三水清 for 三水清, 2011. &#124;
3 comments &#124;在微博关注我：@清-三水清
收藏到：
人人网 &#124; 豆瓣 &#124; 开心网 &#124; QQ书签 &#124; 新浪微博 &#124; 腾讯微博

Post tags: APP, chrome, 插件开发
<table class="wumii-related-items" cellspacing="0" cellpadding="3" border="0"  style="clear: both;">
    
    <tr>
        <td colspan="4"><b><font size="-1"  style="display: block !important; padding: 20px 0 5px !important;">猜你喜欢：</font></b></td>
    </tr>
    
        <tr>
                <td width="102" valign="top" style="padding: 5px !important; margin: 0 !important;">
                    <a target="_blank" title="chrome扩展应用开发教程之天气预报应用开发" style="text-decoration: none !important; cursor: pointer !important;" href="http://app.wumii.com/ext/redirect?url=http%3A%2F%2Fjs8.in%2F834.html&from=http%3A%2F%2Fjs8.in%2F841.html">
                        <img style="margin: 0 !important; padding: 2px !important; border: 1px solid #DDDDDD !important; width: 96px !important; height: 96px !important;" src="http://static.wumii.com/site_images/2011/11/17/10982169.png" width="96px" height="96px" /><br />
                        <font size="-1" color="#333333" style="display: block !important; line-height: 15px !important; width: 102px !important; font: 12px/15px arial !important; height: 60px !important; margin: 3px 0 0 0 !important; padding: 0 !important; overflow: hidden !important;">chrome扩展应用开发教程之天气预报应用开发</font>
                    </a>
                </td>
                <td width="102" valign="top" style="padding: 5px !important; margin: 0 !important; border-left: 1px solid #DDDDDD !important;">
                    <a target="_blank" title="chrome扩展应用开发教程之开发chrome应用基础" style="text-decoration: none !important; cursor: pointer !important;" href="http://app.wumii.com/ext/redirect?url=http%3A%2F%2Fjs8.in%2F818.html&from=http%3A%2F%2Fjs8.in%2F841.html">
                        <img style="margin: 0 !important; padding: 2px !important; border: 1px solid #DDDDDD !important; width: 96px !important; height: 96px !important;" src="http://static.wumii.com/site_images/2011/11/17/10976944.png" width="96px" height="96px" /><br />
                        <font size="-1" color="#333333" style="display: block !important; line-height: 15px !important; width: 102px !important; font: 12px/15px arial !important; height: 60px !important; margin: 3px 0 0 0 !important; padding: 0 !important; overflow: hidden !important;">chrome扩展应用开发教程之开发chrome应用基础</font>
                    </a>
                </td>
                <td width="102" valign="top" style="padding: 5px !important; margin: 0 !important; border-left: 1px solid #DDDDDD !important;">
                    <a target="_blank" title="css解决chrome 12px字号限制" style="text-decoration: none !important; cursor: pointer !important;" href="http://app.wumii.com/ext/redirect?url=http%3A%2F%2Fjs8.in%2F625.html&from=http%3A%2F%2Fjs8.in%2F841.html">
                        <img style="margin: 0 !important; padding: 2px !important; border: 1px solid #DDDDDD !important; width: 96px !important; height: 96px !important;" src="http://static.wumii.com/site_images/2011/11/17/10979712.jpg" width="96px" height="96px" /><br />
                        <font size="-1" color="#333333" style="display: block !important; line-height: 15px !important; width: 102px !important; font: 12px/15px arial !important; height: 60px !important; margin: 3px 0 0 0 !important; padding: 0 !important; overflow: hidden !important;">css解决chrome 12px字号限制</font>
                    </a>
                </td>
                <td width="102" valign="top" style="padding: 5px !important; margin: 0 !important; border-left: 1px solid #DDDDDD !important;">
                    <a target="_blank" title="发现Chrome下提交表单的一个bug" style="text-decoration: none !important; cursor: pointer !important;" href="http://app.wumii.com/ext/redirect?url=http%3A%2F%2Fjs8.in%2F356.html&from=http%3A%2F%2Fjs8.in%2F841.html">
                        <img style="margin: 0 !important; padding: 2px !important; border: 1px solid #DDDDDD !important; width: 96px !important; height: 96px !important;" src="http://static.wumii.com/site_images/2011/11/17/10984473.gif" width="96px" height="96px" /><br />
                        <font size="-1" color="#333333" style="display: block !important; line-height: 15px !important; width: 102px !important; font: 12px/15px arial !important; height: 60px !important; margin: 3px 0 0 0 !important; padding: 0 !important; overflow: hidden !important;">发现Chrome下提交表单的一个bug</font>
                    </a>
                </td>
        </tr>
    
    <tr>
        <td colspan="4" align="right">
            <a style="text-decoration: none !important;" href="http://www.wumii.com/widget/relatedItems" target="_blank" title="无觅相关文章插件">
                <font size="-1" color="#bbbbbb" style="display: block !important; font-family: arial !important; padding: 5px 0 !important; font-size: 12px !important; color: #bbb !important;">无觅</font>
            </a>
        </td>
    </tr>
</table>]]></description>
			<content:encoded><![CDATA[<p>今天的文章来说说chrome扩展开发的最后一步，代码调试和打包上线。</p>
<p><strong>chrome扩展</strong>应用开发教程系列：《<a href="http://js8.in/818.html" target="_blank" title="chrome扩展应用开发教程之开发chrome应用基础">开发chrome应用基础</a>》《<a href="http://js8.in/834.html" target="_blank" title="chrome扩展应用开发教程之天气预报应用开发">天气预报应用开发</a>》《<a href="http://js8.in/841.html" target="_blank" title="chrome扩展应用开发教程之调试和打包上线">调试和打包上线</a>》</p>
<h2>chrome应用代码调试</h2>
<p>跟<strong>前端开发</strong>一样，chrome应用开发过程中也是需要代码调试的，用的调试工具自然是chrome的开发者工具，所以前端开发工程师应该很快就可以上手！</p>
<p>代码调试需要调出来chrome的扩展程序页面，有三种方式调出来chrome的扩展程序页面</p>
<ol>
<li>chrome右上角“扳手图标”→工具→扩展程序</li>
<li>新开个chrome选项卡，然后在地址栏输入：chrome://extensions/回车</li>
<li>右键点击某个扩展，选择管理扩展程序</li>
</ol>
<p>这样就会看到如下的扩展程序界面：<br />
<div id="attachment_844" class="wp-caption aligncenter" style="width: 310px"><a href="http://js8.in/841.html/2011-10-22_124540" rel="attachment wp-att-844"><img src="http://js8.in/wp-content/uploads/2011/10/2011-10-22_124540-300x179.png" alt="chrome扩展程序界面" title="chrome扩展程序界面" width="300" height="179" class="size-medium wp-image-844" /></a><p class="wp-caption-text">chrome扩展程序界面</p></div></p>
<p>点击右上角的“开发者模式”，就会出现三个按钮，选择“载入正在开发中的扩展程序&#8230;”，在新开的窗口中找到自己开发的程序的路径，然后打开就可以导入开发中的chrome应用了。点击活动视窗，就可以打开chrome的开发中工具，前端开发工程师就可以进行调试了，跟调试前端页面一样哦。<br />
<span id="more-841"></span><br />
如果chrome的扩展代码更新了可以点击“重新载入”就可以使用最新的代码了。</p>
<h2>chrome扩展应用的打包</h2>
<p>如果你使用 <a target="_blank" href="https://chrome.google.com/webstore/developer/dashboard">Chrome Developer Dashboard</a>，发布你的扩展，你将无需自己打包。你自己打包一个crx的唯一原因是你需要发布一个非公开版本，比如一个alpha测试版本给测试用户。</p>
<p>当你打包一个扩展到时候。这个扩展获得唯一的一对密钥，其中的公共密钥用于标识这个扩展，私密密钥用于保存私密信息和给这个扩展的各个版本签名。当你需要更新版本只是，需要找个签名文件。</p>
<h2>使用扩展程序打包</h2>
<p>进入chrome的扩展程序页面，选择“打包扩展程序&#8230;”弹出窗口：</p>
<div id="attachment_846" class="wp-caption aligncenter" style="width: 310px"><a href="http://js8.in/841.html/2011-10-22_130404" rel="attachment wp-att-846"><img src="http://js8.in/wp-content/uploads/2011/10/2011-10-22_130404-300x95.png" alt="chrome扩展打包弹出框" title="chrome扩展打包弹出框" width="300" height="95" class="size-medium wp-image-846" /></a><p class="wp-caption-text">chrome扩展打包弹出框</p></div>
<p>选择chrome扩展所在的文件路径，如果是更新chrome应用需要选择签名文件所在的地址，点击确定打包即可，打包成功会收到如下图的提示信息：</p>
<div id="attachment_845" class="wp-caption aligncenter" style="width: 310px"><a href="http://js8.in/841.html/2011-10-22_130344" rel="attachment wp-att-845"><img src="http://js8.in/wp-content/uploads/2011/10/2011-10-22_130344-300x191.png" alt="chrome扩展打包成功提示" title="chrome扩展打包成功" width="300" height="191" class="size-medium wp-image-845" /></a><p class="wp-caption-text">chrome扩展打包成功提示</p></div>
<h3>命令行打包chrome应用</h3>
<p>chrome应用打包还支持命令行，只需要运行cmd，然后输入命令行参数即可完成打包过程。<br />
&#8211;pack-extension指定扩展所在的文件夹，<br />
&#8211;pack-extension-key指定私钥所在的文件位置，<br />
如果你不想看到对话框，请使用 &#8211;no-message-box。<br />
命令行打包示例：</p>

<div class="wp_syntax"><div class="code"><pre class="shell" style="font-family:monospace;">chrome.exe --pack-extension=c:\\myext --pack-extension-key=c:\\myext.pem</pre></div></div>

<p>到此一个chrome扩展就开发完成了。希望《chrome扩展应用开发教程》对你的chrome开发有帮助。</p>
<blockquote><ol>
<li>《<a href="http://js8.in/818.html" target="_blank" title="chrome扩展应用开发教程之开发chrome应用基础">开发chrome应用基础</a>》</li>
<li>《<a href="http://js8.in/834.html" target="_blank" title="chrome扩展应用开发教程之天气预报应用开发">天气预报应用开发</a>》</li>
<li>《<a href="http://js8.in/841.html" target="_blank" title="chrome扩展应用开发教程之调试和打包上线">调试和打包上线</a>》</li>
</ol>
</blockquote>
<div class="copyright">
<strong>声明：</strong>文章未声明为原创文章，本文链接 <a href="http://js8.in/841.html" title="chrome扩展应用开发教程之调试和打包上线">http://js8.in/841.html</a>. 转载请注明转自<a href="http://js8.in" title="前端开发博客"> JS8.IN ™</a></span></span></div>
<h3 class="box-title">随机文章</h3>
<ul class="box_random">
<li><a href="http://js8.in/564.html" title="Google Map API教程之使用GControl对象在地图上添加control按钮" rel="bookmark inlinks">Google Map API教程之使用GControl对象在地图上添加control按钮</a></li>
<li><a href="http://js8.in/438.html" title="由一篇文章的收录说说百度和谷歌" rel="bookmark inlinks">由一篇文章的收录说说百度和谷歌</a></li>
<li><a href="http://js8.in/502.html" title="jQuery插件--wBox发布" rel="bookmark inlinks">jQuery插件&#8211;wBox发布</a></li>
<li><a href="http://js8.in/646.html" title="分享一个php验证码类，支持中文字母数字，还可自定义字体" rel="bookmark inlinks">分享一个php验证码类，支持中文字母数字，还可自定义字体</a></li>
<li><a href="http://js8.in/585.html" title="jQuery弹出框wBox的一个使用实例" rel="bookmark inlinks">jQuery弹出框wBox的一个使用实例</a></li>
<li><a href="http://js8.in/352.html" title="wordpress Follow5插件发布" rel="bookmark inlinks">wordpress Follow5插件发布</a></li>
<li><a href="http://js8.in/605.html" title="javascript简单实现checkbox的全选与反选" rel="bookmark inlinks">javascript简单实现checkbox的全选与反选</a></li>
<li><a href="http://js8.in/507.html" title="25大实用的jQuery技巧和解决方案" rel="bookmark inlinks">25大实用的jQuery技巧和解决方案</a></li>
</ul>
<hr />
<p><small>© 三水清 for <a href="http://js8.in">三水清</a>, 2011. |
<a href="http://js8.in/841.html#comments">3 comments</a> |在微博关注我：<a href="//weibo.com/sanshuiqing" target="_blank" title="关注断桥残雪的新浪微博">@清-三水清</a>
<br/>收藏到：
<a rel="nofollow" href="http://share.renren.com/share/buttonshare.do?link=%posturl%&title=%posttitle%" title="收藏本文到人人网" target="_blank">人人网</a> | <a rel="nofollow" href="http://www.douban.com/recommend/?url=%posturl%&title=%posttitle%" title="收藏本文到豆瓣" target="_blank">豆瓣</a> | <a rel="nofollow" href="http://www.kaixin001.com/repaste/share.php?rtitle=%posttitle%&rurl=%posturl%" title="收藏本文到开心网" target="_blank">开心网</a> | <a rel="nofollow" href="http://shuqian.qq.com/post?title=%posttitle%&%20uri=%posturl%" title="收藏本文到QQ书签" target="_blank">QQ书签</a> | <a rel="nofollow" href="http://v.t.sina.com.cn/share/share.php?url=%posturl%&title=%posttitle%" title="收藏本文到新浪微博" target="_blank">新浪微博</a> | <a rel="nofollow" href="http://v.t.qq.com/share/share.php?title=%posttitle%&url=%posturl%&site=http://www.kaixin100.info" title="收藏本文到腾讯微博" target="_blank">腾讯微博</a>
<br/>
Post tags: <a href="http://js8.in/tag/app" rel="tag">APP</a>, <a href="http://js8.in/tag/chrome" rel="tag">chrome</a>, <a href="http://js8.in/tag/%e6%8f%92%e4%bb%b6%e5%bc%80%e5%8f%91" rel="tag">插件开发</a><br/>
</small></p><table class="wumii-related-items" cellspacing="0" cellpadding="3" border="0"  style="clear: both;">
    
    <tr>
        <td colspan="4"><b><font size="-1"  style="display: block !important; padding: 20px 0 5px !important;">猜你喜欢：</font></b></td>
    </tr>
    
        <tr>
                <td width="102" valign="top" style="padding: 5px !important; margin: 0 !important;">
                    <a target="_blank" title="chrome扩展应用开发教程之天气预报应用开发" style="text-decoration: none !important; cursor: pointer !important;" href="http://app.wumii.com/ext/redirect?url=http%3A%2F%2Fjs8.in%2F834.html&from=http%3A%2F%2Fjs8.in%2F841.html">
                        <img style="margin: 0 !important; padding: 2px !important; border: 1px solid #DDDDDD !important; width: 96px !important; height: 96px !important;" src="http://static.wumii.com/site_images/2011/11/17/10982169.png" width="96px" height="96px" /><br />
                        <font size="-1" color="#333333" style="display: block !important; line-height: 15px !important; width: 102px !important; font: 12px/15px arial !important; height: 60px !important; margin: 3px 0 0 0 !important; padding: 0 !important; overflow: hidden !important;">chrome扩展应用开发教程之天气预报应用开发</font>
                    </a>
                </td>
                <td width="102" valign="top" style="padding: 5px !important; margin: 0 !important; border-left: 1px solid #DDDDDD !important;">
                    <a target="_blank" title="chrome扩展应用开发教程之开发chrome应用基础" style="text-decoration: none !important; cursor: pointer !important;" href="http://app.wumii.com/ext/redirect?url=http%3A%2F%2Fjs8.in%2F818.html&from=http%3A%2F%2Fjs8.in%2F841.html">
                        <img style="margin: 0 !important; padding: 2px !important; border: 1px solid #DDDDDD !important; width: 96px !important; height: 96px !important;" src="http://static.wumii.com/site_images/2011/11/17/10976944.png" width="96px" height="96px" /><br />
                        <font size="-1" color="#333333" style="display: block !important; line-height: 15px !important; width: 102px !important; font: 12px/15px arial !important; height: 60px !important; margin: 3px 0 0 0 !important; padding: 0 !important; overflow: hidden !important;">chrome扩展应用开发教程之开发chrome应用基础</font>
                    </a>
                </td>
                <td width="102" valign="top" style="padding: 5px !important; margin: 0 !important; border-left: 1px solid #DDDDDD !important;">
                    <a target="_blank" title="css解决chrome 12px字号限制" style="text-decoration: none !important; cursor: pointer !important;" href="http://app.wumii.com/ext/redirect?url=http%3A%2F%2Fjs8.in%2F625.html&from=http%3A%2F%2Fjs8.in%2F841.html">
                        <img style="margin: 0 !important; padding: 2px !important; border: 1px solid #DDDDDD !important; width: 96px !important; height: 96px !important;" src="http://static.wumii.com/site_images/2011/11/17/10979712.jpg" width="96px" height="96px" /><br />
                        <font size="-1" color="#333333" style="display: block !important; line-height: 15px !important; width: 102px !important; font: 12px/15px arial !important; height: 60px !important; margin: 3px 0 0 0 !important; padding: 0 !important; overflow: hidden !important;">css解决chrome 12px字号限制</font>
                    </a>
                </td>
                <td width="102" valign="top" style="padding: 5px !important; margin: 0 !important; border-left: 1px solid #DDDDDD !important;">
                    <a target="_blank" title="发现Chrome下提交表单的一个bug" style="text-decoration: none !important; cursor: pointer !important;" href="http://app.wumii.com/ext/redirect?url=http%3A%2F%2Fjs8.in%2F356.html&from=http%3A%2F%2Fjs8.in%2F841.html">
                        <img style="margin: 0 !important; padding: 2px !important; border: 1px solid #DDDDDD !important; width: 96px !important; height: 96px !important;" src="http://static.wumii.com/site_images/2011/11/17/10984473.gif" width="96px" height="96px" /><br />
                        <font size="-1" color="#333333" style="display: block !important; line-height: 15px !important; width: 102px !important; font: 12px/15px arial !important; height: 60px !important; margin: 3px 0 0 0 !important; padding: 0 !important; overflow: hidden !important;">发现Chrome下提交表单的一个bug</font>
                    </a>
                </td>
        </tr>
    
    <tr>
        <td colspan="4" align="right">
            <a style="text-decoration: none !important;" href="http://www.wumii.com/widget/relatedItems" target="_blank" title="无觅相关文章插件">
                <font size="-1" color="#bbbbbb" style="display: block !important; font-family: arial !important; padding: 5px 0 !important; font-size: 12px !important; color: #bbb !important;">无觅</font>
            </a>
        </td>
    </tr>
</table>]]></content:encoded>
			<wfw:commentRss>http://js8.in/841.html/feed</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>chrome扩展应用开发教程之天气预报应用开发</title>
		<link>http://js8.in/834.html</link>
		<comments>http://js8.in/834.html#comments</comments>
		<pubDate>Sun, 23 Oct 2011 04:14:24 +0000</pubDate>
		<dc:creator>三水清</dc:creator>
				<category><![CDATA[web前端开发]]></category>
		<category><![CDATA[APP]]></category>
		<category><![CDATA[chrome]]></category>
		<category><![CDATA[插件开发]]></category>

		<guid isPermaLink="false">http://www.js8.in/?p=834</guid>
		<description><![CDATA[上一篇讲到了chrome应用开发的基础知识，这一篇通过周末天气预报插件的开发来讲解下chrome扩展应用的开发过程。熟悉前端开发的童靴，知道了chrome应用开发的基本配置，应该很快就可以开发一个chrome应用，因为chrome插件就是纯粹的javascript和html！
chrome扩展应用开发教程系列：《开发chrome应用基础》《天气预报应用开发》《调试和打包上线》
开发前的准备
在开发之前需要统筹下，chrome天气预报插件的基本功能和界面，本插件，会这chrome顶部添加一个带有当前天气icon的应用，点击应用打开弹窗页面，天气的数据来自weather.com.cn的接口，所以我们需要跨域授权应用可以请求weather.com.cn的数据。于是chrome天气预报插件的manifest.json部分代码就出来了：

&#123; 
  &#34;name&#34;: &#34;Chrome Weather&#34;, //name
  &#34;version&#34;: &#34;0.1.0&#34;, //version
  &#34;description&#34;: &#34;weather.&#34;, //description
  &#34;background_page&#34;: &#34;background.html&#34;,//背景页面，应用请求数据，处理icon显示实时气温
  &#34;browser_action&#34;: &#123; 
    &#34;default_icon&#34;: &#34;icon.png&#34; ,//默认的icon
    &#34;default_title&#34;: &#34;Weather&#34;,//默认鼠标overtitle
    &#34;default_popup&#34;: &#34;popup.html&#34;//弹窗页面
  &#125;,
	&#34;permissions&#34;: &#91; &#34;tabs&#34;, &#34;http://*.weather.com.cn/&#34; &#93;//跨域请求授权
&#125;

先来个最终效果截图：
通过背景页面来请求天气数据
chrome天气插件用到了weather.com.cn的三个接口：

根据ip获取当前用户所在城市天气编号：http://61.4.185.48:81/g/
根据城市天气编号获取五天内天气：http://m.weather.com.cn/data/&#8217;+id+&#8217;.html
根据城市天气编号获取实时天气：http://www.weather.com.cn/data/sk/&#8217;+id+&#8217;.html

chrome天气插件使用了jQuery开发，所以我们需要在html的头部添加jquery库：

&#60;script type=&#34;text/javascript&#34; src=&#34;js/jquery.min.js&#34;&#62;&#60;/script&#62;

根据ip获取当前用户所在城市
当用户第一次运行chrome时候，需要请求背景页面，即background.html，这时，我们需要请求接口来获取当前用户所在的城市信息，以根据cityid获取天气情况。代码如下：

$.getScript&#40;'http://61.4.185.48:81/g/',function&#40;&#41;&#123;
	window.localStorage.cityid = id;//保存cityid到localStorage
	getWeather&#40;id&#41;;//获取天气信息
&#125;&#41;;

根据cityid获取天气信息
上一步，涉及到了一个函数getWeather，这个函数的作用就是做一个xmlHttpRequest请求，获取当前cityid的天气信息，包括实时天气。getWeather中运用了send函数来做xmlHttpRequest请求。

function getWeather&#40;id&#41;&#123;
	var url = 'http://m.weather.com.cn/data/'+id+'.html';
	var url2 = 'http://www.weather.com.cn/data/sk/'+id+'.html';
	send&#40;url,function&#40;json&#41;&#123;
		json0 [...]<table class="wumii-related-items" cellspacing="0" cellpadding="3" border="0"  style="clear: both;">
    
    <tr>
        <td colspan="4"><b><font size="-1"  style="display: block !important; padding: 20px 0 5px !important;">猜你喜欢：</font></b></td>
    </tr>
    
        <tr>
                <td width="102" valign="top" style="padding: 5px !important; margin: 0 !important;">
                    <a target="_blank" title="chrome扩展应用开发教程之开发chrome应用基础" style="text-decoration: none !important; cursor: pointer !important;" href="http://app.wumii.com/ext/redirect?url=http%3A%2F%2Fjs8.in%2F818.html&from=http%3A%2F%2Fjs8.in%2F834.html">
                        <img style="margin: 0 !important; padding: 2px !important; border: 1px solid #DDDDDD !important; width: 96px !important; height: 96px !important;" src="http://static.wumii.com/site_images/2011/11/17/10976944.png" width="96px" height="96px" /><br />
                        <font size="-1" color="#333333" style="display: block !important; line-height: 15px !important; width: 102px !important; font: 12px/15px arial !important; height: 60px !important; margin: 3px 0 0 0 !important; padding: 0 !important; overflow: hidden !important;">chrome扩展应用开发教程之开发chrome应用基础</font>
                    </a>
                </td>
                <td width="102" valign="top" style="padding: 5px !important; margin: 0 !important; border-left: 1px solid #DDDDDD !important;">
                    <a target="_blank" title="chrome扩展应用开发教程之调试和打包上线" style="text-decoration: none !important; cursor: pointer !important;" href="http://app.wumii.com/ext/redirect?url=http%3A%2F%2Fjs8.in%2F841.html&from=http%3A%2F%2Fjs8.in%2F834.html">
                        <img style="margin: 0 !important; padding: 2px !important; border: 1px solid #DDDDDD !important; width: 96px !important; height: 96px !important;" src="http://static.wumii.com/site_images/2011/11/17/10977346.png" width="96px" height="96px" /><br />
                        <font size="-1" color="#333333" style="display: block !important; line-height: 15px !important; width: 102px !important; font: 12px/15px arial !important; height: 60px !important; margin: 3px 0 0 0 !important; padding: 0 !important; overflow: hidden !important;">chrome扩展应用开发教程之调试和打包上线</font>
                    </a>
                </td>
                <td width="102" valign="top" style="padding: 5px !important; margin: 0 !important; border-left: 1px solid #DDDDDD !important;">
                    <a target="_blank" title="发布WordPress来访者天气预报插件" style="text-decoration: none !important; cursor: pointer !important;" href="http://app.wumii.com/ext/redirect?url=http%3A%2F%2Fjs8.in%2F374.html&from=http%3A%2F%2Fjs8.in%2F834.html">
                        <img style="margin: 0 !important; padding: 2px !important; border: 1px solid #DDDDDD !important; width: 96px !important; height: 96px !important;" src="http://static.wumii.com/site_images/2011/11/17/10977484.jpg" width="96px" height="96px" /><br />
                        <font size="-1" color="#333333" style="display: block !important; line-height: 15px !important; width: 102px !important; font: 12px/15px arial !important; height: 60px !important; margin: 3px 0 0 0 !important; padding: 0 !important; overflow: hidden !important;">发布WordPress来访者天气预报插件</font>
                    </a>
                </td>
                <td width="102" valign="top" style="padding: 5px !important; margin: 0 !important; border-left: 1px solid #DDDDDD !important;">
                    <a target="_blank" title="六个精美的WordPress圣诞插件" style="text-decoration: none !important; cursor: pointer !important;" href="http://app.wumii.com/ext/redirect?url=http%3A%2F%2Fjs8.in%2F385.html&from=http%3A%2F%2Fjs8.in%2F834.html">
                        <img style="margin: 0 !important; padding: 2px !important; border: 1px solid #DDDDDD !important; width: 96px !important; height: 96px !important;" src="http://static.wumii.com/site_images/2011/11/18/11027118.png" width="96px" height="96px" /><br />
                        <font size="-1" color="#333333" style="display: block !important; line-height: 15px !important; width: 102px !important; font: 12px/15px arial !important; height: 60px !important; margin: 3px 0 0 0 !important; padding: 0 !important; overflow: hidden !important;">六个精美的WordPress圣诞插件</font>
                    </a>
                </td>
        </tr>
    
    <tr>
        <td colspan="4" align="right">
            <a style="text-decoration: none !important;" href="http://www.wumii.com/widget/relatedItems" target="_blank" title="无觅相关文章插件">
                <font size="-1" color="#bbbbbb" style="display: block !important; font-family: arial !important; padding: 5px 0 !important; font-size: 12px !important; color: #bbb !important;">无觅</font>
            </a>
        </td>
    </tr>
</table>]]></description>
			<content:encoded><![CDATA[<p>上一篇讲到了<strong>chrome应用开发</strong>的基础知识，这一篇通过周末天气预报插件的开发来讲解下chrome扩展应用的开发过程。熟悉前端开发的童靴，知道了chrome应用开发的基本配置，应该很快就可以开发一个chrome应用，因为chrome插件就是纯粹的javascript和html！</p>
<p>chrome扩展应用开发教程系列：《<a href="http://js8.in/818.html" target="_blank" title="chrome扩展应用开发教程之开发chrome应用基础">开发chrome应用基础</a>》《<a href="http://js8.in/834.html" target="_blank" title="chrome扩展应用开发教程之天气预报应用开发">天气预报应用开发</a>》《<a href="http://js8.in/841.html" target="_blank" title="chrome扩展应用开发教程之调试和打包上线">调试和打包上线</a>》</p>
<h2>开发前的准备</h2>
<p>在开发之前需要统筹下，chrome天气预报插件的基本功能和界面，本插件，会这chrome顶部添加一个带有当前天气icon的应用，点击应用打开弹窗页面，天气的数据来自weather.com.cn的接口，所以我们需要跨域授权应用可以请求weather.com.cn的数据。于是chrome天气预报插件的manifest.json部分代码就出来了：</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #009900;">&#123;</span> 
  <span style="color: #3366CC;">&quot;name&quot;</span><span style="color: #339933;">:</span> <span style="color: #3366CC;">&quot;Chrome Weather&quot;</span><span style="color: #339933;">,</span> <span style="color: #006600; font-style: italic;">//name</span>
  <span style="color: #3366CC;">&quot;version&quot;</span><span style="color: #339933;">:</span> <span style="color: #3366CC;">&quot;0.1.0&quot;</span><span style="color: #339933;">,</span> <span style="color: #006600; font-style: italic;">//version</span>
  <span style="color: #3366CC;">&quot;description&quot;</span><span style="color: #339933;">:</span> <span style="color: #3366CC;">&quot;weather.&quot;</span><span style="color: #339933;">,</span> <span style="color: #006600; font-style: italic;">//description</span>
  <span style="color: #3366CC;">&quot;background_page&quot;</span><span style="color: #339933;">:</span> <span style="color: #3366CC;">&quot;background.html&quot;</span><span style="color: #339933;">,</span><span style="color: #006600; font-style: italic;">//背景页面，应用请求数据，处理icon显示实时气温</span>
  <span style="color: #3366CC;">&quot;browser_action&quot;</span><span style="color: #339933;">:</span> <span style="color: #009900;">&#123;</span> 
    <span style="color: #3366CC;">&quot;default_icon&quot;</span><span style="color: #339933;">:</span> <span style="color: #3366CC;">&quot;icon.png&quot;</span> <span style="color: #339933;">,</span><span style="color: #006600; font-style: italic;">//默认的icon</span>
    <span style="color: #3366CC;">&quot;default_title&quot;</span><span style="color: #339933;">:</span> <span style="color: #3366CC;">&quot;Weather&quot;</span><span style="color: #339933;">,</span><span style="color: #006600; font-style: italic;">//默认鼠标overtitle</span>
    <span style="color: #3366CC;">&quot;default_popup&quot;</span><span style="color: #339933;">:</span> <span style="color: #3366CC;">&quot;popup.html&quot;</span><span style="color: #006600; font-style: italic;">//弹窗页面</span>
  <span style="color: #009900;">&#125;</span><span style="color: #339933;">,</span>
	<span style="color: #3366CC;">&quot;permissions&quot;</span><span style="color: #339933;">:</span> <span style="color: #009900;">&#91;</span> <span style="color: #3366CC;">&quot;tabs&quot;</span><span style="color: #339933;">,</span> <span style="color: #3366CC;">&quot;http://*.weather.com.cn/&quot;</span> <span style="color: #009900;">&#93;</span><span style="color: #006600; font-style: italic;">//跨域请求授权</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<p>先来个最终效果截图：<br />
<div id="attachment_838" class="wp-caption aligncenter" style="width: 310px"><a href="http://js8.in/834.html/2011-10-22_124856" rel="attachment wp-att-838"><img src="http://js8.in/wp-content/uploads/2011/10/2011-10-22_124856-300x80.png" alt="chrome天气预报应用最终效果截图" title="chrome天气预报应用最终效果截图" width="300" height="80" class="size-medium wp-image-838" /></a><p class="wp-caption-text">chrome天气预报应用最终效果截图</p></div></p>
<h2>通过背景页面来请求天气数据</h2>
<p>chrome天气插件用到了weather.com.cn的三个接口：</p>
<ol>
<li>根据ip获取当前用户所在城市天气编号：http://61.4.185.48:81/g/</li>
<li>根据城市天气编号获取五天内天气：http://m.weather.com.cn/data/&#8217;+id+&#8217;.html</li>
<li>根据城市天气编号获取实时天气：http://www.weather.com.cn/data/sk/&#8217;+id+&#8217;.html</li>
</ol>
<p>chrome天气插件使用了jQuery开发，所以我们需要在html的头部添加jquery库：</p>

<div class="wp_syntax"><div class="code"><pre class="html" style="font-family:monospace;">&lt;script type=&quot;text/javascript&quot; src=&quot;js/jquery.min.js&quot;&gt;&lt;/script&gt;</pre></div></div>

<h3>根据ip获取当前用户所在城市</h3>
<p>当用户第一次运行chrome时候，需要请求背景页面，即background.html，这时，我们需要请求接口来获取当前用户所在的城市信息，以根据cityid获取天气情况。代码如下：</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;">$.<span style="color: #660066;">getScript</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'http://61.4.185.48:81/g/'</span><span style="color: #339933;">,</span><span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
	window.<span style="color: #660066;">localStorage</span>.<span style="color: #660066;">cityid</span> <span style="color: #339933;">=</span> id<span style="color: #339933;">;</span><span style="color: #006600; font-style: italic;">//保存cityid到localStorage</span>
	getWeather<span style="color: #009900;">&#40;</span>id<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><span style="color: #006600; font-style: italic;">//获取天气信息</span>
<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<h3>根据cityid获取天气信息</h3>
<p>上一步，涉及到了一个函数getWeather，这个函数的作用就是做一个xmlHttpRequest请求，获取当前cityid的天气信息，包括实时天气。getWeather中运用了send函数来做xmlHttpRequest请求。</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #003366; font-weight: bold;">function</span> getWeather<span style="color: #009900;">&#40;</span>id<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
	<span style="color: #003366; font-weight: bold;">var</span> url <span style="color: #339933;">=</span> <span style="color: #3366CC;">'http://m.weather.com.cn/data/'</span><span style="color: #339933;">+</span>id<span style="color: #339933;">+</span><span style="color: #3366CC;">'.html'</span><span style="color: #339933;">;</span>
	<span style="color: #003366; font-weight: bold;">var</span> url2 <span style="color: #339933;">=</span> <span style="color: #3366CC;">'http://www.weather.com.cn/data/sk/'</span><span style="color: #339933;">+</span>id<span style="color: #339933;">+</span><span style="color: #3366CC;">'.html'</span><span style="color: #339933;">;</span>
	send<span style="color: #009900;">&#40;</span>url<span style="color: #339933;">,</span><span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span>json<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
		json0 <span style="color: #339933;">=</span> json<span style="color: #339933;">;</span>
		window.<span style="color: #660066;">localStorage</span>.<span style="color: #660066;">json0</span> <span style="color: #339933;">=</span> JSON.<span style="color: #660066;">stringify</span><span style="color: #009900;">&#40;</span>json<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		doit<span style="color: #339933;">++;</span>
		deal<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><span style="color: #006600; font-style: italic;">//处理json0</span>
	<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">call</span><span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">this</span><span style="color: #339933;">,</span>url2<span style="color: #339933;">,</span><span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span>json<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
		json1 <span style="color: #339933;">=</span> json<span style="color: #339933;">;</span>
		window.<span style="color: #660066;">localStorage</span>.<span style="color: #660066;">json1</span> <span style="color: #339933;">=</span> JSON.<span style="color: #660066;">stringify</span><span style="color: #009900;">&#40;</span>json<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		doit<span style="color: #339933;">++;</span>
		deal<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><span style="color: #006600; font-style: italic;">//处理json1</span>
	<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #009900;">&#125;</span>
<span style="color: #003366; font-weight: bold;">function</span> send<span style="color: #009900;">&#40;</span>url<span style="color: #339933;">,</span>cb<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
	<span style="color: #003366; font-weight: bold;">var</span> xhr <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">new</span> XMLHttpRequest<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	xhr.<span style="color: #000066;">open</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;GET&quot;</span><span style="color: #339933;">,</span> url<span style="color: #339933;">,</span> <span style="color: #003366; font-weight: bold;">true</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	xhr.<span style="color: #660066;">onreadystatechange</span> <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
	  <span style="color: #000066; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>xhr.<span style="color: #660066;">readyState</span> <span style="color: #339933;">==</span> <span style="color: #CC0000;">4</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
		<span style="color: #003366; font-weight: bold;">var</span> json <span style="color: #339933;">=</span> JSON.<span style="color: #660066;">parse</span><span style="color: #009900;">&#40;</span>xhr.<span style="color: #660066;">responseText</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><span style="color: #006600; font-style: italic;">//解析json，保证安全性</span>
		<span style="color: #000066; font-weight: bold;">typeof</span> cb<span style="color: #339933;">===</span><span style="color: #3366CC;">'function'</span> <span style="color: #339933;">&amp;&amp;</span> json.<span style="color: #660066;">weatherinfo</span> <span style="color: #339933;">&amp;&amp;</span> cb<span style="color: #009900;">&#40;</span>json.<span style="color: #660066;">weatherinfo</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		xhr <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">null</span><span style="color: #339933;">;</span>
	  <span style="color: #009900;">&#125;</span>
	<span style="color: #009900;">&#125;</span>
	xhr.<span style="color: #660066;">send</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #000066; font-weight: bold;">return</span> arguments.<span style="color: #660066;">callee</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<p><span id="more-834"></span></p>
<h3>天气信息的处理</h3>
<p>deal函数是处理天气信息，主要代码如下：</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #003366; font-weight: bold;">function</span> deal<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
	<span style="color: #000066; font-weight: bold;">if</span><span style="color: #009900;">&#40;</span>doit<span style="color: #339933;">===</span><span style="color: #CC0000;">2</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
		doit <span style="color: #339933;">=</span> <span style="color: #CC0000;">0</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span><span style="color: #000066; font-weight: bold;">else</span><span style="color: #009900;">&#123;</span>
		<span style="color: #000066; font-weight: bold;">return</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
	<span style="color: #003366; font-weight: bold;">var</span> img <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">new</span> Image<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	img.<span style="color: #000066;">onload</span> <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
		<span style="color: #003366; font-weight: bold;">var</span> context <span style="color: #339933;">=</span> $<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'#canvas'</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#91;</span><span style="color: #CC0000;">0</span><span style="color: #009900;">&#93;</span>.<span style="color: #660066;">getContext</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'2d'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		context.<span style="color: #660066;">drawImage</span><span style="color: #009900;">&#40;</span>img<span style="color: #339933;">,</span><span style="color: #CC0000;">0</span><span style="color: #339933;">,</span><span style="color: #CC0000;">0</span><span style="color: #339933;">,</span><span style="color: #CC0000;">19</span><span style="color: #339933;">,</span><span style="color: #CC0000;">19</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
                <span style="color: #006600; font-style: italic;">//通过canvas对象改变icon</span>
		chrome.<span style="color: #660066;">browserAction</span>.<span style="color: #660066;">setIcon</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#123;</span>imageData<span style="color: #339933;">:</span>context.<span style="color: #660066;">getImageData</span><span style="color: #009900;">&#40;</span><span style="color: #CC0000;">0</span><span style="color: #339933;">,</span> <span style="color: #CC0000;">0</span><span style="color: #339933;">,</span> <span style="color: #CC0000;">19</span><span style="color: #339933;">,</span><span style="color: #CC0000;">19</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span><span style="color: #339933;">;</span>
	img.<span style="color: #660066;">src</span> <span style="color: #339933;">=</span> <span style="color: #3366CC;">&quot;http://m.weather.com.cn/weather_img/&quot;</span><span style="color: #339933;">+</span>json0.<span style="color: #660066;">img1</span><span style="color: #339933;">+</span><span style="color: #3366CC;">&quot;.gif&quot;</span><span style="color: #339933;">;</span>
	<span style="color: #003366; font-weight: bold;">var</span> strTip <span style="color: #339933;">=</span> json1.<span style="color: #660066;">city</span><span style="color: #339933;">+</span><span style="color: #3366CC;">'现在温度:'</span><span style="color: #339933;">+</span>json1.<span style="color: #660066;">temp</span><span style="color: #339933;">+</span><span style="color: #3366CC;">'℃<span style="color: #000099; font-weight: bold;">\n</span>今天：'</span><span style="color: #339933;">+</span>
                         json0.<span style="color: #660066;">weather1</span><span style="color: #339933;">+</span>json0.<span style="color: #660066;">temp1</span><span style="color: #339933;">+</span><span style="color: #3366CC;">'<span style="color: #000099; font-weight: bold;">\n</span>明天：'</span><span style="color: #339933;">+</span>
                         json0.<span style="color: #660066;">weather2</span><span style="color: #339933;">+</span>json0.<span style="color: #660066;">temp2</span><span style="color: #339933;">+</span><span style="color: #3366CC;">'<span style="color: #000099; font-weight: bold;">\n</span>后天：'</span><span style="color: #339933;">+</span>
                         json0.<span style="color: #660066;">weather3</span><span style="color: #339933;">+</span>json0.<span style="color: #660066;">temp3</span><span style="color: #339933;">;</span>
	strTip <span style="color: #339933;">+=</span> <span style="color: #3366CC;">&quot;<span style="color: #000099; font-weight: bold;">\n</span>最后更新时间：&quot;</span><span style="color: #339933;">+</span><span style="color: #003366; font-weight: bold;">new</span> Date<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">toLocaleTimeString</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	chrome.<span style="color: #660066;">browserAction</span>.<span style="color: #660066;">setTitle</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#123;</span>title<span style="color: #339933;">:</span>strTip<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><span style="color: #006600; font-style: italic;">//设置鼠标经过title</span>
        <span style="color: #006600; font-style: italic;">//背景颜色</span>
	chrome.<span style="color: #660066;">browserAction</span>.<span style="color: #660066;">setBadgeBackgroundColor</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#123;</span>color<span style="color: #339933;">:</span><span style="color: #009900;">&#91;</span><span style="color: #CC0000;">0</span><span style="color: #339933;">,</span> <span style="color: #CC0000;">97</span><span style="color: #339933;">,</span> <span style="color: #CC0000;">255</span><span style="color: #339933;">,</span><span style="color: #CC0000;">100</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #006600; font-style: italic;">//将实时气温显示在icon上面</span>
	chrome.<span style="color: #660066;">browserAction</span>.<span style="color: #660066;">setBadgeText</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#123;</span>text<span style="color: #339933;">:</span>json1.<span style="color: #660066;">temp</span>.<span style="color: #660066;">toString</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<h3>background.html的全部代码</h3>

<div class="wp_syntax"><div class="code"><pre class="html" style="font-family:monospace;">&lt;!DOCTYPE HTML&gt;
&lt;html&gt;
&lt;head&gt;
	&lt;meta charset=&quot;UTF-8&quot;&gt;
	&lt;title&gt;weather&lt;/title&gt;
	&lt;link rel=&quot;stylesheet&quot; href=&quot;css/style.css&quot; /&gt;
	&lt;script type=&quot;text/javascript&quot; src=&quot;js/jquery.min.js&quot;&gt;&lt;/script&gt;
&lt;/head&gt;
&lt;body&gt;
&lt;canvas id=&quot;canvas&quot; &gt;&lt;/canvas&gt;
&lt;script type=&quot;text/javascript&quot;&gt;
!function(win,doc,$){
	var json0,json1,doit = 0;
	function getWeather(id){
		var url = 'http://m.weather.com.cn/data/'+id+'.html';
		var url2 = 'http://www.weather.com.cn/data/sk/'+id+'.html';
		send(url,function(json){
			json0 = json;
			win.localStorage.json0 = JSON.stringify(json);
			doit++;
			deal();
		}).call(this,url2,function(json){
			json1 = json;
			win.localStorage.json1 = JSON.stringify(json);
			doit++;
			deal();
		});
&nbsp;
	}
	function send(url,cb){
		var xhr = new XMLHttpRequest();
		xhr.open(&quot;GET&quot;, url, true);
		xhr.onreadystatechange = function() {
		  if (xhr.readyState == 4) {
			var json = JSON.parse(xhr.responseText);
			typeof cb==='function' &amp;&amp; json.weatherinfo &amp;&amp; cb(json.weatherinfo);
			xhr = null;
		  }
		}
		xhr.send();
		return arguments.callee;
	}
	function deal(){
		if(doit===2){
			doit = 0;
		}else{
			return;
		}
		var img = new Image();
		img.onload = function(){
			var context = $('#canvas')[0].getContext('2d');
			context.drawImage(img,0,0,19,19);
			chrome.browserAction.setIcon({imageData:context.getImageData(0, 0, 19,19)});
		};
		img.src = &quot;http://m.weather.com.cn/weather_img/&quot;+json0.img1+&quot;.gif&quot;;
		var strTip = json1.city+'现在温度:'+json1.temp+'℃\n今天：'+
			json0.weather1+json0.temp1+'\n明天：'+json0.weather2+json0.temp2+
			'\n后天：'+json0.weather3+json0.temp3;
		strTip += &quot;\n最后更新时间：&quot;+new Date().toLocaleTimeString();
		chrome.browserAction.setTitle({title:strTip});
		chrome.browserAction.setBadgeBackgroundColor({color:[0, 97, 255,100]});
		chrome.browserAction.setBadgeText({text:json1.temp.toString()});
	}
	var init = function(){
		chrome.browserAction.setBadgeText({text:'...'});
		if(win.localStorage.cityid){
			getWeather(win.localStorage.cityid);
			return;
		}
&nbsp;
		$.getScript('http://61.4.185.48:81/g/',function(){
			win.localStorage.cityid = id;
			getWeather(id);
		});
	};
	$(doc).ready(init);//页面加载完成就开始初始化
&nbsp;
	win.setInterval(init,30*60*1000);//每间隔三十分钟，请求一下最新的天气数据
&nbsp;
}(window,document,jQuery);
&lt;/script&gt;
&lt;/body&gt;
&lt;/html&gt;</pre></div></div>

<h2>弹窗页面代码</h2>
<p>弹窗页面是当用户点击icon后显示的内容，本实例应用中，点击icon当然是显示完整的天气信息了。数据就不需要再次请求了，在background.html中已经把每次请求下来的数据存入localStorage中，所以可以直接从localStorage中调用完整的天气数据，注意localStorage保存的是string，需要重新解析json哦，不多说了，直接上popup的代码：</p>

<div class="wp_syntax"><div class="code"><pre class="html" style="font-family:monospace;">&lt;!DOCTYPE HTML&gt;
&lt;html&gt;
&lt;head&gt;
	&lt;meta charset=&quot;UTF-8&quot;&gt;
	&lt;title&gt;weather&lt;/title&gt;
&lt;/head&gt;
&lt;body&gt;
&lt;table width='780px'&gt;
 &lt;tr&gt; 
    &lt;th rowspan='2' style=&quot;width:130px;text-align:center;&quot;&gt;&lt;h1 id=&quot;city&quot;&gt;&lt;/h1&gt;&lt;/th&gt; 
    &lt;th id=&quot;day1&quot; width=&quot;130px&quot;&gt;&lt;strong&gt;今&amp;nbsp;&amp;nbsp;天&lt;/strong&gt;&lt;/th&gt;
    &lt;th id=&quot;day2&quot; width=&quot;130px&quot;&gt;&lt;strong&gt;明&amp;nbsp;&amp;nbsp;天&lt;/strong&gt;&lt;/th&gt;
    &lt;th id=&quot;day3&quot; width=&quot;130px&quot;&gt;&lt;strong&gt;后&amp;nbsp;&amp;nbsp;天&lt;/strong&gt;&lt;/th&gt;
    &lt;th id=&quot;day4&quot; width=&quot;130px&quot;&gt;&lt;strong&gt;第四天&lt;/strong&gt;&lt;/th&gt;
    &lt;th id=&quot;day5&quot; width=&quot;130px&quot;&gt;&lt;strong&gt;第五天&lt;/strong&gt;&lt;/th&gt;
  &lt;/tr&gt;
  &lt;tr&gt;
    &lt;td style=&quot;text-align:center;&quot;&gt;&lt;img id=&quot;img1&quot; src=&quot;#&quot; alt=&quot;&quot; width=&quot;50&quot; height=&quot;50&quot; /&gt;&lt;/td&gt;
    &lt;td style=&quot;text-align:center;&quot;&gt;&lt;img id=&quot;img3&quot; src=&quot;#&quot; alt=&quot;&quot; width=&quot;50&quot; height=&quot;50&quot; /&gt;&lt;/td&gt;
    &lt;td style=&quot;text-align:center;&quot;&gt;&lt;img id=&quot;img5&quot; src=&quot;#&quot; alt=&quot;&quot; width=&quot;50&quot; height=&quot;50&quot; /&gt;&lt;/td&gt;
    &lt;td style=&quot;text-align:center;&quot;&gt;&lt;img id=&quot;img7&quot; src=&quot;#&quot; alt=&quot;&quot; width=&quot;50&quot; height=&quot;50&quot; /&gt;&lt;/td&gt;
    &lt;td style=&quot;text-align:center;&quot;&gt;&lt;img id=&quot;img9&quot; src=&quot;#&quot; alt=&quot;&quot; width=&quot;50&quot; height=&quot;50&quot; /&gt;&lt;/td&gt;
  &lt;/tr&gt;
  &lt;tr&gt;
    &lt;td style=&quot;text-align:center;&quot;&gt;&lt;span class=&quot;spanAt&quot;&gt;实时气温:&lt;/span&gt;&lt;span id=&quot;temp&quot;&gt;&lt;/span&gt;℃&lt;/td&gt; 
    &lt;td style=&quot;text-align:center&quot;&gt;&lt;span id=&quot;temp1&quot;&gt;&lt;/span&gt;&lt;/td&gt;
    &lt;td style=&quot;text-align:center&quot;&gt;&lt;span id=&quot;temp2&quot;&gt;&lt;/span&gt;&lt;/td&gt;
    &lt;td style=&quot;text-align:center&quot;&gt;&lt;span id=&quot;temp3&quot;&gt;&lt;/span&gt;&lt;/td&gt;
    &lt;td style=&quot;text-align:center&quot;&gt;&lt;span id=&quot;temp4&quot;&gt;&lt;/span&gt;&lt;/td&gt;
   &lt;td style=&quot;text-align:center&quot;&gt;&lt;span id=&quot;temp5&quot;&gt;&lt;/span&gt;&lt;/td&gt;
  &lt;/tr&gt;
  &lt;tr&gt;
    &lt;td style=&quot;text-align:center;&quot;&gt;&lt;span class=&quot;spanAt&quot;&gt;风向:&lt;/span&gt;&lt;span id=&quot;WD&quot;&gt;&lt;/span&gt;&lt;/td&gt; 
    &lt;td style=&quot;text-align:center&quot;&gt;&lt;span id=&quot;weather1&quot;&gt;&lt;/span&gt;&lt;/td&gt;
    &lt;td style=&quot;text-align:center&quot;&gt;&lt;span id=&quot;weather2&quot;&gt;&lt;/span&gt;&lt;/td&gt;
    &lt;td style=&quot;text-align:center&quot;&gt;&lt;span id=&quot;weather3&quot;&gt;&lt;/span&gt;&lt;/td&gt;
    &lt;td style=&quot;text-align:center&quot;&gt;&lt;span id=&quot;weather4&quot;&gt;&lt;/span&gt;&lt;/td&gt;
    &lt;td style=&quot;text-align:center&quot;&gt;&lt;span id=&quot;weather5&quot;&gt;&lt;/span&gt;&lt;/td&gt;
  &lt;/tr&gt;
  &lt;tr&gt;
    &lt;td style=&quot;text-align:center;&quot;&gt;&lt;span class=&quot;spanAt&quot;&gt;湿度:&lt;/span&gt;&lt;span id=&quot;SD&quot;&gt;&lt;/span&gt;&lt;/td&gt; 
    &lt;td style=&quot;text-align:center&quot;&gt;&lt;div id=&quot;wind1&quot;&gt;&lt;/div&gt;&lt;/td&gt;
    &lt;td style=&quot;text-align:center&quot;&gt;&lt;div id=&quot;wind2&quot;&gt;&lt;/div&gt;&lt;/td&gt;
    &lt;td style=&quot;text-align:center&quot;&gt;&lt;div id=&quot;wind3&quot;&gt;&lt;/div&gt;&lt;/td&gt;
    &lt;td style=&quot;text-align:center&quot;&gt;&lt;div id=&quot;wind4&quot;&gt;&lt;/div&gt;&lt;/td&gt;
    &lt;td style=&quot;text-align:center&quot;&gt;&lt;div id=&quot;wind5&quot;&gt;&lt;/div&gt;&lt;/td&gt;
  &lt;/tr&gt;
&lt;/table&gt;
&lt;script type=&quot;text/javascript&quot;&gt;
	var json1 = JSON.parse(localStorage.json1),json0 = JSON.parse(localStorage.json0);
	['weather','wind','temp'].forEach(function(v){
		var j = 6;
		while(--j){
			document.getElementById(v+j).innerHTML = json0[v+j];
		}
	});
	for(var i=1,step=2;i&lt;10;i+=step){
		document.getElementById('img'+i).src = &quot;http://m.weather.com.cn/weather_img/&quot;+json0['img'+i]+&quot;.gif&quot;
	}
	&quot;city SD temp WD&quot;.replace(/[^ ]+/g,function(a){
		document.getElementById(a).innerHTML = json1[a];
	});
	document.getElementById('cityid').href = json1.cityid;
&lt;/script&gt;
&lt;/body&gt;
&lt;/html&gt;</pre></div></div>

<p>到这里一个简单的chrome天气预报插件就已经完成了，当然还需要完善，比如添加设置页面，用户可以设置自己关心城市，添加手动刷新功能，需要做的事情还是很多的，哈哈~不多说了，主要的代码已经出来了，需要的也可以直接下载我打包好的代码来测试。</p>
<p class="demoview"><a target="_blank" href="//1.qdemo.sinaapp.com/chrome-weather.zip" title="chrome天气预报扩展zip包">chrome天气预报插件扩展zip包</a></p>
<div class="copyright">
<strong>声明：</strong>文章未声明为原创文章，本文链接 <a href="http://js8.in/834.html" title="chrome扩展应用开发教程之天气预报应用开发">http://js8.in/834.html</a>. 转载请注明转自<a href="http://js8.in" title="前端开发博客"> JS8.IN ™</a></span></span></div>
<h3 class="box-title">随机文章</h3>
<ul class="box_random">
<li><a href="http://js8.in/634.html" title="Sina App Engine开发实例：天气预报的定时短信（二）" rel="bookmark inlinks">Sina App Engine开发实例：天气预报的定时短信（二）</a></li>
<li><a href="http://js8.in/469.html" title="jQuery 1.4.1 中文参考文档下载" rel="bookmark inlinks">jQuery 1.4.1 中文参考文档下载</a></li>
<li><a href="http://js8.in/305.html" title="查看自己是否在对方QQ好友中最简单的方法" rel="bookmark inlinks">查看自己是否在对方QQ好友中最简单的方法</a></li>
<li><a href="http://js8.in/46.html" title="如何写网站的robots.txt和meta name robots的配置" rel="bookmark inlinks">如何写网站的robots.txt和meta name robots的配置</a></li>
<li><a href="http://js8.in/467.html" title="Javascript设置光标位置到结尾并显示出来" rel="bookmark inlinks">Javascript设置光标位置到结尾并显示出来</a></li>
<li><a href="http://js8.in/553.html" title="解决IE6 select z-index无效，遮挡div的bug" rel="bookmark inlinks">解决IE6 select z-index无效，遮挡div的bug</a></li>
<li><a href="http://js8.in/47.html" title="十七届三中全会思想汇报~" rel="bookmark inlinks">十七届三中全会思想汇报~</a></li>
<li><a href="http://js8.in/497.html" title="韩峰其实是个好干部" rel="bookmark inlinks">韩峰其实是个好干部</a></li>
</ul>
<hr />
<p><small>© 三水清 for <a href="http://js8.in">三水清</a>, 2011. |
<a href="http://js8.in/834.html#comments">3 comments</a> |在微博关注我：<a href="//weibo.com/sanshuiqing" target="_blank" title="关注断桥残雪的新浪微博">@清-三水清</a>
<br/>收藏到：
<a rel="nofollow" href="http://share.renren.com/share/buttonshare.do?link=%posturl%&title=%posttitle%" title="收藏本文到人人网" target="_blank">人人网</a> | <a rel="nofollow" href="http://www.douban.com/recommend/?url=%posturl%&title=%posttitle%" title="收藏本文到豆瓣" target="_blank">豆瓣</a> | <a rel="nofollow" href="http://www.kaixin001.com/repaste/share.php?rtitle=%posttitle%&rurl=%posturl%" title="收藏本文到开心网" target="_blank">开心网</a> | <a rel="nofollow" href="http://shuqian.qq.com/post?title=%posttitle%&%20uri=%posturl%" title="收藏本文到QQ书签" target="_blank">QQ书签</a> | <a rel="nofollow" href="http://v.t.sina.com.cn/share/share.php?url=%posturl%&title=%posttitle%" title="收藏本文到新浪微博" target="_blank">新浪微博</a> | <a rel="nofollow" href="http://v.t.qq.com/share/share.php?title=%posttitle%&url=%posturl%&site=http://www.kaixin100.info" title="收藏本文到腾讯微博" target="_blank">腾讯微博</a>
<br/>
Post tags: <a href="http://js8.in/tag/app" rel="tag">APP</a>, <a href="http://js8.in/tag/chrome" rel="tag">chrome</a>, <a href="http://js8.in/tag/%e6%8f%92%e4%bb%b6%e5%bc%80%e5%8f%91" rel="tag">插件开发</a><br/>
</small></p><table class="wumii-related-items" cellspacing="0" cellpadding="3" border="0"  style="clear: both;">
    
    <tr>
        <td colspan="4"><b><font size="-1"  style="display: block !important; padding: 20px 0 5px !important;">猜你喜欢：</font></b></td>
    </tr>
    
        <tr>
                <td width="102" valign="top" style="padding: 5px !important; margin: 0 !important;">
                    <a target="_blank" title="chrome扩展应用开发教程之开发chrome应用基础" style="text-decoration: none !important; cursor: pointer !important;" href="http://app.wumii.com/ext/redirect?url=http%3A%2F%2Fjs8.in%2F818.html&from=http%3A%2F%2Fjs8.in%2F834.html">
                        <img style="margin: 0 !important; padding: 2px !important; border: 1px solid #DDDDDD !important; width: 96px !important; height: 96px !important;" src="http://static.wumii.com/site_images/2011/11/17/10976944.png" width="96px" height="96px" /><br />
                        <font size="-1" color="#333333" style="display: block !important; line-height: 15px !important; width: 102px !important; font: 12px/15px arial !important; height: 60px !important; margin: 3px 0 0 0 !important; padding: 0 !important; overflow: hidden !important;">chrome扩展应用开发教程之开发chrome应用基础</font>
                    </a>
                </td>
                <td width="102" valign="top" style="padding: 5px !important; margin: 0 !important; border-left: 1px solid #DDDDDD !important;">
                    <a target="_blank" title="chrome扩展应用开发教程之调试和打包上线" style="text-decoration: none !important; cursor: pointer !important;" href="http://app.wumii.com/ext/redirect?url=http%3A%2F%2Fjs8.in%2F841.html&from=http%3A%2F%2Fjs8.in%2F834.html">
                        <img style="margin: 0 !important; padding: 2px !important; border: 1px solid #DDDDDD !important; width: 96px !important; height: 96px !important;" src="http://static.wumii.com/site_images/2011/11/17/10977346.png" width="96px" height="96px" /><br />
                        <font size="-1" color="#333333" style="display: block !important; line-height: 15px !important; width: 102px !important; font: 12px/15px arial !important; height: 60px !important; margin: 3px 0 0 0 !important; padding: 0 !important; overflow: hidden !important;">chrome扩展应用开发教程之调试和打包上线</font>
                    </a>
                </td>
                <td width="102" valign="top" style="padding: 5px !important; margin: 0 !important; border-left: 1px solid #DDDDDD !important;">
                    <a target="_blank" title="发布WordPress来访者天气预报插件" style="text-decoration: none !important; cursor: pointer !important;" href="http://app.wumii.com/ext/redirect?url=http%3A%2F%2Fjs8.in%2F374.html&from=http%3A%2F%2Fjs8.in%2F834.html">
                        <img style="margin: 0 !important; padding: 2px !important; border: 1px solid #DDDDDD !important; width: 96px !important; height: 96px !important;" src="http://static.wumii.com/site_images/2011/11/17/10977484.jpg" width="96px" height="96px" /><br />
                        <font size="-1" color="#333333" style="display: block !important; line-height: 15px !important; width: 102px !important; font: 12px/15px arial !important; height: 60px !important; margin: 3px 0 0 0 !important; padding: 0 !important; overflow: hidden !important;">发布WordPress来访者天气预报插件</font>
                    </a>
                </td>
                <td width="102" valign="top" style="padding: 5px !important; margin: 0 !important; border-left: 1px solid #DDDDDD !important;">
                    <a target="_blank" title="六个精美的WordPress圣诞插件" style="text-decoration: none !important; cursor: pointer !important;" href="http://app.wumii.com/ext/redirect?url=http%3A%2F%2Fjs8.in%2F385.html&from=http%3A%2F%2Fjs8.in%2F834.html">
                        <img style="margin: 0 !important; padding: 2px !important; border: 1px solid #DDDDDD !important; width: 96px !important; height: 96px !important;" src="http://static.wumii.com/site_images/2011/11/18/11027118.png" width="96px" height="96px" /><br />
                        <font size="-1" color="#333333" style="display: block !important; line-height: 15px !important; width: 102px !important; font: 12px/15px arial !important; height: 60px !important; margin: 3px 0 0 0 !important; padding: 0 !important; overflow: hidden !important;">六个精美的WordPress圣诞插件</font>
                    </a>
                </td>
        </tr>
    
    <tr>
        <td colspan="4" align="right">
            <a style="text-decoration: none !important;" href="http://www.wumii.com/widget/relatedItems" target="_blank" title="无觅相关文章插件">
                <font size="-1" color="#bbbbbb" style="display: block !important; font-family: arial !important; padding: 5px 0 !important; font-size: 12px !important; color: #bbb !important;">无觅</font>
            </a>
        </td>
    </tr>
</table>]]></content:encoded>
			<wfw:commentRss>http://js8.in/834.html/feed</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>chrome扩展应用开发教程之开发chrome应用基础</title>
		<link>http://js8.in/818.html</link>
		<comments>http://js8.in/818.html#comments</comments>
		<pubDate>Sat, 22 Oct 2011 03:55:17 +0000</pubDate>
		<dc:creator>三水清</dc:creator>
				<category><![CDATA[网络技术]]></category>
		<category><![CDATA[APP]]></category>
		<category><![CDATA[chrome]]></category>
		<category><![CDATA[插件开发]]></category>

		<guid isPermaLink="false">http://www.js8.in/?p=818</guid>
		<description><![CDATA[不得不说chrome做的真的不错，听了貘大大关于chrome插件机制的讲座，就有亲手做个chrome应用的冲动，这个周末终于抽时间做了一个简单的天气预报插件，原理还是很简单的，采用了weather.com.cn的数据，因为比较熟悉这个weather.com.cn的接口，所以很快就搞定一个简单的chrome天气预报应用了。废话不多说了，开始正文。
本教程会step by step的讲解我周末的做天气预报插件，教程包括三篇文章《开发chrome应用基础》《天气预报应用开发》《调试和打包上线》，通过实例讲解，希望对大家开发chrome插件有所帮助。本文只是介绍了chrome应用开发的冰山一角，更多的chrome应用开发技巧还是要自己动手查看下google的文档。
chrome应用开发基础知识
chrome扩展应用是由html、css和javascript组成的，所以chrome应用的门槛比较低，对于一个前端开发者，只要读懂了chrome的开发文档，就可以很快的上手一个chrome应用。
每个chrome扩展都应该包含下面的文件：
一个包括一个manifest.json文件，是个配置文件，json格式，通过manifest.json可以设置应用的icon，指定默认的background.html或者popup.html……
一个或多个html文件（除非这个应用是一个皮肤）
可选的一个或多个javascript文件
可选的任何需要的其他文件，例如图片
在开发应用（扩展）时，需要把这些文件都放到同一个目录下。发布应用（扩展）时，这个目录全部打包到一个应用（扩展）名是.crx的压缩文件中。如果使用Chrome Developer Dashboard，上传应用（扩展），可以自动生成.crx文件。
下图是我天气预报插件的文件列表：
chrome应用界面控制
chrome应用会以browser action或page action的形式在chrome浏览器界面上展现出来。每个应用扩展最多可以有一个browser action或page action。当应用（扩展）的图标是否显示出来是取决于单个的页面时，应当选择page action；当其它情况时可以选择browser action。
例如gmail提醒应用使用了browser action，它在工具栏上增加一个图标：
这个新闻阅读应用也使用了browser action，当点击时会弹出一个气泡窗口popup.html：
另外chrome还包括了桌面提醒（gmail新邮件提醒），主题（chrome皮肤），应用设置页面（应用设置页面），选项卡页面（新选项卡页面）等多种界面形式，本文示例使用的是browser action和popup页面来做一个简单的应用。
chrome应用基本架构
绝大多数chrome应用会包含一个背景页面(background page)，用来执行chrome应用扩展的主要功能。该背景页面时再manifest.json中设置的：

&#34;background_page&#34;: &#34;bg.html&#34;,//默认背景页面

上图显示了安装了应用扩展的chrome。黄色图标代表的browser action和蓝色图标代表的page action。在background.html文件里定义了browser action和javascript代码。在两个窗口里browser action都可以工作。
背景页面并不是chrome应用中唯一的页面。例如，本例天气预报插件中还包括了一个弹窗页面(popup.html)，此页面也是又html页面实现的。在应用内部还可以使用chrome.tabs.create()或者window.open()来显示内部的HTML文件。
chrome应用的弹窗界面也是可以在manifest.json中设置的：

&#34;browser_action&#34;: &#123; 
    &#34;default_icon&#34;: &#34;icon.png&#34; ,
    &#34;default_title&#34;: &#34;Weather&#34;,
    &#34;default_popup&#34;: &#34;popup.html&#34;
  &#125;,

值得一提的是chrome应用里面的HTML页面可以互相访问各自DOM树中的全部元素，或者互相调用其中的函数。
下图显示了一个chrome应用的弹窗的架构。弹窗的内容是由HTML文件（popup.html）定义的web页面。它不必复制背景页面(background.html)里的代码，因为它可以直接调用背景页面中的函数！
应用文件的引用
任何需要的文件都可以放到应用（扩展）中，但是怎么使用它们呢？一般的说，可以像在普通的HTML文件中那样使用相对地址来引用一个文件。下面的例子演示了如何引用images子目录下的文件myimage.png

&#60;img src=&#34;img/myimage.png&#34;&#62;


manifest.json中的文件引用也是采用了相对路径的方式，如下面的代码&#8221;

&#123;
&#34;name&#34;: &#34;My Extension&#34;,//名字
&#34;version&#34;: &#34;2.1&#34;,//版本
&#34;description&#34;: &#34;Gets information from Google.&#34;,//描述
&#34;icons&#34;: &#123; &#34;128&#34;: &#34;icon_128.png&#34; &#125;,//icon
&#34;background_page&#34;: &#34;bg.html&#34;,//默认背景page
&#34;permissions&#34;: &#91;&#34;http://*.google.com/&#34;, &#34;https://*.google.com/&#34;&#93;,//跨域请求域名
&#34;browser_action&#34;: [...]<table class="wumii-related-items" cellspacing="0" cellpadding="3" border="0"  style="clear: both;">
    
    <tr>
        <td colspan="4"><b><font size="-1"  style="display: block !important; padding: 20px 0 5px !important;">猜你喜欢：</font></b></td>
    </tr>
    
        <tr>
                <td width="102" valign="top" style="padding: 5px !important; margin: 0 !important;">
                    <a target="_blank" title="chrome扩展应用开发教程之天气预报应用开发" style="text-decoration: none !important; cursor: pointer !important;" href="http://app.wumii.com/ext/redirect?url=http%3A%2F%2Fjs8.in%2F834.html&from=http%3A%2F%2Fjs8.in%2F818.html">
                        <img style="margin: 0 !important; padding: 2px !important; border: 1px solid #DDDDDD !important; width: 96px !important; height: 96px !important;" src="http://static.wumii.com/site_images/2011/11/17/10982169.png" width="96px" height="96px" /><br />
                        <font size="-1" color="#333333" style="display: block !important; line-height: 15px !important; width: 102px !important; font: 12px/15px arial !important; height: 60px !important; margin: 3px 0 0 0 !important; padding: 0 !important; overflow: hidden !important;">chrome扩展应用开发教程之天气预报应用开发</font>
                    </a>
                </td>
                <td width="102" valign="top" style="padding: 5px !important; margin: 0 !important; border-left: 1px solid #DDDDDD !important;">
                    <a target="_blank" title="chrome扩展应用开发教程之调试和打包上线" style="text-decoration: none !important; cursor: pointer !important;" href="http://app.wumii.com/ext/redirect?url=http%3A%2F%2Fjs8.in%2F841.html&from=http%3A%2F%2Fjs8.in%2F818.html">
                        <img style="margin: 0 !important; padding: 2px !important; border: 1px solid #DDDDDD !important; width: 96px !important; height: 96px !important;" src="http://static.wumii.com/site_images/2011/11/17/10977346.png" width="96px" height="96px" /><br />
                        <font size="-1" color="#333333" style="display: block !important; line-height: 15px !important; width: 102px !important; font: 12px/15px arial !important; height: 60px !important; margin: 3px 0 0 0 !important; padding: 0 !important; overflow: hidden !important;">chrome扩展应用开发教程之调试和打包上线</font>
                    </a>
                </td>
                <td width="102" valign="top" style="padding: 5px !important; margin: 0 !important; border-left: 1px solid #DDDDDD !important;">
                    <a target="_blank" title="chrome字体最小值12px问题及解决方法" style="text-decoration: none !important; cursor: pointer !important;" href="http://app.wumii.com/ext/redirect?url=http%3A%2F%2Fjs8.in%2F341.html&from=http%3A%2F%2Fjs8.in%2F818.html">
                        <img style="margin: 0 !important; padding: 2px !important; border: 1px solid #DDDDDD !important; width: 96px !important; height: 96px !important;" src="http://static.wumii.com/site_images/2011/11/17/10978957.jpg" width="96px" height="96px" /><br />
                        <font size="-1" color="#333333" style="display: block !important; line-height: 15px !important; width: 102px !important; font: 12px/15px arial !important; height: 60px !important; margin: 3px 0 0 0 !important; padding: 0 !important; overflow: hidden !important;">chrome字体最小值12px问题及解决方法</font>
                    </a>
                </td>
                <td width="102" valign="top" style="padding: 5px !important; margin: 0 !important; border-left: 1px solid #DDDDDD !important;">
                    <a target="_blank" title="发现Chrome下提交表单的一个bug" style="text-decoration: none !important; cursor: pointer !important;" href="http://app.wumii.com/ext/redirect?url=http%3A%2F%2Fjs8.in%2F356.html&from=http%3A%2F%2Fjs8.in%2F818.html">
                        <img style="margin: 0 !important; padding: 2px !important; border: 1px solid #DDDDDD !important; width: 96px !important; height: 96px !important;" src="http://static.wumii.com/site_images/2011/11/17/10984473.gif" width="96px" height="96px" /><br />
                        <font size="-1" color="#333333" style="display: block !important; line-height: 15px !important; width: 102px !important; font: 12px/15px arial !important; height: 60px !important; margin: 3px 0 0 0 !important; padding: 0 !important; overflow: hidden !important;">发现Chrome下提交表单的一个bug</font>
                    </a>
                </td>
        </tr>
    
    <tr>
        <td colspan="4" align="right">
            <a style="text-decoration: none !important;" href="http://www.wumii.com/widget/relatedItems" target="_blank" title="无觅相关文章插件">
                <font size="-1" color="#bbbbbb" style="display: block !important; font-family: arial !important; padding: 5px 0 !important; font-size: 12px !important; color: #bbb !important;">无觅</font>
            </a>
        </td>
    </tr>
</table>]]></description>
			<content:encoded><![CDATA[<p>不得不说<strong>chrome</strong>做的真的不错，听了貘大大关于<strong>chrome插件</strong>机制的讲座，就有亲手做个chrome应用的冲动，这个周末终于抽时间做了一个简单的天气预报插件，原理还是很简单的，采用了weather.com.cn的数据，因为比较熟悉这个weather.com.cn的接口，所以很快就搞定一个简单的chrome天气预报应用了。废话不多说了，开始正文。</p>
<p>本教程会step by step的讲解我周末的做天气预报插件，教程包括三篇文章《<a href="http://js8.in/818.htm" target="_blank" title="chrome扩展应用开发教程之开发chrome应用基础">开发chrome应用基础</a>》《<a href="http://js8.in/834.html" target="_blank" title="chrome扩展应用开发教程之天气预报应用开发">天气预报应用开发</a>》《<a href="http://js8.in/841.html" target="_blank" title="chrome扩展应用开发教程之调试和打包上线">调试和打包上线</a>》，通过实例讲解，希望对大家开发chrome插件有所帮助。本文只是介绍了chrome应用开发的冰山一角，更多的chrome应用开发技巧还是要自己动手查看下google的文档。</p>
<h2>chrome应用开发基础知识</h2>
<p>chrome扩展应用是由html、css和javascript组成的，所以chrome应用的门槛比较低，对于一个<strong>前端开发</strong>者，只要读懂了chrome的开发文档，就可以很快的上手一个chrome应用。</p>
<p>每个chrome扩展都应该包含下面的文件：</p>
<blockquote><p>一个包括一个manifest.json文件，是个配置文件，json格式，通过manifest.json可以设置应用的icon，指定默认的background.html或者popup.html……<br />
一个或多个html文件（除非这个应用是一个皮肤）<br />
可选的一个或多个javascript文件<br />
可选的任何需要的其他文件，例如图片</p></blockquote>
<p>在开发应用（扩展）时，需要把这些文件都放到同一个目录下。发布应用（扩展）时，这个目录全部打包到一个应用（扩展）名是.crx的压缩文件中。如果使用<a target="_blank" href="https://chrome.google.com/webstore/developer/dashboard">Chrome Developer Dashboard</a>，上传应用（扩展），可以自动生成.crx文件。</p>
<p>下图是我天气预报插件的文件列表：<br />
<div id="attachment_821" class="wp-caption aligncenter" style="width: 257px"><a href="http://js8.in/818.html/2011-10-21_215004" rel="attachment wp-att-821"><img src="http://js8.in/wp-content/uploads/2011/10/2011-10-21_215004.png" alt="chrome天气预报插件目录结构" title="chrome天气预报插件目录结构" width="247" height="206" class="size-full wp-image-821" /></a><p class="wp-caption-text">chrome天气预报插件目录结构</p></div></p>
<h2>chrome应用界面控制</h2>
<p>chrome应用会以browser action或page action的形式在chrome浏览器界面上展现出来。每个应用扩展最多可以有一个browser action或page action。当应用（扩展）的图标是否显示出来是取决于单个的页面时，应当选择page action；当其它情况时可以选择browser action。</p>
<p>例如gmail提醒应用使用了browser action，它在工具栏上增加一个图标：</p>
<div id="attachment_822" class="wp-caption aligncenter" style="width: 160px"><a href="http://js8.in/818.html/gmail" rel="attachment wp-att-822"><img src="http://js8.in/wp-content/uploads/2011/10/gmail.png" alt="gmail应用使用browser action提示" title="gmail应用使用browser action提示" width="150" height="79" class="size-full wp-image-822" /></a><p class="wp-caption-text">gmail应用使用browser action提示</p></div><br />
这个新闻阅读应用也使用了browser action，当点击时会弹出一个气泡窗口popup.html：<br />
<div id="attachment_823" class="wp-caption aligncenter" style="width: 160px"><a href="http://js8.in/818.html/news" rel="attachment wp-att-823"><img src="http://js8.in/wp-content/uploads/2011/10/news.png" alt="news使用的是popup的方式" title="news使用的是popup的方式" width="150" height="79" class="size-full wp-image-823" /></a><p class="wp-caption-text">news使用的是popup的方式</p></div>
<p>另外chrome还包括了<a target="_blank" href="http://dev.chromium.org/developers/design-documents/desktop-notifications/api-specification">桌面提醒</a>（gmail新邮件提醒），主题（chrome皮肤），应用设置页面（应用设置页面），选项卡页面（新选项卡页面）等多种界面形式，本文示例使用的是browser action和popup页面来做一个简单的应用。</p>
<h3>chrome应用基本架构</h3>
<p>绝大多数chrome应用会包含一个背景页面(background page)，用来执行chrome应用扩展的主要功能。该背景页面时再manifest.json中设置的：</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #3366CC;">&quot;background_page&quot;</span><span style="color: #339933;">:</span> <span style="color: #3366CC;">&quot;bg.html&quot;</span><span style="color: #339933;">,</span><span style="color: #006600; font-style: italic;">//默认背景页面</span></pre></div></div>

<div id="attachment_826" class="wp-caption aligncenter" style="width: 242px"><a href="http://js8.in/818.html/background" rel="attachment wp-att-826"><img src="http://js8.in/wp-content/uploads/2011/10/background.gif" alt="chrome通过background.html来实现主要功能" title="chrome通过background.html来实现主要功能" width="232" height="168" class="size-full wp-image-826" /></a><p class="wp-caption-text">chrome通过background.html来实现主要功能</p></div>
<p>上图显示了安装了应用扩展的chrome。黄色图标代表的browser action和蓝色图标代表的page action。在background.html文件里定义了browser action和javascript代码。在两个窗口里browser action都可以工作。</p>
<p>背景页面并不是chrome应用中唯一的页面。例如，本例天气预报插件中还包括了一个弹窗页面(popup.html)，此页面也是又html页面实现的。在应用内部还可以使用chrome.tabs.create()或者window.open()来显示内部的HTML文件。</p>
<p>chrome应用的弹窗界面也是可以在manifest.json中设置的：</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #3366CC;">&quot;browser_action&quot;</span><span style="color: #339933;">:</span> <span style="color: #009900;">&#123;</span> 
    <span style="color: #3366CC;">&quot;default_icon&quot;</span><span style="color: #339933;">:</span> <span style="color: #3366CC;">&quot;icon.png&quot;</span> <span style="color: #339933;">,</span>
    <span style="color: #3366CC;">&quot;default_title&quot;</span><span style="color: #339933;">:</span> <span style="color: #3366CC;">&quot;Weather&quot;</span><span style="color: #339933;">,</span>
    <span style="color: #3366CC;">&quot;default_popup&quot;</span><span style="color: #339933;">:</span> <span style="color: #3366CC;">&quot;popup.html&quot;</span>
  <span style="color: #009900;">&#125;</span><span style="color: #339933;">,</span></pre></div></div>

<blockquote><p>值得一提的是chrome应用里面的HTML页面可以互相访问各自DOM树中的全部元素，或者互相调用其中的函数。</p></blockquote>
<p>下图显示了一个chrome应用的弹窗的架构。弹窗的内容是由HTML文件（popup.html）定义的web页面。它不必复制背景页面(background.html)里的代码，因为它可以直接调用背景页面中的函数！</p>
<div id="attachment_827" class="wp-caption aligncenter" style="width: 266px"><a href="http://js8.in/818.html/popup" rel="attachment wp-att-827"><img src="http://js8.in/wp-content/uploads/2011/10/popup.gif" alt="chrome应用的弹窗界面" title="chrome应用的弹窗界面" width="256" height="168" class="size-full wp-image-827" /></a><p class="wp-caption-text">chrome应用的弹窗界面</p></div>
<h3>应用文件的引用</h3>
<p>任何需要的文件都可以放到应用（扩展）中，但是怎么使用它们呢？一般的说，可以像在普通的HTML文件中那样使用相对地址来引用一个文件。下面的例子演示了如何引用images子目录下的文件myimage.png</p>

<div class="wp_syntax"><div class="code"><pre class="html" style="font-family:monospace;">&lt;img src=&quot;img/myimage.png&quot;&gt;</pre></div></div>

<p><span id="more-818"></span><br />
<strong>manifest.json</strong>中的文件引用也是采用了相对路径的方式，如下面的代码&#8221;</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #009900;">&#123;</span>
<span style="color: #3366CC;">&quot;name&quot;</span><span style="color: #339933;">:</span> <span style="color: #3366CC;">&quot;My Extension&quot;</span><span style="color: #339933;">,</span><span style="color: #006600; font-style: italic;">//名字</span>
<span style="color: #3366CC;">&quot;version&quot;</span><span style="color: #339933;">:</span> <span style="color: #3366CC;">&quot;2.1&quot;</span><span style="color: #339933;">,</span><span style="color: #006600; font-style: italic;">//版本</span>
<span style="color: #3366CC;">&quot;description&quot;</span><span style="color: #339933;">:</span> <span style="color: #3366CC;">&quot;Gets information from Google.&quot;</span><span style="color: #339933;">,</span><span style="color: #006600; font-style: italic;">//描述</span>
<span style="color: #3366CC;">&quot;icons&quot;</span><span style="color: #339933;">:</span> <span style="color: #009900;">&#123;</span> <span style="color: #3366CC;">&quot;128&quot;</span><span style="color: #339933;">:</span> <span style="color: #3366CC;">&quot;icon_128.png&quot;</span> <span style="color: #009900;">&#125;</span><span style="color: #339933;">,</span><span style="color: #006600; font-style: italic;">//icon</span>
<span style="color: #3366CC;">&quot;background_page&quot;</span><span style="color: #339933;">:</span> <span style="color: #3366CC;">&quot;bg.html&quot;</span><span style="color: #339933;">,</span><span style="color: #006600; font-style: italic;">//默认背景page</span>
<span style="color: #3366CC;">&quot;permissions&quot;</span><span style="color: #339933;">:</span> <span style="color: #009900;">&#91;</span><span style="color: #3366CC;">&quot;http://*.google.com/&quot;</span><span style="color: #339933;">,</span> <span style="color: #3366CC;">&quot;https://*.google.com/&quot;</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">,</span><span style="color: #006600; font-style: italic;">//跨域请求域名</span>
<span style="color: #3366CC;">&quot;browser_action&quot;</span><span style="color: #339933;">:</span> <span style="color: #009900;">&#123;</span> 
    <span style="color: #3366CC;">&quot;default_icon&quot;</span><span style="color: #339933;">:</span> <span style="color: #3366CC;">&quot;icon.png&quot;</span> <span style="color: #339933;">,</span><span style="color: #006600; font-style: italic;">//界面显示的icon</span>
    <span style="color: #3366CC;">&quot;default_title&quot;</span><span style="color: #339933;">:</span> <span style="color: #3366CC;">&quot;Weather&quot;</span><span style="color: #339933;">,</span><span style="color: #006600; font-style: italic;">//界面icon鼠标滑过的title</span>
    <span style="color: #3366CC;">&quot;default_popup&quot;</span><span style="color: #339933;">:</span> <span style="color: #3366CC;">&quot;popup.html&quot;</span><span style="color: #006600; font-style: italic;">//弹窗界面</span>
  <span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<h3>chrome应用页面间的通信</h3>
<p>前面说到了，一个应用中background页面和popup页面之间可以随意的访问相互的DOM，并且可以使用对方的函数。这是因为同一个应用所有页面是在同一个页面的同一个线程中运行的（来自貘大大的ppt），它们之间可以直接互相调用各自的函数。</p>
<p>可以使用 chrome.extension的方法来获取<strong>chrome应用</strong>中的页面，例如getViews()和getBackgroundPage()。一旦一个页面拥有了对这个应用中其它页面的引用，它就可以调用其它页面中的函数，并控制它们的DOM树。</p>
<h2>chrome应用数据处理</h2>
<h3>数据存储</h3>
<p>开发应用肯定会用到数据的处理，chrome是高级浏览器，所以我们可以使用<a href="http://js8.in/802.html" title="HTMl5的sessionStorage和localStorage" target="_blank">html5的web storage api</a>来存储数据。</p>
<h3>跨域请求数据</h3>
<p>作为一个web前端开发者，我们知道普通网页能够使用XMLHttpRequest对象发送或者接受服务器数据， 但是它们受限于同源策略。 扩展可以不受该限制。</p>
<p>但是chrome应用可以做到跨域请求数据，这是chrome的内置机制保证的。任何chrome扩展只要它先获取了跨域请求许可，就可以进行跨域请求。这个获取跨域请求许可方式就是在manifest.json中配置跨域授权的域名，例如：</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #3366CC;">&quot;permissions&quot;</span><span style="color: #339933;">:</span> <span style="color: #009900;">&#91;</span>  <span style="color: #3366CC;">&quot;http://*.weather.com.cn/&quot;</span> <span style="color: #009900;">&#93;</span></pre></div></div>

<p>跨域允许设置可以使用完整域名, 例如:</p>
<blockquote><p>&#8220;http://www.google.com/&#8221;<br />
&#8220;http://www.gmail.com/&#8221;</p></blockquote>
<p>或者使用模式匹配, 例如:</p>
<blockquote><p>&#8220;http://*.google.com/&#8221;</p></blockquote>
<p>这里还需要注意访问权限是根据访问协议(匹配模式里的http或者https或者其他协议名)及域名来授予的。例如某个扩展希望同时基于https和http协议访问某个域或者某些域，那么它必须分别获取基于这两种协议的访问允许(类似下面这样的声明):</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #3366CC;">&quot;permissions&quot;</span><span style="color: #339933;">:</span> <span style="color: #009900;">&#91;</span>
  <span style="color: #3366CC;">&quot;http://www.google.com/&quot;</span><span style="color: #339933;">,</span>
  <span style="color: #3366CC;">&quot;https://www.google.com/&quot;</span>
<span style="color: #009900;">&#93;</span></pre></div></div>

<p>关于跨域的更多了解，可以访问下面四篇跨域相关文章：</p>
<ol>
<li>《<a href="http://js8.in/752.html" target="_blank" title="使用html5 postMessage和window.name实现多浏览器跨域">使用html5 postMessage和window.name实现多浏览器跨域</a>》</li>
<li>《<a title="用document.domain+iframe实现Ajax跨子域" target="_blank" href="http://js8.in/443.html">用document.domain+iframe实现Ajax跨子域</a>》</li>
<li>《<a title="[转]利用跨域资源共享（CORS）实现ajax跨域调用" target="_blank" href="http://js8.in/685.html">[转]利用跨域资源共享（CORS）实现ajax跨域调用</a>》</li>
<li>《<a title="通过JSONP实现完美跨域" target="_blank" href="http://js8.in/548.html">通过JSONP实现完美跨域</a>》</li>
</ol>
<h3>跨域的安全性</h3>
<p>跨域必然要面对的一个问题就是安全问题，尤其是chrome应用中，如果一个chrome应用留有安全隐患，那么所有在chrome浏览的页面都有危险，所以我们编写的背景页需要注意不要成为跨域脚本的牺牲品。例如下面的代码，就很危险：</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #003366; font-weight: bold;">var</span> xhr <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">new</span> XMLHttpRequest<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
xhr.<span style="color: #000066;">open</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;GET&quot;</span><span style="color: #339933;">,</span> <span style="color: #3366CC;">&quot;http://api.example.com/data.json&quot;</span><span style="color: #339933;">,</span> <span style="color: #003366; font-weight: bold;">true</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
xhr.<span style="color: #660066;">onreadystatechange</span> <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
  <span style="color: #000066; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>xhr.<span style="color: #660066;">readyState</span> <span style="color: #339933;">==</span> <span style="color: #CC0000;">4</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
    <span style="color: #006600; font-style: italic;">// 警告! 这里有可能执行了一段恶意脚本!</span>
    <span style="color: #003366; font-weight: bold;">var</span> resp <span style="color: #339933;">=</span> <span style="color: #000066; font-weight: bold;">eval</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;(&quot;</span> <span style="color: #339933;">+</span> xhr.<span style="color: #660066;">responseText</span> <span style="color: #339933;">+</span> <span style="color: #3366CC;">&quot;)&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #006600; font-style: italic;">// 警告! 这样处理有可能被注入恶意脚本!</span>
    document.<span style="color: #660066;">getElementById</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;resp&quot;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">innerHTML</span> <span style="color: #339933;">=</span> xhr.<span style="color: #660066;">responseText</span><span style="color: #339933;">;</span>
    ...
  <span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span>
xhr.<span style="color: #660066;">send</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p>要处理这些问题，需要用到json的解析器<code>JSON.parse</code>，在高级浏览器（比如chrome）中已经集成了JSON的操作，不需要引入json.js就可以操作了，所以上面的代码可以改写成：</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #003366; font-weight: bold;">var</span> xhr <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">new</span> XMLHttpRequest<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
xhr.<span style="color: #000066;">open</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;GET&quot;</span><span style="color: #339933;">,</span> <span style="color: #3366CC;">&quot;http://api.example.com/data.json&quot;</span><span style="color: #339933;">,</span> <span style="color: #003366; font-weight: bold;">true</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
xhr.<span style="color: #660066;">onreadystatechange</span> <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
  <span style="color: #000066; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>xhr.<span style="color: #660066;">readyState</span> <span style="color: #339933;">==</span> <span style="color: #CC0000;">4</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
    <span style="color: #006600; font-style: italic;">// 警告! 这里有可能执行了一段恶意脚本!</span>
    <span style="color: #003366; font-weight: bold;">var</span> resp <span style="color: #339933;">=</span> JSON.<span style="color: #660066;">parse</span><span style="color: #009900;">&#40;</span>xhr.<span style="color: #660066;">responseText</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #006600; font-style: italic;">// 警告! 这样处理有可能被注入恶意脚本!</span>
    document.<span style="color: #660066;">getElementById</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;resp&quot;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">innerText</span><span style="color: #339933;">=</span> xhr.<span style="color: #660066;">responseText</span><span style="color: #339933;">;</span>
    ...
  <span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span>
xhr.<span style="color: #660066;">send</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p>今天关于<strong>chrome应用开发</strong>的教程就先写到这里，明天继续！</p>
<div class="copyright">
<strong>声明：</strong>文章未声明为原创文章，本文链接 <a href="http://js8.in/818.html" title="chrome扩展应用开发教程之开发chrome应用基础">http://js8.in/818.html</a>. 转载请注明转自<a href="http://js8.in" title="前端开发博客"> JS8.IN ™</a></span></span></div>
<h3 class="box-title">随机文章</h3>
<ul class="box_random">
<li><a href="http://js8.in/472.html" title="Javascript在IE与Firefox下的差异写法总结" rel="bookmark inlinks">Javascript在IE与Firefox下的差异写法总结</a></li>
<li><a href="http://js8.in/538.html" title="javascript在光标位置插入内容" rel="bookmark inlinks">javascript在光标位置插入内容</a></li>
<li><a href="http://js8.in/455.html" title="谷歌退出中国事件尘埃落定" rel="bookmark inlinks">谷歌退出中国事件尘埃落定</a></li>
<li><a href="http://js8.in/382.html" title="主流浏览器的CSS Hack方法整理" rel="bookmark inlinks">主流浏览器的CSS Hack方法整理</a></li>
<li><a href="http://js8.in/531.html" title="jQuery插件wBox准备更新" rel="bookmark inlinks">jQuery插件wBox准备更新</a></li>
<li><a href="http://js8.in/750.html" title="javascript入门到高级PPT" rel="bookmark inlinks">javascript入门到高级PPT</a></li>
<li><a href="http://js8.in/413.html" title="jQuery1.4浏览器判断函数bug仍然存在" rel="bookmark inlinks">jQuery1.4浏览器判断函数bug仍然存在</a></li>
<li><a href="http://js8.in/443.html" title="用document.domain+iframe实现Ajax跨子域" rel="bookmark inlinks">用document.domain+iframe实现Ajax跨子域</a></li>
</ul>
<hr />
<p><small>© 三水清 for <a href="http://js8.in">三水清</a>, 2011. |
<a href="http://js8.in/818.html#comments">7 comments</a> |在微博关注我：<a href="//weibo.com/sanshuiqing" target="_blank" title="关注断桥残雪的新浪微博">@清-三水清</a>
<br/>收藏到：
<a rel="nofollow" href="http://share.renren.com/share/buttonshare.do?link=%posturl%&title=%posttitle%" title="收藏本文到人人网" target="_blank">人人网</a> | <a rel="nofollow" href="http://www.douban.com/recommend/?url=%posturl%&title=%posttitle%" title="收藏本文到豆瓣" target="_blank">豆瓣</a> | <a rel="nofollow" href="http://www.kaixin001.com/repaste/share.php?rtitle=%posttitle%&rurl=%posturl%" title="收藏本文到开心网" target="_blank">开心网</a> | <a rel="nofollow" href="http://shuqian.qq.com/post?title=%posttitle%&%20uri=%posturl%" title="收藏本文到QQ书签" target="_blank">QQ书签</a> | <a rel="nofollow" href="http://v.t.sina.com.cn/share/share.php?url=%posturl%&title=%posttitle%" title="收藏本文到新浪微博" target="_blank">新浪微博</a> | <a rel="nofollow" href="http://v.t.qq.com/share/share.php?title=%posttitle%&url=%posturl%&site=http://www.kaixin100.info" title="收藏本文到腾讯微博" target="_blank">腾讯微博</a>
<br/>
Post tags: <a href="http://js8.in/tag/app" rel="tag">APP</a>, <a href="http://js8.in/tag/chrome" rel="tag">chrome</a>, <a href="http://js8.in/tag/%e6%8f%92%e4%bb%b6%e5%bc%80%e5%8f%91" rel="tag">插件开发</a><br/>
</small></p><table class="wumii-related-items" cellspacing="0" cellpadding="3" border="0"  style="clear: both;">
    
    <tr>
        <td colspan="4"><b><font size="-1"  style="display: block !important; padding: 20px 0 5px !important;">猜你喜欢：</font></b></td>
    </tr>
    
        <tr>
                <td width="102" valign="top" style="padding: 5px !important; margin: 0 !important;">
                    <a target="_blank" title="chrome扩展应用开发教程之天气预报应用开发" style="text-decoration: none !important; cursor: pointer !important;" href="http://app.wumii.com/ext/redirect?url=http%3A%2F%2Fjs8.in%2F834.html&from=http%3A%2F%2Fjs8.in%2F818.html">
                        <img style="margin: 0 !important; padding: 2px !important; border: 1px solid #DDDDDD !important; width: 96px !important; height: 96px !important;" src="http://static.wumii.com/site_images/2011/11/17/10982169.png" width="96px" height="96px" /><br />
                        <font size="-1" color="#333333" style="display: block !important; line-height: 15px !important; width: 102px !important; font: 12px/15px arial !important; height: 60px !important; margin: 3px 0 0 0 !important; padding: 0 !important; overflow: hidden !important;">chrome扩展应用开发教程之天气预报应用开发</font>
                    </a>
                </td>
                <td width="102" valign="top" style="padding: 5px !important; margin: 0 !important; border-left: 1px solid #DDDDDD !important;">
                    <a target="_blank" title="chrome扩展应用开发教程之调试和打包上线" style="text-decoration: none !important; cursor: pointer !important;" href="http://app.wumii.com/ext/redirect?url=http%3A%2F%2Fjs8.in%2F841.html&from=http%3A%2F%2Fjs8.in%2F818.html">
                        <img style="margin: 0 !important; padding: 2px !important; border: 1px solid #DDDDDD !important; width: 96px !important; height: 96px !important;" src="http://static.wumii.com/site_images/2011/11/17/10977346.png" width="96px" height="96px" /><br />
                        <font size="-1" color="#333333" style="display: block !important; line-height: 15px !important; width: 102px !important; font: 12px/15px arial !important; height: 60px !important; margin: 3px 0 0 0 !important; padding: 0 !important; overflow: hidden !important;">chrome扩展应用开发教程之调试和打包上线</font>
                    </a>
                </td>
                <td width="102" valign="top" style="padding: 5px !important; margin: 0 !important; border-left: 1px solid #DDDDDD !important;">
                    <a target="_blank" title="chrome字体最小值12px问题及解决方法" style="text-decoration: none !important; cursor: pointer !important;" href="http://app.wumii.com/ext/redirect?url=http%3A%2F%2Fjs8.in%2F341.html&from=http%3A%2F%2Fjs8.in%2F818.html">
                        <img style="margin: 0 !important; padding: 2px !important; border: 1px solid #DDDDDD !important; width: 96px !important; height: 96px !important;" src="http://static.wumii.com/site_images/2011/11/17/10978957.jpg" width="96px" height="96px" /><br />
                        <font size="-1" color="#333333" style="display: block !important; line-height: 15px !important; width: 102px !important; font: 12px/15px arial !important; height: 60px !important; margin: 3px 0 0 0 !important; padding: 0 !important; overflow: hidden !important;">chrome字体最小值12px问题及解决方法</font>
                    </a>
                </td>
                <td width="102" valign="top" style="padding: 5px !important; margin: 0 !important; border-left: 1px solid #DDDDDD !important;">
                    <a target="_blank" title="发现Chrome下提交表单的一个bug" style="text-decoration: none !important; cursor: pointer !important;" href="http://app.wumii.com/ext/redirect?url=http%3A%2F%2Fjs8.in%2F356.html&from=http%3A%2F%2Fjs8.in%2F818.html">
                        <img style="margin: 0 !important; padding: 2px !important; border: 1px solid #DDDDDD !important; width: 96px !important; height: 96px !important;" src="http://static.wumii.com/site_images/2011/11/17/10984473.gif" width="96px" height="96px" /><br />
                        <font size="-1" color="#333333" style="display: block !important; line-height: 15px !important; width: 102px !important; font: 12px/15px arial !important; height: 60px !important; margin: 3px 0 0 0 !important; padding: 0 !important; overflow: hidden !important;">发现Chrome下提交表单的一个bug</font>
                    </a>
                </td>
        </tr>
    
    <tr>
        <td colspan="4" align="right">
            <a style="text-decoration: none !important;" href="http://www.wumii.com/widget/relatedItems" target="_blank" title="无觅相关文章插件">
                <font size="-1" color="#bbbbbb" style="display: block !important; font-family: arial !important; padding: 5px 0 !important; font-size: 12px !important; color: #bbb !important;">无觅</font>
            </a>
        </td>
    </tr>
</table>]]></content:encoded>
			<wfw:commentRss>http://js8.in/818.html/feed</wfw:commentRss>
		<slash:comments>7</slash:comments>
		</item>
		<item>
		<title>css解决chrome 12px字号限制</title>
		<link>http://js8.in/625.html</link>
		<comments>http://js8.in/625.html#comments</comments>
		<pubDate>Sun, 19 Sep 2010 01:07:43 +0000</pubDate>
		<dc:creator>三水清</dc:creator>
				<category><![CDATA[CSS]]></category>
		<category><![CDATA[chrome]]></category>
		<category><![CDATA[webkit]]></category>

		<guid isPermaLink="false">http://www.js8.in/625.html</guid>
		<description><![CDATA[很早之前断桥残雪写过一篇关于chrome最小字体12px的解决方法，但是没有提出来在CSS中的解决方法，今天看了芒果的文章，终于找到了解决的方法了。要解决chrome中最小字体为12px的问题，我们可以使用Webkit 的内核的 -webkit-text-size-adjust 的私有 CSS 属性来解决<table class="wumii-related-items" cellspacing="0" cellpadding="3" border="0"  style="clear: both;">
    
    <tr>
        <td colspan="4"><b><font size="-1"  style="display: block !important; padding: 20px 0 5px !important;">猜你喜欢：</font></b></td>
    </tr>
    
        <tr>
                <td width="102" valign="top" style="padding: 5px !important; margin: 0 !important;">
                    <a target="_blank" title="chrome字体最小值12px问题及解决方法" style="text-decoration: none !important; cursor: pointer !important;" href="http://app.wumii.com/ext/redirect?url=http%3A%2F%2Fjs8.in%2F341.html&from=http%3A%2F%2Fjs8.in%2F625.html">
                        <img style="margin: 0 !important; padding: 2px !important; border: 1px solid #DDDDDD !important; width: 96px !important; height: 96px !important;" src="http://static.wumii.com/site_images/2011/11/17/10978957.jpg" width="96px" height="96px" /><br />
                        <font size="-1" color="#333333" style="display: block !important; line-height: 15px !important; width: 102px !important; font: 12px/15px arial !important; height: 60px !important; margin: 3px 0 0 0 !important; padding: 0 !important; overflow: hidden !important;">chrome字体最小值12px问题及解决方法</font>
                    </a>
                </td>
                <td width="102" valign="top" style="padding: 5px !important; margin: 0 !important; border-left: 1px solid #DDDDDD !important;">
                    <a target="_blank" title="chrome扩展应用开发教程之开发chrome应用基础" style="text-decoration: none !important; cursor: pointer !important;" href="http://app.wumii.com/ext/redirect?url=http%3A%2F%2Fjs8.in%2F818.html&from=http%3A%2F%2Fjs8.in%2F625.html">
                        <img style="margin: 0 !important; padding: 2px !important; border: 1px solid #DDDDDD !important; width: 96px !important; height: 96px !important;" src="http://static.wumii.com/site_images/2011/11/17/10976944.png" width="96px" height="96px" /><br />
                        <font size="-1" color="#333333" style="display: block !important; line-height: 15px !important; width: 102px !important; font: 12px/15px arial !important; height: 60px !important; margin: 3px 0 0 0 !important; padding: 0 !important; overflow: hidden !important;">chrome扩展应用开发教程之开发chrome应用基础</font>
                    </a>
                </td>
                <td width="102" valign="top" style="padding: 5px !important; margin: 0 !important; border-left: 1px solid #DDDDDD !important;">
                    <a target="_blank" title="chrome扩展应用开发教程之调试和打包上线" style="text-decoration: none !important; cursor: pointer !important;" href="http://app.wumii.com/ext/redirect?url=http%3A%2F%2Fjs8.in%2F841.html&from=http%3A%2F%2Fjs8.in%2F625.html">
                        <img style="margin: 0 !important; padding: 2px !important; border: 1px solid #DDDDDD !important; width: 96px !important; height: 96px !important;" src="http://static.wumii.com/site_images/2011/11/17/10977346.png" width="96px" height="96px" /><br />
                        <font size="-1" color="#333333" style="display: block !important; line-height: 15px !important; width: 102px !important; font: 12px/15px arial !important; height: 60px !important; margin: 3px 0 0 0 !important; padding: 0 !important; overflow: hidden !important;">chrome扩展应用开发教程之调试和打包上线</font>
                    </a>
                </td>
                <td width="102" valign="top" style="padding: 5px !important; margin: 0 !important; border-left: 1px solid #DDDDDD !important;">
                    <a target="_blank" title="chrome扩展应用开发教程之天气预报应用开发" style="text-decoration: none !important; cursor: pointer !important;" href="http://app.wumii.com/ext/redirect?url=http%3A%2F%2Fjs8.in%2F834.html&from=http%3A%2F%2Fjs8.in%2F625.html">
                        <img style="margin: 0 !important; padding: 2px !important; border: 1px solid #DDDDDD !important; width: 96px !important; height: 96px !important;" src="http://static.wumii.com/site_images/2011/11/17/10982169.png" width="96px" height="96px" /><br />
                        <font size="-1" color="#333333" style="display: block !important; line-height: 15px !important; width: 102px !important; font: 12px/15px arial !important; height: 60px !important; margin: 3px 0 0 0 !important; padding: 0 !important; overflow: hidden !important;">chrome扩展应用开发教程之天气预报应用开发</font>
                    </a>
                </td>
        </tr>
    
    <tr>
        <td colspan="4" align="right">
            <a style="text-decoration: none !important;" href="http://www.wumii.com/widget/relatedItems" target="_blank" title="无觅相关文章插件">
                <font size="-1" color="#bbbbbb" style="display: block !important; font-family: arial !important; padding: 5px 0 !important; font-size: 12px !important; color: #bbb !important;">无觅</font>
            </a>
        </td>
    </tr>
</table>]]></description>
			<content:encoded><![CDATA[<p>很早之前断桥残雪写过一篇关于<a target="_blank" href="http://js8.in/341.html">chrome最小字体12px的解决方法</a>，但是没有提出来在<strong>CSS</strong>中的解决方法，今天看了<a href="http://www.mangguo.org/google-chrome-chinese-minimum-font-size/" target="_blank">芒果</a>的文章，终于找到了解决的方法了。要解决<strong>chrome</strong>中最小字体为<strong>12px</strong>的问题，我们可以使用Webkit 的内核的<code> -webkit-text-size-adjust</code> 的私有 <strong>CSS 属性</strong>来解决，比如下面的代码就可以成功的解决，通过它即可实现字体大小不随终端设备或浏览器影响。样式定义如下：</p>

<div class="wp_syntax"><div class="code"><pre class="css" style="font-family:monospace;"><span style="color: #cc00cc;">#chrome<span style="color: #933;">10px</span></span><span style="color: #00AA00;">&#123;</span>
-webkit-text-size-adjust<span style="color: #00AA00;">:</span><span style="color: #993333;">none</span><span style="color: #00AA00;">;</span>
<span style="color: #000000; font-weight: bold;">font-size</span><span style="color: #00AA00;">:</span><span style="color: #933;">10px</span><span style="color: #00AA00;">;</span>
<span style="color: #00AA00;">&#125;</span></pre></div></div>

<p>纠结了大半年的chrome<strong>字体</strong>12px的限制问题终于找到了CSS的解决方法了！<br />
上图看看：</p>
<p><div id="attachment_624" class="wp-caption aligncenter" style="width: 155px"><a href="http://js8.in/wp-content/uploads/2010/09/Snap3.jpg"><img class="size-full wp-image-624" title="chrome字体限制12px" src="http://js8.in/wp-content/uploads/2010/09/Snap3.jpg" alt="css解决chrome字体限制12px" width="145" height="48" /></a><p class="wp-caption-text">css解决chrome字体限制12px</p></div>
<div class="copyright">
<strong>声明：</strong>文章未声明为原创文章，本文链接 <a href="http://js8.in/625.html" title="css解决chrome 12px字号限制">http://js8.in/625.html</a>. 转载请注明转自<a href="http://js8.in" title="前端开发博客"> JS8.IN ™</a></span></span></div>
<h3 class="box-title">随机文章</h3>
<ul class="box_random">
<li><a href="http://js8.in/481.html" title="瑞星贿赂造假丑闻曝光，为转移视线捏造360后门事件" rel="bookmark inlinks">瑞星贿赂造假丑闻曝光，为转移视线捏造360后门事件</a></li>
<li><a href="http://js8.in/337.html" title="jQuery浏览器判断一个bug，以及修改建议" rel="bookmark inlinks">jQuery浏览器判断一个bug，以及修改建议</a></li>
<li><a href="http://js8.in/457.html" title="21个常用的 PHP 代码汇总" rel="bookmark inlinks">21个常用的 PHP 代码汇总</a></li>
<li><a href="http://js8.in/456.html" title="google黑板报澄清退出中国的不实传言" rel="bookmark inlinks">google黑板报澄清退出中国的不实传言</a></li>
<li><a href="http://js8.in/679.html" title="html5+css3版的爱墙上了" rel="bookmark inlinks">html5+css3版的爱墙上了</a></li>
<li><a href="http://js8.in/495.html" title="爱墙 许愿墙 祝福墙程序免费下载" rel="bookmark inlinks">爱墙 许愿墙 祝福墙程序免费下载</a></li>
<li><a href="http://js8.in/636.html" title="俺的Feed地址又换了！" rel="bookmark inlinks">俺的Feed地址又换了！</a></li>
<li><a href="http://js8.in/681.html" title="WinHttp.WinHttpRequest.5.1—可以用作抓取的msxml 4.0底层对象" rel="bookmark inlinks">WinHttp.WinHttpRequest.5.1—可以用作抓取的msxml 4.0底层对象</a></li>
</ul>
<hr />
<p><small>© 三水清 for <a href="http://js8.in">三水清</a>, 2010. |
<a href="http://js8.in/625.html#comments">5 comments</a> |在微博关注我：<a href="//weibo.com/sanshuiqing" target="_blank" title="关注断桥残雪的新浪微博">@清-三水清</a>
<br/>收藏到：
<a rel="nofollow" href="http://share.renren.com/share/buttonshare.do?link=%posturl%&title=%posttitle%" title="收藏本文到人人网" target="_blank">人人网</a> | <a rel="nofollow" href="http://www.douban.com/recommend/?url=%posturl%&title=%posttitle%" title="收藏本文到豆瓣" target="_blank">豆瓣</a> | <a rel="nofollow" href="http://www.kaixin001.com/repaste/share.php?rtitle=%posttitle%&rurl=%posturl%" title="收藏本文到开心网" target="_blank">开心网</a> | <a rel="nofollow" href="http://shuqian.qq.com/post?title=%posttitle%&%20uri=%posturl%" title="收藏本文到QQ书签" target="_blank">QQ书签</a> | <a rel="nofollow" href="http://v.t.sina.com.cn/share/share.php?url=%posturl%&title=%posttitle%" title="收藏本文到新浪微博" target="_blank">新浪微博</a> | <a rel="nofollow" href="http://v.t.qq.com/share/share.php?title=%posttitle%&url=%posturl%&site=http://www.kaixin100.info" title="收藏本文到腾讯微博" target="_blank">腾讯微博</a>
<br/>
Post tags: <a href="http://js8.in/tag/chrome" rel="tag">chrome</a>, <a href="http://js8.in/tag/webkit" rel="tag">webkit</a><br/>
</small></p><table class="wumii-related-items" cellspacing="0" cellpadding="3" border="0"  style="clear: both;">
    
    <tr>
        <td colspan="4"><b><font size="-1"  style="display: block !important; padding: 20px 0 5px !important;">猜你喜欢：</font></b></td>
    </tr>
    
        <tr>
                <td width="102" valign="top" style="padding: 5px !important; margin: 0 !important;">
                    <a target="_blank" title="chrome字体最小值12px问题及解决方法" style="text-decoration: none !important; cursor: pointer !important;" href="http://app.wumii.com/ext/redirect?url=http%3A%2F%2Fjs8.in%2F341.html&from=http%3A%2F%2Fjs8.in%2F625.html">
                        <img style="margin: 0 !important; padding: 2px !important; border: 1px solid #DDDDDD !important; width: 96px !important; height: 96px !important;" src="http://static.wumii.com/site_images/2011/11/17/10978957.jpg" width="96px" height="96px" /><br />
                        <font size="-1" color="#333333" style="display: block !important; line-height: 15px !important; width: 102px !important; font: 12px/15px arial !important; height: 60px !important; margin: 3px 0 0 0 !important; padding: 0 !important; overflow: hidden !important;">chrome字体最小值12px问题及解决方法</font>
                    </a>
                </td>
                <td width="102" valign="top" style="padding: 5px !important; margin: 0 !important; border-left: 1px solid #DDDDDD !important;">
                    <a target="_blank" title="chrome扩展应用开发教程之开发chrome应用基础" style="text-decoration: none !important; cursor: pointer !important;" href="http://app.wumii.com/ext/redirect?url=http%3A%2F%2Fjs8.in%2F818.html&from=http%3A%2F%2Fjs8.in%2F625.html">
                        <img style="margin: 0 !important; padding: 2px !important; border: 1px solid #DDDDDD !important; width: 96px !important; height: 96px !important;" src="http://static.wumii.com/site_images/2011/11/17/10976944.png" width="96px" height="96px" /><br />
                        <font size="-1" color="#333333" style="display: block !important; line-height: 15px !important; width: 102px !important; font: 12px/15px arial !important; height: 60px !important; margin: 3px 0 0 0 !important; padding: 0 !important; overflow: hidden !important;">chrome扩展应用开发教程之开发chrome应用基础</font>
                    </a>
                </td>
                <td width="102" valign="top" style="padding: 5px !important; margin: 0 !important; border-left: 1px solid #DDDDDD !important;">
                    <a target="_blank" title="chrome扩展应用开发教程之调试和打包上线" style="text-decoration: none !important; cursor: pointer !important;" href="http://app.wumii.com/ext/redirect?url=http%3A%2F%2Fjs8.in%2F841.html&from=http%3A%2F%2Fjs8.in%2F625.html">
                        <img style="margin: 0 !important; padding: 2px !important; border: 1px solid #DDDDDD !important; width: 96px !important; height: 96px !important;" src="http://static.wumii.com/site_images/2011/11/17/10977346.png" width="96px" height="96px" /><br />
                        <font size="-1" color="#333333" style="display: block !important; line-height: 15px !important; width: 102px !important; font: 12px/15px arial !important; height: 60px !important; margin: 3px 0 0 0 !important; padding: 0 !important; overflow: hidden !important;">chrome扩展应用开发教程之调试和打包上线</font>
                    </a>
                </td>
                <td width="102" valign="top" style="padding: 5px !important; margin: 0 !important; border-left: 1px solid #DDDDDD !important;">
                    <a target="_blank" title="chrome扩展应用开发教程之天气预报应用开发" style="text-decoration: none !important; cursor: pointer !important;" href="http://app.wumii.com/ext/redirect?url=http%3A%2F%2Fjs8.in%2F834.html&from=http%3A%2F%2Fjs8.in%2F625.html">
                        <img style="margin: 0 !important; padding: 2px !important; border: 1px solid #DDDDDD !important; width: 96px !important; height: 96px !important;" src="http://static.wumii.com/site_images/2011/11/17/10982169.png" width="96px" height="96px" /><br />
                        <font size="-1" color="#333333" style="display: block !important; line-height: 15px !important; width: 102px !important; font: 12px/15px arial !important; height: 60px !important; margin: 3px 0 0 0 !important; padding: 0 !important; overflow: hidden !important;">chrome扩展应用开发教程之天气预报应用开发</font>
                    </a>
                </td>
        </tr>
    
    <tr>
        <td colspan="4" align="right">
            <a style="text-decoration: none !important;" href="http://www.wumii.com/widget/relatedItems" target="_blank" title="无觅相关文章插件">
                <font size="-1" color="#bbbbbb" style="display: block !important; font-family: arial !important; padding: 5px 0 !important; font-size: 12px !important; color: #bbb !important;">无觅</font>
            </a>
        </td>
    </tr>
</table>]]></content:encoded>
			<wfw:commentRss>http://js8.in/625.html/feed</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>发现Chrome下提交表单的一个bug</title>
		<link>http://js8.in/356.html</link>
		<comments>http://js8.in/356.html#comments</comments>
		<pubDate>Wed, 02 Dec 2009 09:44:31 +0000</pubDate>
		<dc:creator>三水清</dc:creator>
				<category><![CDATA[软件心得]]></category>
		<category><![CDATA[bug]]></category>
		<category><![CDATA[chrome]]></category>

		<guid isPermaLink="false">http://www.js8.in/356.html</guid>
		<description><![CDATA[之前在文章《Chrome字体最小值12px问题及解决方法》中提到Chrome需要配置一些软件才能显示小于12px的字，默认如果在css中设置更小的字号却是12px。这个是要前端人员很头疼的事情，并且前端开发者除了css hack不能要每个用户都配置软件，以达到更好地浏览效果~
昨天晓亮对于我写的打印页面提出一个问题：在chrome下，打印按钮只能使用一次，今天我写了一个简单的表单，只有一个input的，加一个submit，可是chrome还是提交了一次，一次之后任你狂点，都不会做出任何的举动。
更有趣的是，我发现在iGoogle上的搜索按钮，在chrome也是存在类似的问题~不知道是chrome为了防止重复提交表单故意设计，还是Chrome的一个程序设计bug，不管怎样我还是把bug提交给了google官方，希望官方尽快给予答复。
特此记录一下~

声明：文章未声明为原创文章，本文链接 http://js8.in/356.html. 转载请注明转自 JS8.IN ™
随机文章

谷歌要退出中国大陆市场？！
再来几个腾讯微博的邀请种子
推荐六个在线制作Loading图标的网站
没见过这么不要脸的！——校内网太不厚道，无耻之
简单修改.htaccess来提高Yslow等级
非字母javascript
哎~都挺穷的！
javascript简单实现checkbox的全选与反选


© 三水清 for 三水清, 2009. &#124;
2 comments &#124;在微博关注我：@清-三水清
收藏到：
人人网 &#124; 豆瓣 &#124; 开心网 &#124; QQ书签 &#124; 新浪微博 &#124; 腾讯微博

Post tags: bug, chrome
<table class="wumii-related-items" cellspacing="0" cellpadding="3" border="0"  style="clear: both;">
    
    <tr>
        <td colspan="4"><b><font size="-1"  style="display: block !important; padding: 20px 0 5px !important;">猜你喜欢：</font></b></td>
    </tr>
    
        <tr>
                <td width="102" valign="top" style="padding: 5px !important; margin: 0 !important;">
                    <a target="_blank" title="解决IE6不支持max-height的bug" style="text-decoration: none !important; cursor: pointer !important;" href="http://app.wumii.com/ext/redirect?url=http%3A%2F%2Fjs8.in%2F606.html&from=http%3A%2F%2Fjs8.in%2F356.html">
                        <img style="margin: 0 !important; padding: 2px !important; border: 1px solid #DDDDDD !important; width: 96px !important; height: 96px !important;" src="http://static.wumii.com/site_images/2011/11/17/10978851.gif" width="96px" height="96px" /><br />
                        <font size="-1" color="#333333" style="display: block !important; line-height: 15px !important; width: 102px !important; font: 12px/15px arial !important; height: 60px !important; margin: 3px 0 0 0 !important; padding: 0 !important; overflow: hidden !important;">解决IE6不支持max-height的bug</font>
                    </a>
                </td>
                <td width="102" valign="top" style="padding: 5px !important; margin: 0 !important; border-left: 1px solid #DDDDDD !important;">
                    <a target="_blank" title="css解决chrome 12px字号限制" style="text-decoration: none !important; cursor: pointer !important;" href="http://app.wumii.com/ext/redirect?url=http%3A%2F%2Fjs8.in%2F625.html&from=http%3A%2F%2Fjs8.in%2F356.html">
                        <img style="margin: 0 !important; padding: 2px !important; border: 1px solid #DDDDDD !important; width: 96px !important; height: 96px !important;" src="http://static.wumii.com/site_images/2011/11/17/10979712.jpg" width="96px" height="96px" /><br />
                        <font size="-1" color="#333333" style="display: block !important; line-height: 15px !important; width: 102px !important; font: 12px/15px arial !important; height: 60px !important; margin: 3px 0 0 0 !important; padding: 0 !important; overflow: hidden !important;">css解决chrome 12px字号限制</font>
                    </a>
                </td>
                <td width="102" valign="top" style="padding: 5px !important; margin: 0 !important; border-left: 1px solid #DDDDDD !important;">
                    <a target="_blank" title="最新版wBox 解决IE6 背景太小bug" style="text-decoration: none !important; cursor: pointer !important;" href="http://app.wumii.com/ext/redirect?url=http%3A%2F%2Fjs8.in%2F506.html&from=http%3A%2F%2Fjs8.in%2F356.html">
                        <img style="margin: 0 !important; padding: 2px !important; border: 1px solid #DDDDDD !important; width: 96px !important; height: 96px !important;" src="http://static.wumii.com/site_images/2011/11/17/10977733.png" width="96px" height="96px" /><br />
                        <font size="-1" color="#333333" style="display: block !important; line-height: 15px !important; width: 102px !important; font: 12px/15px arial !important; height: 60px !important; margin: 3px 0 0 0 !important; padding: 0 !important; overflow: hidden !important;">最新版wBox 解决IE6 背景太小bug</font>
                    </a>
                </td>
                <td width="102" valign="top" style="padding: 5px !important; margin: 0 !important; border-left: 1px solid #DDDDDD !important;">
                    <a target="_blank" title="解决IE下setTimeout传参数的bug" style="text-decoration: none !important; cursor: pointer !important;" href="http://app.wumii.com/ext/redirect?url=http%3A%2F%2Fjs8.in%2F593.html&from=http%3A%2F%2Fjs8.in%2F356.html">
                        <img style="margin: 0 !important; padding: 2px !important; border: 1px solid #DDDDDD !important; width: 96px !important; height: 96px !important;" src="http://static.wumii.com/images/blogWidget/wordpress_default.gif" width="96px" height="96px" /><br />
                        <font size="-1" color="#333333" style="display: block !important; line-height: 15px !important; width: 102px !important; font: 12px/15px arial !important; height: 60px !important; margin: 3px 0 0 0 !important; padding: 0 !important; overflow: hidden !important;">解决IE下setTimeout传参数的bug</font>
                    </a>
                </td>
        </tr>
    
    <tr>
        <td colspan="4" align="right">
            <a style="text-decoration: none !important;" href="http://www.wumii.com/widget/relatedItems" target="_blank" title="无觅相关文章插件">
                <font size="-1" color="#bbbbbb" style="display: block !important; font-family: arial !important; padding: 5px 0 !important; font-size: 12px !important; color: #bbb !important;">无觅</font>
            </a>
        </td>
    </tr>
</table>]]></description>
			<content:encoded><![CDATA[<p>之前在文章《<a href="http://js8.in/341.html" title="《Chrome字体最小值12px问题及解决方法》原文"><strong>Chrome字体最小值12px问题及解决方法</strong></a>》中提到Chrome需要配置一些软件才能显示小于12px的字，默认如果在css中设置更小的字号却是12px。这个是要前端人员很头疼的事情，并且前端开发者除了<strong>css hack</strong>不能要每个用户都配置软件，以达到更好地浏览效果~</p>
<p>昨天<a target="_blank" href="http://www.masterboke.cn" target="_blank">晓亮</a>对于我写的打印页面提出一个问题：在chrome下，打印按钮只能使用一次，今天我写了一个简单的表单，只有一个input的，加一个submit，可是chrome还是提交了一次，一次之后任你狂点，都不会做出任何的举动。</p>
<p>更有趣的是，我发现在iGoogle上的搜索按钮，在chrome也是存在类似的问题~不知道是chrome为了防止重复提交表单故意设计，还是Chrome的一个程序设计bug，不管怎样我还是把bug提交给了<strong>google</strong>官方，希望官方尽快给予答复。<br />
特此记录一下~
<div class="copyright">
<strong>声明：</strong>文章未声明为原创文章，本文链接 <a href="http://js8.in/356.html" title="发现Chrome下提交表单的一个bug">http://js8.in/356.html</a>. 转载请注明转自<a href="http://js8.in" title="前端开发博客"> JS8.IN ™</a></span></span></div>
<h3 class="box-title">随机文章</h3>
<ul class="box_random">
<li><a href="http://js8.in/640.html" title="dedeeims列表页面导航条当前样式实现方法" rel="bookmark inlinks">dedeeims列表页面导航条当前样式实现方法</a></li>
<li><a href="http://js8.in/497.html" title="韩峰其实是个好干部" rel="bookmark inlinks">韩峰其实是个好干部</a></li>
<li><a href="http://js8.in/37.html" title="“学长，你考研挺忙吧？！”" rel="bookmark inlinks">“学长，你考研挺忙吧？！”</a></li>
<li><a href="http://js8.in/731.html" title="IE的fireEvent方法" rel="bookmark inlinks">IE的fireEvent方法</a></li>
<li><a href="http://js8.in/600.html" title="jQuery教程之鼠标事件篇" rel="bookmark inlinks">jQuery教程之鼠标事件篇</a></li>
<li><a href="http://js8.in/359.html" title="提前体验Google新页面" rel="bookmark inlinks">提前体验Google新页面</a></li>
<li><a href="http://js8.in/491.html" title="雷：蓝翔技校黑谷歌！" rel="bookmark inlinks">雷：蓝翔技校黑谷歌！</a></li>
<li><a href="http://js8.in/591.html" title="切换订阅地址到feedsky" rel="bookmark inlinks">切换订阅地址到feedsky</a></li>
</ul>
<hr />
<p><small>© 三水清 for <a href="http://js8.in">三水清</a>, 2009. |
<a href="http://js8.in/356.html#comments">2 comments</a> |在微博关注我：<a href="//weibo.com/sanshuiqing" target="_blank" title="关注断桥残雪的新浪微博">@清-三水清</a>
<br/>收藏到：
<a rel="nofollow" href="http://share.renren.com/share/buttonshare.do?link=%posturl%&title=%posttitle%" title="收藏本文到人人网" target="_blank">人人网</a> | <a rel="nofollow" href="http://www.douban.com/recommend/?url=%posturl%&title=%posttitle%" title="收藏本文到豆瓣" target="_blank">豆瓣</a> | <a rel="nofollow" href="http://www.kaixin001.com/repaste/share.php?rtitle=%posttitle%&rurl=%posturl%" title="收藏本文到开心网" target="_blank">开心网</a> | <a rel="nofollow" href="http://shuqian.qq.com/post?title=%posttitle%&%20uri=%posturl%" title="收藏本文到QQ书签" target="_blank">QQ书签</a> | <a rel="nofollow" href="http://v.t.sina.com.cn/share/share.php?url=%posturl%&title=%posttitle%" title="收藏本文到新浪微博" target="_blank">新浪微博</a> | <a rel="nofollow" href="http://v.t.qq.com/share/share.php?title=%posttitle%&url=%posturl%&site=http://www.kaixin100.info" title="收藏本文到腾讯微博" target="_blank">腾讯微博</a>
<br/>
Post tags: <a href="http://js8.in/tag/bug" rel="tag">bug</a>, <a href="http://js8.in/tag/chrome" rel="tag">chrome</a><br/>
</small></p><table class="wumii-related-items" cellspacing="0" cellpadding="3" border="0"  style="clear: both;">
    
    <tr>
        <td colspan="4"><b><font size="-1"  style="display: block !important; padding: 20px 0 5px !important;">猜你喜欢：</font></b></td>
    </tr>
    
        <tr>
                <td width="102" valign="top" style="padding: 5px !important; margin: 0 !important;">
                    <a target="_blank" title="解决IE6不支持max-height的bug" style="text-decoration: none !important; cursor: pointer !important;" href="http://app.wumii.com/ext/redirect?url=http%3A%2F%2Fjs8.in%2F606.html&from=http%3A%2F%2Fjs8.in%2F356.html">
                        <img style="margin: 0 !important; padding: 2px !important; border: 1px solid #DDDDDD !important; width: 96px !important; height: 96px !important;" src="http://static.wumii.com/site_images/2011/11/17/10978851.gif" width="96px" height="96px" /><br />
                        <font size="-1" color="#333333" style="display: block !important; line-height: 15px !important; width: 102px !important; font: 12px/15px arial !important; height: 60px !important; margin: 3px 0 0 0 !important; padding: 0 !important; overflow: hidden !important;">解决IE6不支持max-height的bug</font>
                    </a>
                </td>
                <td width="102" valign="top" style="padding: 5px !important; margin: 0 !important; border-left: 1px solid #DDDDDD !important;">
                    <a target="_blank" title="css解决chrome 12px字号限制" style="text-decoration: none !important; cursor: pointer !important;" href="http://app.wumii.com/ext/redirect?url=http%3A%2F%2Fjs8.in%2F625.html&from=http%3A%2F%2Fjs8.in%2F356.html">
                        <img style="margin: 0 !important; padding: 2px !important; border: 1px solid #DDDDDD !important; width: 96px !important; height: 96px !important;" src="http://static.wumii.com/site_images/2011/11/17/10979712.jpg" width="96px" height="96px" /><br />
                        <font size="-1" color="#333333" style="display: block !important; line-height: 15px !important; width: 102px !important; font: 12px/15px arial !important; height: 60px !important; margin: 3px 0 0 0 !important; padding: 0 !important; overflow: hidden !important;">css解决chrome 12px字号限制</font>
                    </a>
                </td>
                <td width="102" valign="top" style="padding: 5px !important; margin: 0 !important; border-left: 1px solid #DDDDDD !important;">
                    <a target="_blank" title="最新版wBox 解决IE6 背景太小bug" style="text-decoration: none !important; cursor: pointer !important;" href="http://app.wumii.com/ext/redirect?url=http%3A%2F%2Fjs8.in%2F506.html&from=http%3A%2F%2Fjs8.in%2F356.html">
                        <img style="margin: 0 !important; padding: 2px !important; border: 1px solid #DDDDDD !important; width: 96px !important; height: 96px !important;" src="http://static.wumii.com/site_images/2011/11/17/10977733.png" width="96px" height="96px" /><br />
                        <font size="-1" color="#333333" style="display: block !important; line-height: 15px !important; width: 102px !important; font: 12px/15px arial !important; height: 60px !important; margin: 3px 0 0 0 !important; padding: 0 !important; overflow: hidden !important;">最新版wBox 解决IE6 背景太小bug</font>
                    </a>
                </td>
                <td width="102" valign="top" style="padding: 5px !important; margin: 0 !important; border-left: 1px solid #DDDDDD !important;">
                    <a target="_blank" title="解决IE下setTimeout传参数的bug" style="text-decoration: none !important; cursor: pointer !important;" href="http://app.wumii.com/ext/redirect?url=http%3A%2F%2Fjs8.in%2F593.html&from=http%3A%2F%2Fjs8.in%2F356.html">
                        <img style="margin: 0 !important; padding: 2px !important; border: 1px solid #DDDDDD !important; width: 96px !important; height: 96px !important;" src="http://static.wumii.com/images/blogWidget/wordpress_default.gif" width="96px" height="96px" /><br />
                        <font size="-1" color="#333333" style="display: block !important; line-height: 15px !important; width: 102px !important; font: 12px/15px arial !important; height: 60px !important; margin: 3px 0 0 0 !important; padding: 0 !important; overflow: hidden !important;">解决IE下setTimeout传参数的bug</font>
                    </a>
                </td>
        </tr>
    
    <tr>
        <td colspan="4" align="right">
            <a style="text-decoration: none !important;" href="http://www.wumii.com/widget/relatedItems" target="_blank" title="无觅相关文章插件">
                <font size="-1" color="#bbbbbb" style="display: block !important; font-family: arial !important; padding: 5px 0 !important; font-size: 12px !important; color: #bbb !important;">无觅</font>
            </a>
        </td>
    </tr>
</table>]]></content:encoded>
			<wfw:commentRss>http://js8.in/356.html/feed</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>chrome字体最小值12px问题及解决方法</title>
		<link>http://js8.in/341.html</link>
		<comments>http://js8.in/341.html#comments</comments>
		<pubDate>Fri, 20 Nov 2009 02:30:31 +0000</pubDate>
		<dc:creator>三水清</dc:creator>
				<category><![CDATA[网络技术]]></category>
		<category><![CDATA[chrome]]></category>
		<category><![CDATA[css hack]]></category>
		<category><![CDATA[wordpress]]></category>

		<guid isPermaLink="false">http://www.js8.in/341.html</guid>
		<description><![CDATA[昨天我修改自己的WordPress天气插件的时候，发现一个比较有趣的问题：chrome竟然最小的字体是12px，而小于12px的数值，百分比之类的都不起左右，都是显示12px。
对于这个问题，我上google搜索了半天也没有结果，本来因为是css出现了问题，测试了好多次都不行，于是最后来了个style=&#8221;font-size:10px&#8221;都没有显示成功，之后我写了一段代码在本地测试，还是不行，问了同事，同事都是表示不知道。
后来是怀疑自己的html声明写错了，可是更换了标准声明还是不行，至今还是表示疑惑，找到了客户端设置chrome的方法，而没有css hack的方法没有找到，希望高手给个css hack解决的方法。
WordPress天气预报插件地址：http://js8.in/mywork/weather
demo地址：http://js8.in/mywork/weather/demo.php?city=0532
 
解决方法
1.将chrome的界面语言改成英文,方法:扳手-选项-高级选项-更改字体和语言设置-语言-谷歌浏览器语言 将这里的改成英语(美国)之类
2.
Basically, the Chrome browser is based on WebKit. There are some webkit internal font setting options for font family, font size, etc.
Using text editor to open &#8220;Documents and Settings\User_Name\Local Settings\Application Data\Google\Chrome\User Data\Default\Preferences&#8221;
You will find the &#8220;webkit&#8221;: {  &#8220;webprefs&#8221;: { in the file. Those settings are for WebKit.
In my setting example:
 [...]<table class="wumii-related-items" cellspacing="0" cellpadding="3" border="0"  style="clear: both;">
    
    <tr>
        <td colspan="4"><b><font size="-1"  style="display: block !important; padding: 20px 0 5px !important;">猜你喜欢：</font></b></td>
    </tr>
    
        <tr>
                <td width="102" valign="top" style="padding: 5px !important; margin: 0 !important;">
                    <a target="_blank" title="Opera Chrome Safari浏览器的CSS Hack方法" style="text-decoration: none !important; cursor: pointer !important;" href="http://app.wumii.com/ext/redirect?url=http%3A%2F%2Fjs8.in%2F397.html&from=http%3A%2F%2Fjs8.in%2F341.html">
                        <img style="margin: 0 !important; padding: 2px !important; border: 1px solid #DDDDDD !important; width: 96px !important; height: 96px !important;" src="http://static.wumii.com/site_images/2011/06/11/11779216.jpg" width="96px" height="96px" /><br />
                        <font size="-1" color="#333333" style="display: block !important; line-height: 15px !important; width: 102px !important; font: 12px/15px arial !important; height: 60px !important; margin: 3px 0 0 0 !important; padding: 0 !important; overflow: hidden !important;">Opera Chrome Safari浏览器的CSS Hack方法</font>
                    </a>
                </td>
                <td width="102" valign="top" style="padding: 5px !important; margin: 0 !important; border-left: 1px solid #DDDDDD !important;">
                    <a target="_blank" title="使用if IE hack注释解决CSS以及JS的兼容问题" style="text-decoration: none !important; cursor: pointer !important;" href="http://app.wumii.com/ext/redirect?url=http%3A%2F%2Fjs8.in%2F381.html&from=http%3A%2F%2Fjs8.in%2F341.html">
                        <img style="margin: 0 !important; padding: 2px !important; border: 1px solid #DDDDDD !important; width: 96px !important; height: 96px !important;" src="http://static.wumii.com/site_images/2011/11/17/10979211.gif" width="96px" height="96px" /><br />
                        <font size="-1" color="#333333" style="display: block !important; line-height: 15px !important; width: 102px !important; font: 12px/15px arial !important; height: 60px !important; margin: 3px 0 0 0 !important; padding: 0 !important; overflow: hidden !important;">使用if IE hack注释解决CSS以及JS的兼容问题</font>
                    </a>
                </td>
                <td width="102" valign="top" style="padding: 5px !important; margin: 0 !important; border-left: 1px solid #DDDDDD !important;">
                    <a target="_blank" title="css解决chrome 12px字号限制" style="text-decoration: none !important; cursor: pointer !important;" href="http://app.wumii.com/ext/redirect?url=http%3A%2F%2Fjs8.in%2F625.html&from=http%3A%2F%2Fjs8.in%2F341.html">
                        <img style="margin: 0 !important; padding: 2px !important; border: 1px solid #DDDDDD !important; width: 96px !important; height: 96px !important;" src="http://static.wumii.com/site_images/2011/11/17/10979712.jpg" width="96px" height="96px" /><br />
                        <font size="-1" color="#333333" style="display: block !important; line-height: 15px !important; width: 102px !important; font: 12px/15px arial !important; height: 60px !important; margin: 3px 0 0 0 !important; padding: 0 !important; overflow: hidden !important;">css解决chrome 12px字号限制</font>
                    </a>
                </td>
                <td width="102" valign="top" style="padding: 5px !important; margin: 0 !important; border-left: 1px solid #DDDDDD !important;">
                    <a target="_blank" title="主流浏览器的CSS Hack方法整理" style="text-decoration: none !important; cursor: pointer !important;" href="http://app.wumii.com/ext/redirect?url=http%3A%2F%2Fjs8.in%2F382.html&from=http%3A%2F%2Fjs8.in%2F341.html">
                        <img style="margin: 0 !important; padding: 2px !important; border: 1px solid #DDDDDD !important; width: 96px !important; height: 96px !important;" src="http://static.wumii.com/site_images/2011/11/17/7942769.gif" width="96px" height="96px" /><br />
                        <font size="-1" color="#333333" style="display: block !important; line-height: 15px !important; width: 102px !important; font: 12px/15px arial !important; height: 60px !important; margin: 3px 0 0 0 !important; padding: 0 !important; overflow: hidden !important;">主流浏览器的CSS Hack方法整理</font>
                    </a>
                </td>
        </tr>
    
    <tr>
        <td colspan="4" align="right">
            <a style="text-decoration: none !important;" href="http://www.wumii.com/widget/relatedItems" target="_blank" title="无觅相关文章插件">
                <font size="-1" color="#bbbbbb" style="display: block !important; font-family: arial !important; padding: 5px 0 !important; font-size: 12px !important; color: #bbb !important;">无觅</font>
            </a>
        </td>
    </tr>
</table>]]></description>
			<content:encoded><![CDATA[<p>昨天我修改自己的<a href="http://js8.in/mywork/weather/">WordPress天气插件</a>的时候，发现一个比较有趣的问题：<strong>chrome</strong>竟然最小的字体是12px，而小于12px的数值，百分比之类的都不起左右，都是显示<strong>12px</strong>。<br />
对于这个问题，我上google搜索了半天也没有结果，本来因为是css出现了问题，测试了好多次都不行，于是最后来了个style=&#8221;font-size:10px&#8221;都没有显示成功，之后我写了一段代码在本地测试，还是不行，问了同事，同事都是表示不知道。<br />
后来是怀疑自己的html声明写错了，可是更换了标准声明还是不行，至今还是表示疑惑，找到了客户端设置chrome的方法，而没有css hack的方法没有找到，希望高手给个<strong>css hack</strong>解决的方法。<br />
WordPress天气预报插件地址：http://js8.in/mywork/weather<br />
demo地址：http://js8.in/mywork/weather/demo.php?city=0532<br />
<a href="http://js8.in/mywork/weather/" target="_blank"><img class="alignnone size-full wp-image-339" title="火狐下正常显示11px，布局正确" src="http://js8.in/wp-content/uploads/2009/11/Snap21.jpg" alt="火狐下正常显示11px，布局正确" width="198" height="253" /></a> <a href="http://js8.in/mywork/weather/" target="_blank"><img class="alignnone size-full wp-image-340" title="chrome下顶部日期显示的是12px" src="http://js8.in/wp-content/uploads/2009/11/Snap31.jpg" alt="chrome下顶部日期显示的是12px" width="201" height="253" /></a><br />
<h3>解决方法</h3>
<p><span id="more-341"></span>1.将chrome的界面语言改成英文,方法:扳手-选项-高级选项-更改字体和语言设置-语言-谷歌浏览器语言 将这里的改成英语(美国)之类<br />
2.<br />
<blockquote>Basically, the Chrome browser is based on WebKit. There are some webkit internal font setting options for font family, font size, etc.<br />
Using text editor to open &#8220;Documents and Settings\User_Name\Local Settings\Application Data\Google\Chrome\User Data\Default\Preferences&#8221;<br />
You will find the &#8220;webkit&#8221;: {  &#8220;webprefs&#8221;: { in the file. Those settings are for WebKit.<br />
In my setting example:<br />
   &#8220;webkit&#8221;: {<br />
      &#8220;webprefs&#8221;: {<br />
         &#8220;default_fixed_font_size&#8221;: 11,<br />
         &#8220;default_font_size&#8221;: 12,<br />
         &#8220;fixed_font_family&#8221;: &#8220;Bitstream Vera Sans Mono&#8221;,<br />
         &#8220;minimum_font_size&#8221;: 12,<br />
         &#8220;minimum_logical_font_siz&#8221;: 12,<br />
         &#8220;sansserif_font_family&#8221;: &#8220;Times New Roman&#8221;,<br />
         &#8220;serif_font_family&#8221;: &#8220;Arial&#8221;,<br />
         &#8220;standard_font_is_serif&#8221;: false,<br />
         &#8220;text_areas_are_resizable&#8221;: true<br />
      }<br />
   }<br />
The minimum_font_size and minimum_logical_font_size prevent Chrome to use very small font size for display.<br />
Remember to close Chrome first before you edit the file, or the file you saved will be overwritten by Chome after exiting.</p></blockquote>
<div class="copyright">
<strong>声明：</strong>文章未声明为原创文章，本文链接 <a href="http://js8.in/341.html" title="chrome字体最小值12px问题及解决方法">http://js8.in/341.html</a>. 转载请注明转自<a href="http://js8.in" title="前端开发博客"> JS8.IN ™</a></span></span></div>
<h3 class="box-title">随机文章</h3>
<ul class="box_random">
<li><a href="http://js8.in/538.html" title="javascript在光标位置插入内容" rel="bookmark inlinks">javascript在光标位置插入内容</a></li>
<li><a href="http://js8.in/311.html" title="关于Ajax在浏览器中产生前进后退的实现方法" rel="bookmark inlinks">关于Ajax在浏览器中产生前进后退的实现方法</a></li>
<li><a href="http://js8.in/632.html" title="网易推出LBS产品网易八方" rel="bookmark inlinks">网易推出LBS产品网易八方</a></li>
<li><a href="http://js8.in/337.html" title="jQuery浏览器判断一个bug，以及修改建议" rel="bookmark inlinks">jQuery浏览器判断一个bug，以及修改建议</a></li>
<li><a href="http://js8.in/665.html" title="委员们又闹笑话了" rel="bookmark inlinks">委员们又闹笑话了</a></li>
<li><a href="http://js8.in/600.html" title="jQuery教程之鼠标事件篇" rel="bookmark inlinks">jQuery教程之鼠标事件篇</a></li>
<li><a href="http://js8.in/15.html" title="奋斗了两天！" rel="bookmark inlinks">奋斗了两天！</a></li>
<li><a href="http://js8.in/689.html" title="NodeList集合跟Array数组的区别" rel="bookmark inlinks">NodeList集合跟Array数组的区别</a></li>
</ul>
<p style="margin:0;padding:0;height:1px;overflow:hidden;">
    <script type="text/javascript"><!--
        var wumiiSitePrefix = "http://js8.in";
        var wumiiEnableCustomPos = false;
        var wumiiParams = "&#038;num=4&#038;mode=3&#038;displayInFeed=1&#038;version=1.0.5.5&#038;pf=WordPress2.8.6";
    //--></script></p>
<hr />
<p><small>© 三水清 for <a href="http://js8.in">三水清</a>, 2009. |
<a href="http://js8.in/341.html#comments">18 comments</a> |在微博关注我：<a href="//weibo.com/sanshuiqing" target="_blank" title="关注断桥残雪的新浪微博">@清-三水清</a>
<br/>收藏到：
<a rel="nofollow" href="http://share.renren.com/share/buttonshare.do?link=%posturl%&title=%posttitle%" title="收藏本文到人人网" target="_blank">人人网</a> | <a rel="nofollow" href="http://www.douban.com/recommend/?url=%posturl%&title=%posttitle%" title="收藏本文到豆瓣" target="_blank">豆瓣</a> | <a rel="nofollow" href="http://www.kaixin001.com/repaste/share.php?rtitle=%posttitle%&rurl=%posturl%" title="收藏本文到开心网" target="_blank">开心网</a> | <a rel="nofollow" href="http://shuqian.qq.com/post?title=%posttitle%&%20uri=%posturl%" title="收藏本文到QQ书签" target="_blank">QQ书签</a> | <a rel="nofollow" href="http://v.t.sina.com.cn/share/share.php?url=%posturl%&title=%posttitle%" title="收藏本文到新浪微博" target="_blank">新浪微博</a> | <a rel="nofollow" href="http://v.t.qq.com/share/share.php?title=%posttitle%&url=%posturl%&site=http://www.kaixin100.info" title="收藏本文到腾讯微博" target="_blank">腾讯微博</a>
<br/>
Post tags: <a href="http://js8.in/tag/chrome" rel="tag">chrome</a>, <a href="http://js8.in/tag/css-hack" rel="tag">css hack</a>, <a href="http://js8.in/tag/wordpress" rel="tag">wordpress</a><br/>
</small></p><table class="wumii-related-items" cellspacing="0" cellpadding="3" border="0"  style="clear: both;">
    
    <tr>
        <td colspan="4"><b><font size="-1"  style="display: block !important; padding: 20px 0 5px !important;">猜你喜欢：</font></b></td>
    </tr>
    
        <tr>
                <td width="102" valign="top" style="padding: 5px !important; margin: 0 !important;">
                    <a target="_blank" title="Opera Chrome Safari浏览器的CSS Hack方法" style="text-decoration: none !important; cursor: pointer !important;" href="http://app.wumii.com/ext/redirect?url=http%3A%2F%2Fjs8.in%2F397.html&from=http%3A%2F%2Fjs8.in%2F341.html">
                        <img style="margin: 0 !important; padding: 2px !important; border: 1px solid #DDDDDD !important; width: 96px !important; height: 96px !important;" src="http://static.wumii.com/site_images/2011/06/11/11779216.jpg" width="96px" height="96px" /><br />
                        <font size="-1" color="#333333" style="display: block !important; line-height: 15px !important; width: 102px !important; font: 12px/15px arial !important; height: 60px !important; margin: 3px 0 0 0 !important; padding: 0 !important; overflow: hidden !important;">Opera Chrome Safari浏览器的CSS Hack方法</font>
                    </a>
                </td>
                <td width="102" valign="top" style="padding: 5px !important; margin: 0 !important; border-left: 1px solid #DDDDDD !important;">
                    <a target="_blank" title="使用if IE hack注释解决CSS以及JS的兼容问题" style="text-decoration: none !important; cursor: pointer !important;" href="http://app.wumii.com/ext/redirect?url=http%3A%2F%2Fjs8.in%2F381.html&from=http%3A%2F%2Fjs8.in%2F341.html">
                        <img style="margin: 0 !important; padding: 2px !important; border: 1px solid #DDDDDD !important; width: 96px !important; height: 96px !important;" src="http://static.wumii.com/site_images/2011/11/17/10979211.gif" width="96px" height="96px" /><br />
                        <font size="-1" color="#333333" style="display: block !important; line-height: 15px !important; width: 102px !important; font: 12px/15px arial !important; height: 60px !important; margin: 3px 0 0 0 !important; padding: 0 !important; overflow: hidden !important;">使用if IE hack注释解决CSS以及JS的兼容问题</font>
                    </a>
                </td>
                <td width="102" valign="top" style="padding: 5px !important; margin: 0 !important; border-left: 1px solid #DDDDDD !important;">
                    <a target="_blank" title="css解决chrome 12px字号限制" style="text-decoration: none !important; cursor: pointer !important;" href="http://app.wumii.com/ext/redirect?url=http%3A%2F%2Fjs8.in%2F625.html&from=http%3A%2F%2Fjs8.in%2F341.html">
                        <img style="margin: 0 !important; padding: 2px !important; border: 1px solid #DDDDDD !important; width: 96px !important; height: 96px !important;" src="http://static.wumii.com/site_images/2011/11/17/10979712.jpg" width="96px" height="96px" /><br />
                        <font size="-1" color="#333333" style="display: block !important; line-height: 15px !important; width: 102px !important; font: 12px/15px arial !important; height: 60px !important; margin: 3px 0 0 0 !important; padding: 0 !important; overflow: hidden !important;">css解决chrome 12px字号限制</font>
                    </a>
                </td>
                <td width="102" valign="top" style="padding: 5px !important; margin: 0 !important; border-left: 1px solid #DDDDDD !important;">
                    <a target="_blank" title="主流浏览器的CSS Hack方法整理" style="text-decoration: none !important; cursor: pointer !important;" href="http://app.wumii.com/ext/redirect?url=http%3A%2F%2Fjs8.in%2F382.html&from=http%3A%2F%2Fjs8.in%2F341.html">
                        <img style="margin: 0 !important; padding: 2px !important; border: 1px solid #DDDDDD !important; width: 96px !important; height: 96px !important;" src="http://static.wumii.com/site_images/2011/11/17/7942769.gif" width="96px" height="96px" /><br />
                        <font size="-1" color="#333333" style="display: block !important; line-height: 15px !important; width: 102px !important; font: 12px/15px arial !important; height: 60px !important; margin: 3px 0 0 0 !important; padding: 0 !important; overflow: hidden !important;">主流浏览器的CSS Hack方法整理</font>
                    </a>
                </td>
        </tr>
    
    <tr>
        <td colspan="4" align="right">
            <a style="text-decoration: none !important;" href="http://www.wumii.com/widget/relatedItems" target="_blank" title="无觅相关文章插件">
                <font size="-1" color="#bbbbbb" style="display: block !important; font-family: arial !important; padding: 5px 0 !important; font-size: 12px !important; color: #bbb !important;">无觅</font>
            </a>
        </td>
    </tr>
</table>]]></content:encoded>
			<wfw:commentRss>http://js8.in/341.html/feed</wfw:commentRss>
		<slash:comments>18</slash:comments>
		</item>
	</channel>
</rss>

