﻿<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:trackback="http://madskills.com/public/xml/rss/module/trackback/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/"><channel><title>BlogJava-xiaomage234-随笔分类-page</title><link>http://www.blogjava.net/xiaomage234/category/35357.html</link><description>生命本就是一次凄美的漂流，记忆中放不下的，永远是孩提时代的那一份浪漫与纯真！</description><language>zh-cn</language><lastBuildDate>Wed, 13 Apr 2016 18:26:54 GMT</lastBuildDate><pubDate>Wed, 13 Apr 2016 18:26:54 GMT</pubDate><ttl>60</ttl><item><title>Jquery Ajax和getJSON获取后台普通Json数据和层级Json数据解析</title><link>http://www.blogjava.net/xiaomage234/archive/2016/04/13/430074.html</link><dc:creator>小马歌</dc:creator><author>小马歌</author><pubDate>Wed, 13 Apr 2016 05:47:00 GMT</pubDate><guid>http://www.blogjava.net/xiaomage234/archive/2016/04/13/430074.html</guid><wfw:comment>http://www.blogjava.net/xiaomage234/comments/430074.html</wfw:comment><comments>http://www.blogjava.net/xiaomage234/archive/2016/04/13/430074.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/xiaomage234/comments/commentRss/430074.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/xiaomage234/services/trackbacks/430074.html</trackback:ping><description><![CDATA[&nbsp;&nbsp;&nbsp;&nbsp; 摘要: from:http://blog.csdn.net/smartsmile2012/article/details/17316351版权声明：本文为博主原创文章，未经博主允许不得转载。[html]&nbsp;view plain&nbsp;copy&nbsp;print?&lt;!DOCTYPE&nbsp;html&nbsp;PUBLIC&nbsp;"-//W3C//DTD&nbsp;XHTML&n...&nbsp;&nbsp;<a href='http://www.blogjava.net/xiaomage234/archive/2016/04/13/430074.html'>阅读全文</a><img src ="http://www.blogjava.net/xiaomage234/aggbug/430074.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/xiaomage234/" target="_blank">小马歌</a> 2016-04-13 13:47 <a href="http://www.blogjava.net/xiaomage234/archive/2016/04/13/430074.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>JQuery的Deferred对象详解</title><link>http://www.blogjava.net/xiaomage234/archive/2011/12/23/367084.html</link><dc:creator>小马歌</dc:creator><author>小马歌</author><pubDate>Fri, 23 Dec 2011 10:06:00 GMT</pubDate><guid>http://www.blogjava.net/xiaomage234/archive/2011/12/23/367084.html</guid><wfw:comment>http://www.blogjava.net/xiaomage234/comments/367084.html</wfw:comment><comments>http://www.blogjava.net/xiaomage234/archive/2011/12/23/367084.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/xiaomage234/comments/commentRss/367084.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/xiaomage234/services/trackbacks/367084.html</trackback:ping><description><![CDATA[&nbsp;&nbsp;&nbsp;&nbsp; 摘要: 作者：&nbsp;阮一峰日期：&nbsp;2011年8月16日jQuery的开发速度很快，几乎每半年一个大版本，每两个月一个小版本。每个版本都会引入一些新功能。今天我想介绍的，就是从jQuery 1.5.0版本开始引入的一个新功能----deferred对象。这个功能很重要，未来将成为jQuery的核心方法，它彻底改变了如何在jQuery中使用ajax。为了实现它，jQuery的全部ajax代码都...&nbsp;&nbsp;<a href='http://www.blogjava.net/xiaomage234/archive/2011/12/23/367084.html'>阅读全文</a><img src ="http://www.blogjava.net/xiaomage234/aggbug/367084.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/xiaomage234/" target="_blank">小马歌</a> 2011-12-23 18:06 <a href="http://www.blogjava.net/xiaomage234/archive/2011/12/23/367084.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>ymPrompt消息提示组件4.0版DEMO演示</title><link>http://www.blogjava.net/xiaomage234/archive/2011/12/23/367064.html</link><dc:creator>小马歌</dc:creator><author>小马歌</author><pubDate>Fri, 23 Dec 2011 06:37:00 GMT</pubDate><guid>http://www.blogjava.net/xiaomage234/archive/2011/12/23/367064.html</guid><wfw:comment>http://www.blogjava.net/xiaomage234/comments/367064.html</wfw:comment><comments>http://www.blogjava.net/xiaomage234/archive/2011/12/23/367064.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/xiaomage234/comments/commentRss/367064.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/xiaomage234/services/trackbacks/367064.html</trackback:ping><description><![CDATA[from :&nbsp;<a href="http://www.rainweb.cn/JavaScript/message-alert/demo.html">http://www.rainweb.cn/JavaScript/message-alert/demo.html<br /><br /></a><div><h1>ymPrompt消息提示组件4.0版DEMO演示</h1><h3>页面IFRAME:</h3><span style="font-family: Simsun; line-height: normal; font-size: medium; "><iframe src="http://www.rainweb.cn/JavaScript/message-alert/iframe.html" width="100%" height="60"></iframe></span><span style="font-family: Simsun; line-height: normal; font-size: medium; "><br /></span><table width="100%" style="font-family: Simsun; line-height: normal; font-size: medium; "><tbody><tr><td><h3>页面文本:</h3>页面文本1<br />页面文本2</td><td><h3>页面Select选择框</h3><select>&nbsp;		<option>下拉选项1</option>&nbsp;		<option>下拉选项2</option>&nbsp;		<option>下拉选项3</option>&nbsp;	</select></td></tr></tbody></table><hr style="font-family: Simsun; line-height: normal; font-size: medium; " /><span style="font-family: Simsun; line-height: normal; font-size: medium; "><strong>更换皮肤：</strong></span><span style="font-family: Simsun; line-height: normal; font-size: medium; "><select id="chgSkin">&nbsp;		<option value="qq">QQ</option>&nbsp;		<option value="vista">VISTA</option>&nbsp;		<option value="dmm-green">dmm-Green</option>&nbsp;		<option value="bluebar">bluebar</option>&nbsp;		<option value="black">black</option>&nbsp;	</select></span><span style="font-family: Simsun; line-height: normal; font-size: medium; ">&nbsp;&nbsp;</span><span style="font-family: Simsun; line-height: normal; font-size: medium; "><strong>修改默认配置：</strong></span><span style="font-family: Simsun; line-height: normal; font-size: medium; ">遮罩颜色：</span><span style="font-family: Simsun; line-height: normal; font-size: medium; "><input type="text" value="#00f" id="c0" /></span><span style="font-family: Simsun; line-height: normal; font-size: medium; ">&nbsp;遮罩透明度:</span><span style="font-family: Simsun; line-height: normal; font-size: medium; "><input id="c1" type="text" value="0.1" /></span>&nbsp;<span style="font-family: Simsun; line-height: normal; font-size: medium; "><input type="button" value="修改默认配置" /></span><hr style="font-family: Simsun; line-height: normal; font-size: medium; " /><table width="100%" cellpadding="3" cellspacing="0" style="border-collapse: collapse; border-top-width: 1px; border-right-width: 1px; border-bottom-width: 1px; border-left-width: 1px; border-top-style: solid; border-right-style: solid; border-bottom-style: solid; border-left-style: solid; border-top-color: #999999; border-right-color: #999999; border-bottom-color: #999999; border-left-color: #999999; margin-top: 5px; margin-right: 0px; margin-bottom: 5px; margin-left: 0px; font-family: Simsun; line-height: normal; font-size: medium; "><caption style="background-image: initial; background-attachment: initial; background-origin: initial; background-clip: initial; background-color: #eeeeee; line-height: 30px; border-top-width: 1px; border-right-width: 1px; border-bottom-width: 1px; border-left-width: 1px; border-top-style: solid; border-right-style: solid; border-bottom-style: solid; border-left-style: solid; border-top-color: #999999; border-right-color: #999999; border-bottom-color: #999999; border-left-color: #999999; font-weight: bold; background-position: initial initial; background-repeat: initial initial; ">组件调用方式1(传统参数传入方式)：</caption><tbody><tr align="center"><th width="150" style="border-top-width: 1px; border-right-width: 1px; border-bottom-width: 1px; border-left-width: 1px; border-top-style: solid; border-right-style: solid; border-bottom-style: solid; border-left-style: solid; border-top-color: #999999; border-right-color: #999999; border-bottom-color: #999999; border-left-color: #999999; text-align: center; line-height: 22px; ">示例</th><th style="border-top-width: 1px; border-right-width: 1px; border-bottom-width: 1px; border-left-width: 1px; border-top-style: solid; border-right-style: solid; border-bottom-style: solid; border-left-style: solid; border-top-color: #999999; border-right-color: #999999; border-bottom-color: #999999; border-left-color: #999999; text-align: center; line-height: 22px; ">调用方法</th></tr><tr><td style="border-top-width: 1px; border-right-width: 1px; border-bottom-width: 1px; border-left-width: 1px; border-top-style: solid; border-right-style: solid; border-bottom-style: solid; border-left-style: solid; border-top-color: #999999; border-right-color: #999999; border-bottom-color: #999999; border-left-color: #999999; text-align: right; "><input type="button" value="信息提示" /></td><td style="border-top-width: 1px; border-right-width: 1px; border-bottom-width: 1px; border-left-width: 1px; border-top-style: solid; border-right-style: solid; border-bottom-style: solid; border-left-style: solid; border-top-color: #999999; border-right-color: #999999; border-bottom-color: #999999; border-left-color: #999999; text-align: left; background-image: initial; background-attachment: initial; background-origin: initial; background-clip: initial; background-color: #eeeeee; font-family: 'Courier New'; line-height: 20px; font-size: 12px; background-position: initial initial; background-repeat: initial initial; ">ymPrompt.alert('http://www.qq.com',null,null,'确认要提交吗?',handler)</td></tr><tr><td style="border-top-width: 1px; border-right-width: 1px; border-bottom-width: 1px; border-left-width: 1px; border-top-style: solid; border-right-style: solid; border-bottom-style: solid; border-left-style: solid; border-top-color: #999999; border-right-color: #999999; border-bottom-color: #999999; border-left-color: #999999; text-align: right; "><input type="button" id="b2" value="成功信息" /></td><td style="border-top-width: 1px; border-right-width: 1px; border-bottom-width: 1px; border-left-width: 1px; border-top-style: solid; border-right-style: solid; border-bottom-style: solid; border-left-style: solid; border-top-color: #999999; border-right-color: #999999; border-bottom-color: #999999; border-left-color: #999999; text-align: left; background-image: initial; background-attachment: initial; background-origin: initial; background-clip: initial; background-color: #eeeeee; font-family: 'Courier New'; line-height: 20px; font-size: 12px; background-position: initial initial; background-repeat: initial initial; ">ymPrompt.succeedInfo(document.getElementById('text').innerHTML,400,260,null,handler2)</td></tr><tr><td style="border-top-width: 1px; border-right-width: 1px; border-bottom-width: 1px; border-left-width: 1px; border-top-style: solid; border-right-style: solid; border-bottom-style: solid; border-left-style: solid; border-top-color: #999999; border-right-color: #999999; border-bottom-color: #999999; border-left-color: #999999; text-align: right; "><input type="button" value="失败信息" /></td><td style="border-top-width: 1px; border-right-width: 1px; border-bottom-width: 1px; border-left-width: 1px; border-top-style: solid; border-right-style: solid; border-bottom-style: solid; border-left-style: solid; border-top-color: #999999; border-right-color: #999999; border-bottom-color: #999999; border-left-color: #999999; text-align: left; background-image: initial; background-attachment: initial; background-origin: initial; background-clip: initial; background-color: #eeeeee; font-family: 'Courier New'; line-height: 20px; font-size: 12px; background-position: initial initial; background-repeat: initial initial; ">ymPrompt.errorInfo('操作失败！',null,null,null,handler)</td></tr><tr><td style="border-top-width: 1px; border-right-width: 1px; border-bottom-width: 1px; border-left-width: 1px; border-top-style: solid; border-right-style: solid; border-bottom-style: solid; border-left-style: solid; border-top-color: #999999; border-right-color: #999999; border-bottom-color: #999999; border-left-color: #999999; text-align: right; "><input type="button" value="询问信息" /></td><td style="border-top-width: 1px; border-right-width: 1px; border-bottom-width: 1px; border-left-width: 1px; border-top-style: solid; border-right-style: solid; border-bottom-style: solid; border-left-style: solid; border-top-color: #999999; border-right-color: #999999; border-bottom-color: #999999; border-left-color: #999999; text-align: left; background-image: initial; background-attachment: initial; background-origin: initial; background-clip: initial; background-color: #eeeeee; font-family: 'Courier New'; line-height: 20px; font-size: 12px; background-position: initial initial; background-repeat: initial initial; ">ymPrompt.confirmInfo('信息确认框功能测试',null,null,null,handler)</td></tr><tr><td style="border-top-width: 1px; border-right-width: 1px; border-bottom-width: 1px; border-left-width: 1px; border-top-style: solid; border-right-style: solid; border-bottom-style: solid; border-left-style: solid; border-top-color: #999999; border-right-color: #999999; border-bottom-color: #999999; border-left-color: #999999; text-align: right; "><input type="button" value="普通弹窗" /></td><td style="border-top-width: 1px; border-right-width: 1px; border-bottom-width: 1px; border-left-width: 1px; border-top-style: solid; border-right-style: solid; border-bottom-style: solid; border-left-style: solid; border-top-color: #999999; border-right-color: #999999; border-bottom-color: #999999; border-left-color: #999999; text-align: left; background-image: initial; background-attachment: initial; background-origin: initial; background-clip: initial; background-color: #eeeeee; font-family: 'Courier New'; line-height: 20px; font-size: 12px; background-position: initial initial; background-repeat: initial initial; ">ymPrompt.win('&lt;div class=\'myContent\'&gt;普通弹出窗口&lt;/div&gt;',300,200,'普通弹窗测试')</td></tr><tr><td style="border-top-width: 1px; border-right-width: 1px; border-bottom-width: 1px; border-left-width: 1px; border-top-style: solid; border-right-style: solid; border-bottom-style: solid; border-left-style: solid; border-top-color: #999999; border-right-color: #999999; border-bottom-color: #999999; border-left-color: #999999; text-align: right; "><input type="button" value="iframe弹窗" /></td><td style="border-top-width: 1px; border-right-width: 1px; border-bottom-width: 1px; border-left-width: 1px; border-top-style: solid; border-right-style: solid; border-bottom-style: solid; border-left-style: solid; border-top-color: #999999; border-right-color: #999999; border-bottom-color: #999999; border-left-color: #999999; text-align: left; background-image: initial; background-attachment: initial; background-origin: initial; background-clip: initial; background-color: #eeeeee; font-family: 'Courier New'; line-height: 20px; font-size: 12px; background-position: initial initial; background-repeat: initial initial; ">ymPrompt.win('http://www.qq.com',500,300,'腾讯QQ官方网站',handler,null,null,true)</td></tr></tbody></table><table width="100%" cellpadding="3" cellspacing="0" style="border-collapse: collapse; border-top-width: 1px; border-right-width: 1px; border-bottom-width: 1px; border-left-width: 1px; border-top-style: solid; border-right-style: solid; border-bottom-style: solid; border-left-style: solid; border-top-color: #999999; border-right-color: #999999; border-bottom-color: #999999; border-left-color: #999999; margin-top: 5px; margin-right: 0px; margin-bottom: 5px; margin-left: 0px; font-family: Simsun; line-height: normal; font-size: medium; "><caption style="background-image: initial; background-attachment: initial; background-origin: initial; background-clip: initial; background-color: #eeeeee; line-height: 30px; border-top-width: 1px; border-right-width: 1px; border-bottom-width: 1px; border-left-width: 1px; border-top-style: solid; border-right-style: solid; border-bottom-style: solid; border-left-style: solid; border-top-color: #999999; border-right-color: #999999; border-bottom-color: #999999; border-left-color: #999999; font-weight: bold; background-position: initial initial; background-repeat: initial initial; ">组件调用方式2(JSON方式)：</caption><tbody><tr align="center"><th width="150" style="border-top-width: 1px; border-right-width: 1px; border-bottom-width: 1px; border-left-width: 1px; border-top-style: solid; border-right-style: solid; border-bottom-style: solid; border-left-style: solid; border-top-color: #999999; border-right-color: #999999; border-bottom-color: #999999; border-left-color: #999999; text-align: center; line-height: 22px; ">示例</th><th style="border-top-width: 1px; border-right-width: 1px; border-bottom-width: 1px; border-left-width: 1px; border-top-style: solid; border-right-style: solid; border-bottom-style: solid; border-left-style: solid; border-top-color: #999999; border-right-color: #999999; border-bottom-color: #999999; border-left-color: #999999; text-align: center; line-height: 22px; ">源码</th></tr><tr><td style="border-top-width: 1px; border-right-width: 1px; border-bottom-width: 1px; border-left-width: 1px; border-top-style: solid; border-right-style: solid; border-bottom-style: solid; border-left-style: solid; border-top-color: #999999; border-right-color: #999999; border-bottom-color: #999999; border-left-color: #999999; text-align: right; "><input type="button" value="信息提示" /></td><td style="border-top-width: 1px; border-right-width: 1px; border-bottom-width: 1px; border-left-width: 1px; border-top-style: solid; border-right-style: solid; border-bottom-style: solid; border-left-style: solid; border-top-color: #999999; border-right-color: #999999; border-bottom-color: #999999; border-left-color: #999999; text-align: left; background-image: initial; background-attachment: initial; background-origin: initial; background-clip: initial; background-color: #eeeeee; font-family: 'Courier New'; line-height: 20px; font-size: 12px; background-position: initial initial; background-repeat: initial initial; ">ymPrompt.alert({message:'http://www.qq.com',title:'确认要提交吗?',handler:handler})</td></tr><tr><td style="border-top-width: 1px; border-right-width: 1px; border-bottom-width: 1px; border-left-width: 1px; border-top-style: solid; border-right-style: solid; border-bottom-style: solid; border-left-style: solid; border-top-color: #999999; border-right-color: #999999; border-bottom-color: #999999; border-left-color: #999999; text-align: right; "><input type="button" value="信息提示" /></td><td style="border-top-width: 1px; border-right-width: 1px; border-bottom-width: 1px; border-left-width: 1px; border-top-style: solid; border-right-style: solid; border-bottom-style: solid; border-left-style: solid; border-top-color: #999999; border-right-color: #999999; border-bottom-color: #999999; border-left-color: #999999; text-align: left; background-image: initial; background-attachment: initial; background-origin: initial; background-clip: initial; background-color: #eeeeee; font-family: 'Courier New'; line-height: 20px; font-size: 12px; background-position: initial initial; background-repeat: initial initial; ">ymPrompt.alert({message:'http://www.qq.com',title:'确认要提交吗?',handler:handler})</td></tr><tr><td style="border-top-width: 1px; border-right-width: 1px; border-bottom-width: 1px; border-left-width: 1px; border-top-style: solid; border-right-style: solid; border-bottom-style: solid; border-left-style: solid; border-top-color: #999999; border-right-color: #999999; border-bottom-color: #999999; border-left-color: #999999; text-align: right; "><input type="button" value="成功信息" /></td><td style="border-top-width: 1px; border-right-width: 1px; border-bottom-width: 1px; border-left-width: 1px; border-top-style: solid; border-right-style: solid; border-bottom-style: solid; border-left-style: solid; border-top-color: #999999; border-right-color: #999999; border-bottom-color: #999999; border-left-color: #999999; text-align: left; background-image: initial; background-attachment: initial; background-origin: initial; background-clip: initial; background-color: #eeeeee; font-family: 'Courier New'; line-height: 20px; font-size: 12px; background-position: initial initial; background-repeat: initial initial; ">ymPrompt.succeedInfo({message:'&lt;br /&gt;&lt;br /&gt;当前版本号：'+ymPrompt.version+'&lt;br /&gt;发布日期：'+ymPrompt.pubDate,width:400,height:260,handler:handler2})</td></tr><tr><td style="border-top-width: 1px; border-right-width: 1px; border-bottom-width: 1px; border-left-width: 1px; border-top-style: solid; border-right-style: solid; border-bottom-style: solid; border-left-style: solid; border-top-color: #999999; border-right-color: #999999; border-bottom-color: #999999; border-left-color: #999999; text-align: right; "><input type="button" value="失败信息" /></td><td style="border-top-width: 1px; border-right-width: 1px; border-bottom-width: 1px; border-left-width: 1px; border-top-style: solid; border-right-style: solid; border-bottom-style: solid; border-left-style: solid; border-top-color: #999999; border-right-color: #999999; border-bottom-color: #999999; border-left-color: #999999; text-align: left; background-image: initial; background-attachment: initial; background-origin: initial; background-clip: initial; background-color: #eeeeee; font-family: 'Courier New'; line-height: 20px; font-size: 12px; background-position: initial initial; background-repeat: initial initial; ">ymPrompt.errorInfo({message:'操作失败！',handler:handler})</td></tr><tr><td style="border-top-width: 1px; border-right-width: 1px; border-bottom-width: 1px; border-left-width: 1px; border-top-style: solid; border-right-style: solid; border-bottom-style: solid; border-left-style: solid; border-top-color: #999999; border-right-color: #999999; border-bottom-color: #999999; border-left-color: #999999; text-align: right; "><input type="button" value="询问信息" /></td><td style="border-top-width: 1px; border-right-width: 1px; border-bottom-width: 1px; border-left-width: 1px; border-top-style: solid; border-right-style: solid; border-bottom-style: solid; border-left-style: solid; border-top-color: #999999; border-right-color: #999999; border-bottom-color: #999999; border-left-color: #999999; text-align: left; background-image: initial; background-attachment: initial; background-origin: initial; background-clip: initial; background-color: #eeeeee; font-family: 'Courier New'; line-height: 20px; font-size: 12px; background-position: initial initial; background-repeat: initial initial; ">ymPrompt.confirmInfo({message:'信息确认框功能测试',handler:handler})</td></tr><tr><td style="border-top-width: 1px; border-right-width: 1px; border-bottom-width: 1px; border-left-width: 1px; border-top-style: solid; border-right-style: solid; border-bottom-style: solid; border-left-style: solid; border-top-color: #999999; border-right-color: #999999; border-bottom-color: #999999; border-left-color: #999999; text-align: right; "><input type="button" value="普通弹窗" /></td><td style="border-top-width: 1px; border-right-width: 1px; border-bottom-width: 1px; border-left-width: 1px; border-top-style: solid; border-right-style: solid; border-bottom-style: solid; border-left-style: solid; border-top-color: #999999; border-right-color: #999999; border-bottom-color: #999999; border-left-color: #999999; text-align: left; background-image: initial; background-attachment: initial; background-origin: initial; background-clip: initial; background-color: #eeeeee; font-family: 'Courier New'; line-height: 20px; font-size: 12px; background-position: initial initial; background-repeat: initial initial; ">ymPrompt.win({message:'&lt;div class=\'myContent\'&gt;普通弹出窗口&lt;/div&gt;',width:300,height:200,title:'普通弹窗测试'})</td></tr><tr><td style="border-top-width: 1px; border-right-width: 1px; border-bottom-width: 1px; border-left-width: 1px; border-top-style: solid; border-right-style: solid; border-bottom-style: solid; border-left-style: solid; border-top-color: #999999; border-right-color: #999999; border-bottom-color: #999999; border-left-color: #999999; text-align: right; "><input type="button" value="iframe弹窗" /></td><td style="border-top-width: 1px; border-right-width: 1px; border-bottom-width: 1px; border-left-width: 1px; border-top-style: solid; border-right-style: solid; border-bottom-style: solid; border-left-style: solid; border-top-color: #999999; border-right-color: #999999; border-bottom-color: #999999; border-left-color: #999999; text-align: left; background-image: initial; background-attachment: initial; background-origin: initial; background-clip: initial; background-color: #eeeeee; font-family: 'Courier New'; line-height: 20px; font-size: 12px; background-position: initial initial; background-repeat: initial initial; ">ymPrompt.win({message:'http://www.qq.com',width:500,height:300,title:'腾讯QQ官方网站',handler:handler,iframe:true})</td></tr></tbody></table><table width="100%" cellpadding="3" cellspacing="0" style="border-collapse: collapse; border-top-width: 1px; border-right-width: 1px; border-bottom-width: 1px; border-left-width: 1px; border-top-style: solid; border-right-style: solid; border-bottom-style: solid; border-left-style: solid; border-top-color: #999999; border-right-color: #999999; border-bottom-color: #999999; border-left-color: #999999; margin-top: 5px; margin-right: 0px; margin-bottom: 5px; margin-left: 0px; font-family: Simsun; line-height: normal; font-size: medium; "><caption style="background-image: initial; background-attachment: initial; background-origin: initial; background-clip: initial; background-color: #eeeeee; line-height: 30px; border-top-width: 1px; border-right-width: 1px; border-bottom-width: 1px; border-left-width: 1px; border-top-style: solid; border-right-style: solid; border-bottom-style: solid; border-left-style: solid; border-top-color: #999999; border-right-color: #999999; border-bottom-color: #999999; border-left-color: #999999; font-weight: bold; background-position: initial initial; background-repeat: initial initial; ">其他使用方式演示：</caption><tbody><tr align="center"><th width="150" style="border-top-width: 1px; border-right-width: 1px; border-bottom-width: 1px; border-left-width: 1px; border-top-style: solid; border-right-style: solid; border-bottom-style: solid; border-left-style: solid; border-top-color: #999999; border-right-color: #999999; border-bottom-color: #999999; border-left-color: #999999; text-align: center; line-height: 22px; ">示例</th><th style="border-top-width: 1px; border-right-width: 1px; border-bottom-width: 1px; border-left-width: 1px; border-top-style: solid; border-right-style: solid; border-bottom-style: solid; border-left-style: solid; border-top-color: #999999; border-right-color: #999999; border-bottom-color: #999999; border-left-color: #999999; text-align: center; line-height: 22px; ">源码</th></tr><tr><td style="border-top-width: 1px; border-right-width: 1px; border-bottom-width: 1px; border-left-width: 1px; border-top-style: solid; border-right-style: solid; border-bottom-style: solid; border-left-style: solid; border-top-color: #999999; border-right-color: #999999; border-bottom-color: #999999; border-left-color: #999999; text-align: right; "><input type="button" value="最简调用1" /></td><td style="border-top-width: 1px; border-right-width: 1px; border-bottom-width: 1px; border-left-width: 1px; border-top-style: solid; border-right-style: solid; border-bottom-style: solid; border-left-style: solid; border-top-color: #999999; border-right-color: #999999; border-bottom-color: #999999; border-left-color: #999999; text-align: left; background-image: initial; background-attachment: initial; background-origin: initial; background-clip: initial; background-color: #eeeeee; font-family: 'Courier New'; line-height: 20px; font-size: 12px; background-position: initial initial; background-repeat: initial initial; ">ymPrompt.alert()</td></tr><tr><td style="border-top-width: 1px; border-right-width: 1px; border-bottom-width: 1px; border-left-width: 1px; border-top-style: solid; border-right-style: solid; border-bottom-style: solid; border-left-style: solid; border-top-color: #999999; border-right-color: #999999; border-bottom-color: #999999; border-left-color: #999999; text-align: right; "><input type="button" value="最简调用2" /></td><td style="border-top-width: 1px; border-right-width: 1px; border-bottom-width: 1px; border-left-width: 1px; border-top-style: solid; border-right-style: solid; border-bottom-style: solid; border-left-style: solid; border-top-color: #999999; border-right-color: #999999; border-bottom-color: #999999; border-left-color: #999999; text-align: left; background-image: initial; background-attachment: initial; background-origin: initial; background-clip: initial; background-color: #eeeeee; font-family: 'Courier New'; line-height: 20px; font-size: 12px; background-position: initial initial; background-repeat: initial initial; ">ymPrompt.alert('消息内容')</td></tr><tr><td style="border-top-width: 1px; border-right-width: 1px; border-bottom-width: 1px; border-left-width: 1px; border-top-style: solid; border-right-style: solid; border-bottom-style: solid; border-left-style: solid; border-top-color: #999999; border-right-color: #999999; border-bottom-color: #999999; border-left-color: #999999; text-align: right; "><input type="button" value="设置消息和标题" /></td><td style="border-top-width: 1px; border-right-width: 1px; border-bottom-width: 1px; border-left-width: 1px; border-top-style: solid; border-right-style: solid; border-bottom-style: solid; border-left-style: solid; border-top-color: #999999; border-right-color: #999999; border-bottom-color: #999999; border-left-color: #999999; text-align: left; background-image: initial; background-attachment: initial; background-origin: initial; background-clip: initial; background-color: #eeeeee; font-family: 'Courier New'; line-height: 20px; font-size: 12px; background-position: initial initial; background-repeat: initial initial; ">ymPrompt.alert({title:'我的标题',message:'我的内容'})</td></tr><tr><td style="border-top-width: 1px; border-right-width: 1px; border-bottom-width: 1px; border-left-width: 1px; border-top-style: solid; border-right-style: solid; border-bottom-style: solid; border-left-style: solid; border-top-color: #999999; border-right-color: #999999; border-bottom-color: #999999; border-left-color: #999999; text-align: right; "><input type="button" value="随滚动条滚动" /></td><td style="border-top-width: 1px; border-right-width: 1px; border-bottom-width: 1px; border-left-width: 1px; border-top-style: solid; border-right-style: solid; border-bottom-style: solid; border-left-style: solid; border-top-color: #999999; border-right-color: #999999; border-bottom-color: #999999; border-left-color: #999999; text-align: left; background-image: initial; background-attachment: initial; background-origin: initial; background-clip: initial; background-color: #eeeeee; font-family: 'Courier New'; line-height: 20px; font-size: 12px; background-position: initial initial; background-repeat: initial initial; ">ymPrompt.alert({title:'fixPosition使用演示',message:'我会随滚动条一起滚动',fixPosition:true})</td></tr><tr><td style="border-top-width: 1px; border-right-width: 1px; border-bottom-width: 1px; border-left-width: 1px; border-top-style: solid; border-right-style: solid; border-bottom-style: solid; border-left-style: solid; border-top-color: #999999; border-right-color: #999999; border-bottom-color: #999999; border-left-color: #999999; text-align: right; "><input type="button" value="在窗口内拖动" /></td><td style="border-top-width: 1px; border-right-width: 1px; border-bottom-width: 1px; border-left-width: 1px; border-top-style: solid; border-right-style: solid; border-bottom-style: solid; border-left-style: solid; border-top-color: #999999; border-right-color: #999999; border-bottom-color: #999999; border-left-color: #999999; text-align: left; background-image: initial; background-attachment: initial; background-origin: initial; background-clip: initial; background-color: #eeeeee; font-family: 'Courier New'; line-height: 20px; font-size: 12px; background-position: initial initial; background-repeat: initial initial; ">ymPrompt.alert({title:'dragOut使用演示',message:'我不能拖出到窗口可见区域以外',dragOut:false})</td></tr><tr><td style="border-top-width: 1px; border-right-width: 1px; border-bottom-width: 1px; border-left-width: 1px; border-top-style: solid; border-right-style: solid; border-bottom-style: solid; border-left-style: solid; border-top-color: #999999; border-right-color: #999999; border-bottom-color: #999999; border-left-color: #999999; text-align: right; "><input type="button" value="程序控制关闭" /></td><td style="border-top-width: 1px; border-right-width: 1px; border-bottom-width: 1px; border-left-width: 1px; border-top-style: solid; border-right-style: solid; border-bottom-style: solid; border-left-style: solid; border-top-color: #999999; border-right-color: #999999; border-bottom-color: #999999; border-left-color: #999999; text-align: left; background-image: initial; background-attachment: initial; background-origin: initial; background-clip: initial; background-color: #eeeeee; font-family: 'Courier New'; line-height: 20px; font-size: 12px; background-position: initial initial; background-repeat: initial initial; ">ymPrompt.alert({title:'autoClose使用演示',message:'程序控制关闭',autoClose:false,handler:autoClose})</td></tr><tr><td style="border-top-width: 1px; border-right-width: 1px; border-bottom-width: 1px; border-left-width: 1px; border-top-style: solid; border-right-style: solid; border-bottom-style: solid; border-left-style: solid; border-top-color: #999999; border-right-color: #999999; border-bottom-color: #999999; border-left-color: #999999; text-align: right; "><input type="button" value="无标题栏" /></td><td style="border-top-width: 1px; border-right-width: 1px; border-bottom-width: 1px; border-left-width: 1px; border-top-style: solid; border-right-style: solid; border-bottom-style: solid; border-left-style: solid; border-top-color: #999999; border-right-color: #999999; border-bottom-color: #999999; border-left-color: #999999; text-align: left; background-image: initial; background-attachment: initial; background-origin: initial; background-clip: initial; background-color: #eeeeee; font-family: 'Courier New'; line-height: 20px; font-size: 12px; background-position: initial initial; background-repeat: initial initial; ">ymPrompt.win({message:'&lt;br&gt;&lt;center&gt;无标题栏&lt;/center&gt;',handler:noTitlebar,btn:[['关闭我']],titleBar:false})</td></tr><tr><td style="border-top-width: 1px; border-right-width: 1px; border-bottom-width: 1px; border-left-width: 1px; border-top-style: solid; border-right-style: solid; border-bottom-style: solid; border-left-style: solid; border-top-color: #999999; border-right-color: #999999; border-bottom-color: #999999; border-left-color: #999999; text-align: right; "><input type="button" value="不显示遮罩" /></td><td style="border-top-width: 1px; border-right-width: 1px; border-bottom-width: 1px; border-left-width: 1px; border-top-style: solid; border-right-style: solid; border-bottom-style: solid; border-left-style: solid; border-top-color: #999999; border-right-color: #999999; border-bottom-color: #999999; border-left-color: #999999; text-align: left; background-image: initial; background-attachment: initial; background-origin: initial; background-clip: initial; background-color: #eeeeee; font-family: 'Courier New'; line-height: 20px; font-size: 12px; background-position: initial initial; background-repeat: initial initial; ">ymPrompt.alert({message:'不显示遮罩',title:'不显示遮罩',showMask:false})</td></tr><tr><td style="border-top-width: 1px; border-right-width: 1px; border-bottom-width: 1px; border-left-width: 1px; border-top-style: solid; border-right-style: solid; border-bottom-style: solid; border-left-style: solid; border-top-color: #999999; border-right-color: #999999; border-bottom-color: #999999; border-left-color: #999999; text-align: right; "><input type="button" value="右下角弹出" /></td><td style="border-top-width: 1px; border-right-width: 1px; border-bottom-width: 1px; border-left-width: 1px; border-top-style: solid; border-right-style: solid; border-bottom-style: solid; border-left-style: solid; border-top-color: #999999; border-right-color: #999999; border-bottom-color: #999999; border-left-color: #999999; text-align: left; background-image: initial; background-attachment: initial; background-origin: initial; background-clip: initial; background-color: #eeeeee; font-family: 'Courier New'; line-height: 20px; font-size: 12px; background-position: initial initial; background-repeat: initial initial; ">ymPrompt.alert({message:'右下角弹出',title:'右下角弹出',winPos:'rb'})</td></tr><tr><td style="border-top-width: 1px; border-right-width: 1px; border-bottom-width: 1px; border-left-width: 1px; border-top-style: solid; border-right-style: solid; border-bottom-style: solid; border-left-style: solid; border-top-color: #999999; border-right-color: #999999; border-bottom-color: #999999; border-left-color: #999999; text-align: right; "><input type="button" value="自定义弹出位置" /></td><td style="border-top-width: 1px; border-right-width: 1px; border-bottom-width: 1px; border-left-width: 1px; border-top-style: solid; border-right-style: solid; border-bottom-style: solid; border-left-style: solid; border-top-color: #999999; border-right-color: #999999; border-bottom-color: #999999; border-left-color: #999999; text-align: left; background-image: initial; background-attachment: initial; background-origin: initial; background-clip: initial; background-color: #eeeeee; font-family: 'Courier New'; line-height: 20px; font-size: 12px; background-position: initial initial; background-repeat: initial initial; ">ymPrompt.alert({message:'自定义弹出位置',title:'右下角弹出',winPos:[200,1000]})</td></tr><tr><td style="border-top-width: 1px; border-right-width: 1px; border-bottom-width: 1px; border-left-width: 1px; border-top-style: solid; border-right-style: solid; border-bottom-style: solid; border-left-style: solid; border-top-color: #999999; border-right-color: #999999; border-bottom-color: #999999; border-left-color: #999999; text-align: right; "><input type="button" value="自定义按钮" /></td><td style="border-top-width: 1px; border-right-width: 1px; border-bottom-width: 1px; border-left-width: 1px; border-top-style: solid; border-right-style: solid; border-bottom-style: solid; border-left-style: solid; border-top-color: #999999; border-right-color: #999999; border-bottom-color: #999999; border-left-color: #999999; text-align: left; background-image: initial; background-attachment: initial; background-origin: initial; background-clip: initial; background-color: #eeeeee; font-family: 'Courier New'; line-height: 20px; font-size: 12px; background-position: initial initial; background-repeat: initial initial; ">ymPrompt.win({message:'自定义按钮',title:'自定义按钮测试',handler:testHd,btn:[['是','yes'],['否','no'],['取消','cancel']]})</td></tr></tbody></table><table width="100%" cellpadding="3" cellspacing="0" style="border-collapse: collapse; border-top-width: 1px; border-right-width: 1px; border-bottom-width: 1px; border-left-width: 1px; border-top-style: solid; border-right-style: solid; border-bottom-style: solid; border-left-style: solid; border-top-color: #999999; border-right-color: #999999; border-bottom-color: #999999; border-left-color: #999999; margin-top: 5px; margin-right: 0px; margin-bottom: 5px; margin-left: 0px; font-family: Simsun; line-height: normal; font-size: medium; "><caption style="background-image: initial; background-attachment: initial; background-origin: initial; background-clip: initial; background-color: #eeeeee; line-height: 30px; border-top-width: 1px; border-right-width: 1px; border-bottom-width: 1px; border-left-width: 1px; border-top-style: solid; border-right-style: solid; border-bottom-style: solid; border-left-style: solid; border-top-color: #999999; border-right-color: #999999; border-bottom-color: #999999; border-left-color: #999999; font-weight: bold; background-position: initial initial; background-repeat: initial initial; ">组件方式及属性调用演示：</caption><tbody><tr align="center"><th width="150" style="border-top-width: 1px; border-right-width: 1px; border-bottom-width: 1px; border-left-width: 1px; border-top-style: solid; border-right-style: solid; border-bottom-style: solid; border-left-style: solid; border-top-color: #999999; border-right-color: #999999; border-bottom-color: #999999; border-left-color: #999999; text-align: center; line-height: 22px; ">示例</th><th style="border-top-width: 1px; border-right-width: 1px; border-bottom-width: 1px; border-left-width: 1px; border-top-style: solid; border-right-style: solid; border-bottom-style: solid; border-left-style: solid; border-top-color: #999999; border-right-color: #999999; border-bottom-color: #999999; border-left-color: #999999; text-align: center; line-height: 22px; ">源码</th></tr><tr><td style="border-top-width: 1px; border-right-width: 1px; border-bottom-width: 1px; border-left-width: 1px; border-top-style: solid; border-right-style: solid; border-bottom-style: solid; border-left-style: solid; border-top-color: #999999; border-right-color: #999999; border-bottom-color: #999999; border-left-color: #999999; text-align: right; "><input type="button" value="属性读取" /></td><td style="border-top-width: 1px; border-right-width: 1px; border-bottom-width: 1px; border-left-width: 1px; border-top-style: solid; border-right-style: solid; border-bottom-style: solid; border-left-style: solid; border-top-color: #999999; border-right-color: #999999; border-bottom-color: #999999; border-left-color: #999999; text-align: left; background-image: initial; background-attachment: initial; background-origin: initial; background-clip: initial; background-color: #eeeeee; font-family: 'Courier New'; line-height: 20px; font-size: 12px; background-position: initial initial; background-repeat: initial initial; ">ymPrompt.win('&lt;div class=fmt&gt;版本号：'+ymPrompt.version+'&lt;br&gt;发布日期：'+ymPrompt.pubDate+'&lt;br&gt;组件当前配置信息：'+json2str(ymPrompt.cfg)+'&lt;/div&gt;',250,450)</td></tr><tr><td style="border-top-width: 1px; border-right-width: 1px; border-bottom-width: 1px; border-left-width: 1px; border-top-style: solid; border-right-style: solid; border-bottom-style: solid; border-left-style: solid; border-top-color: #999999; border-right-color: #999999; border-bottom-color: #999999; border-left-color: #999999; text-align: right; "><input type="button" value="getPage测试" /></td><td style="border-top-width: 1px; border-right-width: 1px; border-bottom-width: 1px; border-left-width: 1px; border-top-style: solid; border-right-style: solid; border-bottom-style: solid; border-left-style: solid; border-top-color: #999999; border-right-color: #999999; border-bottom-color: #999999; border-left-color: #999999; text-align: left; background-image: initial; background-attachment: initial; background-origin: initial; background-clip: initial; background-color: #eeeeee; font-family: 'Courier New'; line-height: 20px; font-size: 12px; background-position: initial initial; background-repeat: initial initial; ">ymPrompt.win({message:'iframe.html',width:500,height:300,title:'getPage测试',handler:handlerIframe,iframe:true})</td></tr><tr><td style="border-top-width: 1px; border-right-width: 1px; border-bottom-width: 1px; border-left-width: 1px; border-top-style: solid; border-right-style: solid; border-bottom-style: solid; border-left-style: solid; border-top-color: #999999; border-right-color: #999999; border-bottom-color: #999999; border-left-color: #999999; text-align: right; "><input type="button" value="resizeWin测试" /></td><td style="border-top-width: 1px; border-right-width: 1px; border-bottom-width: 1px; border-left-width: 1px; border-top-style: solid; border-right-style: solid; border-bottom-style: solid; border-left-style: solid; border-top-color: #999999; border-right-color: #999999; border-bottom-color: #999999; border-left-color: #999999; text-align: left; background-image: initial; background-attachment: initial; background-origin: initial; background-clip: initial; background-color: #eeeeee; font-family: 'Courier New'; line-height: 20px; font-size: 12px; background-position: initial initial; background-repeat: initial initial; ">ymPrompt.alert({message:'一秒钟后我的大小改为[400,300]',height:200,width:250});<br />setTimeout(function(){ymPrompt.resizeWin(400,300)},1000);</td></tr><tr><td style="border-top-width: 1px; border-right-width: 1px; border-bottom-width: 1px; border-left-width: 1px; border-top-style: solid; border-right-style: solid; border-bottom-style: solid; border-left-style: solid; border-top-color: #999999; border-right-color: #999999; border-bottom-color: #999999; border-left-color: #999999; text-align: right; "><input type="button" value="doHandler测试" /></td><td style="border-top-width: 1px; border-right-width: 1px; border-bottom-width: 1px; border-left-width: 1px; border-top-style: solid; border-right-style: solid; border-bottom-style: solid; border-left-style: solid; border-top-color: #999999; border-right-color: #999999; border-bottom-color: #999999; border-left-color: #999999; text-align: left; background-image: initial; background-attachment: initial; background-origin: initial; background-clip: initial; background-color: #eeeeee; font-family: 'Courier New'; line-height: 20px; font-size: 12px; background-position: initial initial; background-repeat: initial initial; ">ymPrompt.alert({message:'两秒钟后自动点击确定按钮',handler:handler});setTimeout(function(){ymPrompt.doHandler('ok')},1000);</td></tr><tr><td style="border-top-width: 1px; border-right-width: 1px; border-bottom-width: 1px; border-left-width: 1px; border-top-style: solid; border-right-style: solid; border-bottom-style: solid; border-left-style: solid; border-top-color: #999999; border-right-color: #999999; border-bottom-color: #999999; border-left-color: #999999; text-align: right; "><input type="button" value="模拟qq消息" /></td><td style="border-top-width: 1px; border-right-width: 1px; border-bottom-width: 1px; border-left-width: 1px; border-top-style: solid; border-right-style: solid; border-bottom-style: solid; border-left-style: solid; border-top-color: #999999; border-right-color: #999999; border-bottom-color: #999999; border-left-color: #999999; text-align: left; background-image: initial; background-attachment: initial; background-origin: initial; background-clip: initial; background-color: #eeeeee; font-family: 'Courier New'; line-height: 20px; font-size: 12px; background-position: initial initial; background-repeat: initial initial; ">ymPrompt.alert({message:'悬浮右下角，模拟qq',fixPosition:true,winPos:'rb',showMask:false})</td></tr><tr><td style="border-top-width: 1px; border-right-width: 1px; border-bottom-width: 1px; border-left-width: 1px; border-top-style: solid; border-right-style: solid; border-bottom-style: solid; border-left-style: solid; border-top-color: #999999; border-right-color: #999999; border-bottom-color: #999999; border-left-color: #999999; text-align: right; "><input type="button" value="英文化" /></td><td style="border-top-width: 1px; border-right-width: 1px; border-bottom-width: 1px; border-left-width: 1px; border-top-style: solid; border-right-style: solid; border-bottom-style: solid; border-left-style: solid; border-top-color: #999999; border-right-color: #999999; border-bottom-color: #999999; border-left-color: #999999; text-align: left; background-image: initial; background-attachment: initial; background-origin: initial; background-clip: initial; background-color: #eeeeee; font-family: 'Courier New'; line-height: 20px; font-size: 12px; background-position: initial initial; background-repeat: initial initial; ">ymPrompt.alert({message:'英文化成功',handler:en})</td></tr><tr><td style="border-top-width: 1px; border-right-width: 1px; border-bottom-width: 1px; border-left-width: 1px; border-top-style: solid; border-right-style: solid; border-bottom-style: solid; border-left-style: solid; border-top-color: #999999; border-right-color: #999999; border-bottom-color: #999999; border-left-color: #999999; text-align: right; "><input type="button" value="中文化" /></td><td style="border-top-width: 1px; border-right-width: 1px; border-bottom-width: 1px; border-left-width: 1px; border-top-style: solid; border-right-style: solid; border-bottom-style: solid; border-left-style: solid; border-top-color: #999999; border-right-color: #999999; border-bottom-color: #999999; border-left-color: #999999; text-align: left; background-image: initial; background-attachment: initial; background-origin: initial; background-clip: initial; background-color: #eeeeee; font-family: 'Courier New'; line-height: 20px; font-size: 12px; background-position: initial initial; background-repeat: initial initial; ">ymPrompt.alert({message:'中文化成功',handler:cn})</td></tr></tbody></table><hr style="font-family: Simsun; line-height: normal; font-size: medium; " /></div><a href="http://www.rainweb.cn/JavaScript/message-alert/demo.html"></a><img src ="http://www.blogjava.net/xiaomage234/aggbug/367064.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/xiaomage234/" target="_blank">小马歌</a> 2011-12-23 14:37 <a href="http://www.blogjava.net/xiaomage234/archive/2011/12/23/367064.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>jQuery Dialog弹出层对话框插件演示</title><link>http://www.blogjava.net/xiaomage234/archive/2011/12/23/367060.html</link><dc:creator>小马歌</dc:creator><author>小马歌</author><pubDate>Fri, 23 Dec 2011 05:59:00 GMT</pubDate><guid>http://www.blogjava.net/xiaomage234/archive/2011/12/23/367060.html</guid><wfw:comment>http://www.blogjava.net/xiaomage234/comments/367060.html</wfw:comment><comments>http://www.blogjava.net/xiaomage234/archive/2011/12/23/367060.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/xiaomage234/comments/commentRss/367060.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/xiaomage234/services/trackbacks/367060.html</trackback:ping><description><![CDATA[<div><span style="font-family: Simsun; line-height: normal; "><div style="margin-top: 20px; margin-right: 20px; margin-bottom: 20px; margin-left: 20px; padding-bottom: 20px; border-bottom-width: 1px; border-bottom-style: dotted; border-bottom-color: gray; "><h3><div><div style="background-image: initial; background-attachment: initial; background-origin: initial; background-clip: initial; padding-top: 20px; padding-right: 20px; padding-bottom: 20px; padding-left: 20px; background-color: #dddddd; "><span style="float: left; font-size: 14px; font-weight: normal; "><span class="Apple-style-span" style="font-size: 16px; font-weight: bold; ">from:&nbsp;<a href="http://www.caixw.com/public/uploads/demo/jquery/dialog/">http://www.caixw.com/public/uploads/demo/jquery/dialog/<br /></a><br />基本操作</span></span></div></div></h3><h5><br />默认的</h5><pre lang-js"="" style="margin-top: 5px !important; margin-right: 10px !important; margin-bottom: 10px !important; margin-left: 10px !important; padding-top: 2px; padding-right: 2px; padding-bottom: 2px; padding-left: 2px; word-wrap: break-word; cursor: pointer; border-top-width: 1px; border-right-width: 1px; border-bottom-width: 1px; border-left-width: 1px; border-top-style: solid; border-right-style: solid; border-bottom-style: solid; border-left-style: solid; border-top-color: #888888; border-right-color: #888888; border-bottom-color: #888888; border-left-color: #888888; "><span style="color: #000088; ">new</span> <span style="color: #660066; ">Dialog</span><span style="color: #666600; ">(</span><span style="color: #008800; ">'这是一个默认对话框'</span><span style="color: #666600; ">).</span><span style="color: #000000; ">show</span><span style="color: #666600; ">();</span></pre><h5>非模态对话框</h5><pre lang-js"="" style="margin-top: 5px !important; margin-right: 10px !important; margin-bottom: 10px !important; margin-left: 10px !important; padding-top: 2px; padding-right: 2px; padding-bottom: 2px; padding-left: 2px; word-wrap: break-word; cursor: pointer; border-top-width: 1px; border-right-width: 1px; border-bottom-width: 1px; border-left-width: 1px; border-top-style: solid; border-right-style: solid; border-bottom-style: solid; border-left-style: solid; border-top-color: #888888; border-right-color: #888888; border-bottom-color: #888888; border-left-color: #888888; "><span style="color: #000088; ">new</span> <span style="color: #660066; ">Dialog</span><span style="color: #666600; ">(</span><span style="color: #008800; ">'非模态对话框，可以打开多个！'</span><span style="color: #666600; ">,{</span><span style="color: #000000; ">modal</span><span style="color: #666600; ">:</span><span style="color: #000088; ">false</span><span style="color: #666600; ">}).</span><span style="color: #000000; ">show</span><span style="color: #666600; ">();</span></pre><h5>自动关闭</h5><pre lang-js"="" style="margin-top: 5px !important; margin-right: 10px !important; margin-bottom: 10px !important; margin-left: 10px !important; padding-top: 2px; padding-right: 2px; padding-bottom: 2px; padding-left: 2px; word-wrap: break-word; cursor: pointer; border-top-width: 1px; border-right-width: 1px; border-bottom-width: 1px; border-left-width: 1px; border-top-style: solid; border-right-style: solid; border-bottom-style: solid; border-left-style: solid; border-top-color: #888888; border-right-color: #888888; border-bottom-color: #888888; border-left-color: #888888; "><span style="color: #000088; ">new</span> <span style="color: #660066; ">Dialog</span><span style="color: #666600; ">(</span><span style="color: #008800; ">'5秒后自动关闭'</span><span style="color: #666600; ">,{</span><span style="color: #000000; ">time</span><span style="color: #666600; ">:</span><span style="color: #006666; ">5000</span><span style="color: #666600; ">}).</span><span style="color: #000000; ">show</span><span style="color: #666600; ">();</span></pre><h5>非fixed模式</h5><pre lang-js"="" style="margin-top: 5px !important; margin-right: 10px !important; margin-bottom: 10px !important; margin-left: 10px !important; padding-top: 2px; padding-right: 2px; padding-bottom: 2px; padding-left: 2px; word-wrap: break-word; cursor: pointer; border-top-width: 1px; border-right-width: 1px; border-bottom-width: 1px; border-left-width: 1px; border-top-style: solid; border-right-style: solid; border-bottom-style: solid; border-left-style: solid; border-top-color: #888888; border-right-color: #888888; border-bottom-color: #888888; border-left-color: #888888; "><span style="color: #000088; ">new</span> <span style="color: #660066; ">Dialog</span><span style="color: #666600; ">(</span><span style="color: #008800; ">'对话框不随滚动条移动'</span><span style="color: #666600; ">,{</span><span style="color: #000000; ">fixed</span><span style="color: #666600; ">:</span><span style="color: #000088; ">false</span><span style="color: #666600; ">}).</span><span style="color: #000000; ">show</span><span style="color: #666600; ">();</span></pre><h5>显示指定ID的内容</h5><pre id="content-type-id"  lang-js"="" style="margin-top: 5px !important; margin-right: 10px !important; margin-bottom: 10px !important; margin-left: 10px !important; padding-top: 2px; padding-right: 2px; padding-bottom: 2px; padding-left: 2px; word-wrap: break-word; cursor: pointer; border-top-width: 1px; border-right-width: 1px; border-bottom-width: 1px; border-left-width: 1px; border-top-style: solid; border-right-style: solid; border-bottom-style: solid; border-left-style: solid; border-top-color: #888888; border-right-color: #888888; border-bottom-color: #888888; border-left-color: #888888; "><span style="color: #880000; ">// 将显示本标签内的内容。</span><span style="color: #000000; "><br /></span><span style="color: #000088; ">new</span> <span style="color: #660066; ">Dialog</span><span style="color: #666600; ">({</span><span style="color: #000000; ">type</span><span style="color: #666600; ">:</span><span style="color: #008800; ">'id'</span><span style="color: #666600; ">,</span><span style="color: #000000; ">value</span><span style="color: #666600; ">:</span><span style="color: #008800; ">'content-type-id'</span><span style="color: #666600; ">}).</span><span style="color: #000000; ">show</span><span style="color: #666600; ">();</span></pre><h5>加载一张图片</h5><pre lang-js"="" style="margin-top: 5px !important; margin-right: 10px !important; margin-bottom: 10px !important; margin-left: 10px !important; padding-top: 2px; padding-right: 2px; padding-bottom: 2px; padding-left: 2px; word-wrap: break-word; cursor: pointer; border-top-width: 1px; border-right-width: 1px; border-bottom-width: 1px; border-left-width: 1px; border-top-style: solid; border-right-style: solid; border-bottom-style: solid; border-left-style: solid; border-top-color: #888888; border-right-color: #888888; border-bottom-color: #888888; border-left-color: #888888; "><span style="color: #000088; ">new</span> <span style="color: #660066; ">Dialog</span><span style="color: #666600; ">({</span><span style="color: #000000; ">type</span><span style="color: #666600; ">:</span><span style="color: #008800; ">'img'</span><span style="color: #666600; ">,</span><span style="color: #000000; ">value</span><span style="color: #666600; ">:</span><span style="color: #008800; ">'http://www.caixw.com/public/uploads/demo/images/300x125.gif'</span><span style="color: #666600; ">}).</span><span style="color: #000000; ">show</span><span style="color: #666600; ">();</span></pre><h5>加载一URL地址</h5><pre lang-js"="" style="margin-top: 5px !important; margin-right: 10px !important; margin-bottom: 10px !important; margin-left: 10px !important; padding-top: 2px; padding-right: 2px; padding-bottom: 2px; padding-left: 2px; word-wrap: break-word; cursor: pointer; border-top-width: 1px; border-right-width: 1px; border-bottom-width: 1px; border-left-width: 1px; border-top-style: solid; border-right-style: solid; border-bottom-style: solid; border-left-style: solid; border-top-color: #888888; border-right-color: #888888; border-bottom-color: #888888; border-left-color: #888888; "><span style="color: #000088; ">new</span> <span style="color: #660066; ">Dialog</span><span style="color: #666600; ">({</span><span style="color: #000000; ">type</span><span style="color: #666600; ">:</span><span style="color: #008800; ">'url'</span><span style="color: #666600; ">,</span><span style="color: #000000; ">value</span><span style="color: #666600; ">:</span><span style="color: #008800; ">'http://www.caixw.com/public/uploads/demo/jquery/dialog/test.html'</span><span style="color: #666600; ">}).</span><span style="color: #000000; ">show</span><span style="color: #666600; ">();</span></pre><h5>加载一URL到iframe</h5><pre lang-js"="" style="margin-top: 5px !important; margin-right: 10px !important; margin-bottom: 10px !important; margin-left: 10px !important; padding-top: 2px; padding-right: 2px; padding-bottom: 2px; padding-left: 2px; word-wrap: break-word; cursor: pointer; border-top-width: 1px; border-right-width: 1px; border-bottom-width: 1px; border-left-width: 1px; border-top-style: solid; border-right-style: solid; border-bottom-style: solid; border-left-style: solid; border-top-color: #888888; border-right-color: #888888; border-bottom-color: #888888; border-left-color: #888888; "><span style="color: #000088; ">new</span> <span style="color: #660066; ">Dialog</span><span style="color: #666600; ">({</span><span style="color: #000000; ">type</span><span style="color: #666600; ">:</span><span style="color: #008800; ">'iframe'</span><span style="color: #666600; ">,</span><span style="color: #000000; ">value</span><span style="color: #666600; ">:</span><span style="color: #008800; ">'http://www.caixw.com'</span><span style="color: #666600; ">}).</span><span style="color: #000000; ">show</span><span style="color: #666600; ">();</span></pre></div><div style="margin-top: 20px; margin-right: 20px; margin-bottom: 20px; margin-left: 20px; padding-bottom: 20px; border-bottom-width: 1px; border-bottom-style: dotted; border-bottom-color: gray; "><h3>自定义CSS</h3><h5>自定义背景遮盖层</h5><pre lang-css"="" style="margin-top: 5px !important; margin-right: 10px !important; margin-bottom: 10px !important; margin-left: 10px !important; padding-top: 2px; padding-right: 2px; padding-bottom: 2px; padding-left: 2px; word-wrap: break-word; cursor: pointer; border-top-width: 1px; border-right-width: 1px; border-bottom-width: 1px; border-left-width: 1px; border-top-style: solid; border-right-style: solid; border-bottom-style: solid; border-left-style: solid; border-top-color: #888888; border-right-color: #888888; border-bottom-color: #888888; border-left-color: #888888; "><span style="color: #880000; ">#dialog1-overlay</span><span style="color: #000000; "><br /></span><span style="color: #666600; ">{</span><span style="color: #000000; "><br />&nbsp; background</span><span style="color: #666600; ">:</span><span style="color: #000000; ">blue</span><span style="color: #666600; ">;</span><span style="color: #000000; "><br />&nbsp; opacity</span><span style="color: #666600; ">:</span><span style="color: #006666; ">0.8</span><span style="color: #666600; ">;</span><span style="color: #000000; "><br />&nbsp; filter</span><span style="color: #666600; ">:</span><span style="color: #000000; ">alpha</span><span style="color: #666600; ">(</span><span style="color: #000000; ">opacity</span><span style="color: #666600; ">=</span><span style="color: #006666; ">80</span><span style="color: #666600; ">);</span><span style="color: #000000; "><br /></span><span style="color: #666600; ">}</span></pre><pre lang-js"="" style="margin-top: 5px !important; margin-right: 10px !important; margin-bottom: 10px !important; margin-left: 10px !important; padding-top: 2px; padding-right: 2px; padding-bottom: 2px; padding-left: 2px; word-wrap: break-word; cursor: pointer; border-top-width: 1px; border-right-width: 1px; border-bottom-width: 1px; border-left-width: 1px; border-top-style: solid; border-right-style: solid; border-bottom-style: solid; border-left-style: solid; border-top-color: #888888; border-right-color: #888888; border-bottom-color: #888888; border-left-color: #888888; "><span style="color: #000088; ">new</span> <span style="color: #660066; ">Dialog</span><span style="color: #666600; ">(</span><span style="color: #008800; ">'自定义背景遮盖层'</span><span style="color: #666600; ">,{</span><span style="color: #000000; ">id</span><span style="color: #666600; ">:</span><span style="color: #008800; ">'dialog1'</span><span style="color: #666600; ">}).</span><span style="color: #000000; ">show</span><span style="color: #666600; ">();</span></pre><h5>自定义内容部分背景</h5><pre lang-css"="" style="margin-top: 5px !important; margin-right: 10px !important; margin-bottom: 10px !important; margin-left: 10px !important; padding-top: 2px; padding-right: 2px; padding-bottom: 2px; padding-left: 2px; word-wrap: break-word; cursor: pointer; border-top-width: 1px; border-right-width: 1px; border-bottom-width: 1px; border-left-width: 1px; border-top-style: solid; border-right-style: solid; border-bottom-style: solid; border-left-style: solid; border-top-color: #888888; border-right-color: #888888; border-bottom-color: #888888; border-left-color: #888888; "><span style="color: #880000; ">#dialog2 .content</span><span style="color: #000000; "><br /></span><span style="color: #666600; ">{</span><span style="color: #000000; "><br />&nbsp; width</span><span style="color: #666600; ">:</span><span style="color: #006666; ">250px</span><span style="color: #666600; ">;</span><span style="color: #000000; "><br />&nbsp; height</span><span style="color: #666600; ">:</span><span style="color: #006666; ">80px</span><span style="color: #666600; ">;</span><span style="color: #000000; "><br />&nbsp; background</span><span style="color: #666600; ">-</span><span style="color: #000000; ">image</span><span style="color: #666600; ">:</span><span style="color: #000000; ">url</span><span style="color: #666600; ">(</span><span style="color: #000000; ">http</span><span style="color: #666600; ">:</span><span style="color: #880000; ">//www.caixw.com/public/uploads/demo/images/300x125.gif);</span><span style="color: #000000; "><br /></span><span style="color: #666600; ">}</span></pre><pre lang-js"="" style="margin-top: 5px !important; margin-right: 10px !important; margin-bottom: 10px !important; margin-left: 10px !important; padding-top: 2px; padding-right: 2px; padding-bottom: 2px; padding-left: 2px; word-wrap: break-word; cursor: pointer; border-top-width: 1px; border-right-width: 1px; border-bottom-width: 1px; border-left-width: 1px; border-top-style: solid; border-right-style: solid; border-bottom-style: solid; border-left-style: solid; border-top-color: #888888; border-right-color: #888888; border-bottom-color: #888888; border-left-color: #888888; "><span style="color: #000088; ">new</span> <span style="color: #660066; ">Dialog</span><span style="color: #666600; ">(</span><span style="color: #008800; ">'自定义内容部分背景'</span><span style="color: #666600; ">,{</span><span style="color: #000000; ">id</span><span style="color: #666600; ">:</span><span style="color: #008800; ">'dialog2'</span><span style="color: #666600; ">}).</span><span style="color: #000000; ">show</span><span style="color: #666600; ">();</span></pre></div><div style="margin-top: 20px; margin-right: 20px; margin-bottom: 20px; margin-left: 20px; padding-bottom: 20px; border-bottom-width: 1px; border-bottom-style: dotted; border-bottom-color: gray; "><h3>回调函数</h3><h5>show()函数</h5><pre lang-js"="" style="margin-top: 5px !important; margin-right: 10px !important; margin-bottom: 10px !important; margin-left: 10px !important; padding-top: 2px; padding-right: 2px; padding-bottom: 2px; padding-left: 2px; word-wrap: break-word; cursor: pointer; border-top-width: 1px; border-right-width: 1px; border-bottom-width: 1px; border-left-width: 1px; border-top-style: solid; border-right-style: solid; border-bottom-style: solid; border-left-style: solid; border-top-color: #888888; border-right-color: #888888; border-bottom-color: #888888; border-left-color: #888888; "><span style="color: #000088; ">new</span> <span style="color: #660066; ">Dialog</span><span style="color: #666600; ">(</span><span style="color: #008800; ">'show()回调函数'</span><span style="color: #000000; "><br />&nbsp; &nbsp; </span><span style="color: #666600; ">{</span><span style="color: #000000; ">beforeShow</span><span style="color: #666600; ">:</span><span style="color: #000088; ">function</span><span style="color: #666600; ">(){</span><span style="color: #000000; ">alert</span><span style="color: #666600; ">(</span><span style="color: #008800; ">'before show'</span><span style="color: #666600; ">),</span><span style="color: #000088; ">return</span> <span style="color: #000088; ">true</span><span style="color: #666600; ">},</span><span style="color: #000000; ">afterShow</span><span style="color: #666600; ">:</span><span style="color: #000088; ">function</span><span style="color: #666600; ">(){</span><span style="color: #000000; ">alert</span><span style="color: #666600; ">(</span><span style="color: #008800; ">'after show'</span><span style="color: #666600; ">);}})</span><span style="color: #000000; "><br />&nbsp; &nbsp; </span><span style="color: #666600; ">.</span><span style="color: #000000; ">show</span><span style="color: #666600; ">();</span></pre><h5>hide()函数</h5><pre lang-js"="" style="margin-top: 5px !important; margin-right: 10px !important; margin-bottom: 10px !important; margin-left: 10px !important; padding-top: 2px; padding-right: 2px; padding-bottom: 2px; padding-left: 2px; word-wrap: break-word; cursor: pointer; border-top-width: 1px; border-right-width: 1px; border-bottom-width: 1px; border-left-width: 1px; border-top-style: solid; border-right-style: solid; border-bottom-style: solid; border-left-style: solid; border-top-color: #888888; border-right-color: #888888; border-bottom-color: #888888; border-left-color: #888888; "><span style="color: #000000; ">dlg </span><span style="color: #666600; ">=</span> <span style="color: #000088; ">new</span> <span style="color: #660066; ">Dialog</span><span style="color: #666600; ">(</span><span style="color: #008800; ">'hide()回调函数'</span><span style="color: #000000; "><br />&nbsp; &nbsp; </span><span style="color: #666600; ">{</span><span style="color: #000000; ">beforeHide</span><span style="color: #666600; ">:</span><span style="color: #000088; ">function</span><span style="color: #666600; ">(){</span><span style="color: #000000; ">alert</span><span style="color: #666600; ">(</span><span style="color: #008800; ">'before hide'</span><span style="color: #666600; ">),</span><span style="color: #000088; ">return</span> <span style="color: #000088; ">true</span><span style="color: #666600; ">},</span><span style="color: #000000; ">afterHide</span><span style="color: #666600; ">:</span><span style="color: #000088; ">function</span><span style="color: #666600; ">(){</span><span style="color: #000000; ">alert</span><span style="color: #666600; ">(</span><span style="color: #008800; ">'after hide'</span><span style="color: #666600; ">);}})</span><span style="color: #000000; "><br />&nbsp; &nbsp; </span><span style="color: #666600; ">.</span><span style="color: #000000; ">show</span><span style="color: #666600; ">();</span><span style="color: #000000; "><br />dlg</span><span style="color: #666600; ">.</span><span style="color: #000000; ">hide</span><span style="color: #666600; ">();</span></pre><button>显示</button>&nbsp;&nbsp;&nbsp;<button>隐藏</button>&nbsp;<br /><br /><h5>close()函数</h5><pre lang-js"="" style="margin-top: 5px !important; margin-right: 10px !important; margin-bottom: 10px !important; margin-left: 10px !important; padding-top: 2px; padding-right: 2px; padding-bottom: 2px; padding-left: 2px; word-wrap: break-word; cursor: pointer; border-top-width: 1px; border-right-width: 1px; border-bottom-width: 1px; border-left-width: 1px; border-top-style: solid; border-right-style: solid; border-bottom-style: solid; border-left-style: solid; border-top-color: #888888; border-right-color: #888888; border-bottom-color: #888888; border-left-color: #888888; "><span style="color: #000088; ">new</span> <span style="color: #660066; ">Dialog</span><span style="color: #666600; ">(</span><span style="color: #008800; ">'close()回调函数'</span><span style="color: #000000; "><br />&nbsp; &nbsp; </span><span style="color: #666600; ">{</span><span style="color: #000000; ">beforeClose</span><span style="color: #666600; ">:</span><span style="color: #000088; ">function</span><span style="color: #666600; ">(){</span><span style="color: #000000; ">alert</span><span style="color: #666600; ">(</span><span style="color: #008800; ">'before close'</span><span style="color: #666600; ">),</span><span style="color: #000088; ">return</span> <span style="color: #000088; ">true</span><span style="color: #666600; ">},</span><span style="color: #000000; ">afterClose</span><span style="color: #666600; ">:</span><span style="color: #000088; ">function</span><span style="color: #666600; ">(){</span><span style="color: #000000; ">alert</span><span style="color: #666600; ">(</span><span style="color: #008800; ">'after close'</span><span style="color: #666600; ">);}})</span><span style="color: #000000; "><br />&nbsp; &nbsp; </span><span style="color: #666600; ">.</span><span style="color: #000000; ">show</span><span style="color: #666600; ">();</span></pre></div></span></div><img src ="http://www.blogjava.net/xiaomage234/aggbug/367060.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/xiaomage234/" target="_blank">小马歌</a> 2011-12-23 13:59 <a href="http://www.blogjava.net/xiaomage234/archive/2011/12/23/367060.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>javascript表单提交【转】</title><link>http://www.blogjava.net/xiaomage234/archive/2011/11/23/364666.html</link><dc:creator>小马歌</dc:creator><author>小马歌</author><pubDate>Wed, 23 Nov 2011 11:32:00 GMT</pubDate><guid>http://www.blogjava.net/xiaomage234/archive/2011/11/23/364666.html</guid><wfw:comment>http://www.blogjava.net/xiaomage234/comments/364666.html</wfw:comment><comments>http://www.blogjava.net/xiaomage234/archive/2011/11/23/364666.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/xiaomage234/comments/commentRss/364666.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/xiaomage234/services/trackbacks/364666.html</trackback:ping><description><![CDATA[总结得不错。<br /><br /><div><span style="color: #4b4b4b; font-family: verdana, Arial, helvetica, sans-seriff; font-size: 12px; line-height: 19px; "><p>1、按钮为button，可在js中调用formName.submit()显性提交。若是submit按钮，则不能再这样加提交语句，否则会提交两次。</p><p>2、一个input域中回车，会默认第一个submit属性的按钮提交。若都是butoon属性，则回车不会提交表单。</p><p>3、有时提交表单后不能刷新页面，即没有action=""的情况，&lt;form name="hand" method="post" onSubmit="javascript:return handle();"&gt;（此时在handle()中进行处理后会返回一个false）或者&lt;form name="hand" method="post" onSubmit="javascript:handle();return false"&gt;或者&lt;input type="button" id="addbt" name="addbt" value="增加关联" onClick="javascript:subList();return false;" /&gt;。这样做了后能保证只执行js代码后，本页面不刷新，也不提交到另一个页面。</p><p>//一般提交&nbsp;<br />function&nbsp;del(myform)&nbsp;<br />{&nbsp;<br />myform.target="_blank"&nbsp;//也可以是_self,_top,_parent,默认为_self&nbsp;<br />myform.action="trade_delete.asp";&nbsp;<br />myform.submit();&nbsp;&nbsp;<br />}&nbsp;<br /><br />//提交后对窗口的限制&nbsp;<br />function&nbsp;del(creator)&nbsp;<br />{&nbsp;<br />creator.target="preview";&nbsp;<br />creator.action="register_check.asp";&nbsp;<br />var&nbsp;win&nbsp;=&nbsp;window.open("about:blank","preview","toolbar=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=no,width=250,height=25,top=250,left=300");&nbsp;<br />win.focus();&nbsp;<br />creator.submit();&nbsp;<br />}&nbsp;</p><p>&nbsp;</p><p>&nbsp;</p><p>&nbsp;</p><div><div><div><li><span>总结下这么几种的方法: &nbsp;&nbsp;</span></li><li>1,通过type=submit&nbsp;或者图片的submti来提交(图片的这种方法很不错) &nbsp;&nbsp;</li><li>2,通过在imput里面加onclick来写个方法来做提交前的验证.type可以是button.,反正多个浏览器&nbsp;&nbsp;</li><li>&nbsp;&nbsp;&nbsp;做的时候,试验一下. &nbsp;&nbsp;</li><li>3,还有可以通过在form里面加onsubmit来验证. &nbsp;&nbsp;</li><li>4,通过在javascript的方法里头,用submit()方法来提交 &nbsp;&nbsp;</li><li>&nbsp;&nbsp;具体得到这个form的方法有: &nbsp;&nbsp;</li><li>oForm&nbsp;=&nbsp;document.getElementById("form1"); &nbsp;&nbsp;</li><li>oForm&nbsp;=&nbsp;document.forms("form1"); &nbsp;&nbsp;</li><li>oForm&nbsp;=&nbsp;document.forms[0]; &nbsp;&nbsp;</li><li>//通过上面的几种可以得到form&nbsp;&nbsp;&nbsp;</li><li>oForm.submit();&nbsp;</li></div></div><div></div><div>xml 代码</div><div><div></div><ol><li><span>&lt;%@&nbsp;page&nbsp;language="java"&nbsp;import="java.util.*"&nbsp;pageEncoding="gbk"%&gt;&nbsp;&nbsp;</span></li><li>&lt;html&gt;&nbsp;&nbsp;</li><li>&lt;script&nbsp;type="text/javascript"&gt;&nbsp;&nbsp;</li><li>&nbsp;&nbsp;&nbsp;&nbsp;function&nbsp;dosubmit()&nbsp;{ &nbsp;&nbsp;</li><li>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;alert("heihei"); &nbsp;&nbsp;</li><li>&nbsp;&nbsp;&nbsp;&nbsp;} &nbsp;&nbsp;</li><li><span>script&gt;&nbsp;&nbsp;</span></li><li>&lt;head&gt;javascript测试<span>head&gt;&nbsp;&nbsp;</span></li><li>&lt;body&gt;&nbsp;&nbsp;</li><li>&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;</li><li>&lt;hr&gt;&nbsp;&nbsp;</li><li>&nbsp;&nbsp;&nbsp;&nbsp;&lt;form&nbsp;action="print.jsp"&nbsp;method="post"&gt;&nbsp;&nbsp;</li><li>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;input&nbsp;type="text"&nbsp;name="hello"/&gt;&nbsp;&nbsp;</li><li>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;input&nbsp;type="submit"&nbsp;name="sub"&nbsp;value="提交"&nbsp;onclick="dosubmit()"/&gt;&nbsp;&nbsp;</li><li>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</li><li>&nbsp;&nbsp;&nbsp;&nbsp;<span>form&gt;&nbsp;&nbsp;</span></li><li><span>body&gt;&nbsp;&nbsp;</span></li><li><span>html&gt;&nbsp;&nbsp;</span></li></ol></div></div><p><strong></strong></p><p><strong>可以在函数里面做出验证.</strong></p><p><strong>这个要用onclick 来触发事件,onchange,试了下不行其他不行.</strong></p><p><strong>这里是用按钮.这里type用了submit</strong></p><div>xml 代码</div><div><div></div><ol><li><span>&lt;%@&nbsp;page&nbsp;language="java"&nbsp;import="java.util.*"&nbsp;pageEncoding="gbk"%&gt;&nbsp;&nbsp;</span></li><li>&lt;html&gt;&nbsp;&nbsp;</li><li>&lt;script&nbsp;type="text/javascript"&gt;&nbsp;&nbsp;</li><li>&nbsp;&nbsp;&nbsp;&nbsp;function&nbsp;dosubmit()&nbsp;{ &nbsp;&nbsp;</li><li>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;document.forms[0].submit(); &nbsp;&nbsp;</li><li>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;alert("^_^提交成功！"); &nbsp;&nbsp;</li><li>&nbsp;&nbsp;&nbsp;&nbsp;} &nbsp;&nbsp;</li><li><span>script&gt;&nbsp;&nbsp;</span></li><li>&lt;head&gt;javascript测试<span>head&gt;&nbsp;&nbsp;</span></li><li>&lt;body&gt;&nbsp;&nbsp;</li><li>&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;</li><li>&lt;hr&gt;&nbsp;&nbsp;</li><li>&nbsp;&nbsp;&nbsp;&nbsp;&lt;form&nbsp;action="print.jsp"&nbsp;method="post"&gt;&nbsp;&nbsp;</li><li>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;input&nbsp;type="text"&nbsp;name="hello"/&gt;&nbsp;&nbsp;</li><li>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;input&nbsp;type="button"&nbsp;name="sub"&nbsp;value="提交"&nbsp;onclick="dosubmit()"/&gt;&nbsp;&nbsp;</li><li>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</li><li>&nbsp;&nbsp;&nbsp;&nbsp;<span>form&gt;&nbsp;&nbsp;</span></li><li><span>body&gt;&nbsp;&nbsp;</span></li><li><span>html&gt;&nbsp;&nbsp;</span></li></ol></div><p><strong>&nbsp;这里type用button,用document.forms[0].submit()来提交.</strong></p><div>xml 代码</div><div><div></div><ol><li><span>&lt;%@&nbsp;page&nbsp;language="java"&nbsp;import="java.util.*"&nbsp;pageEncoding="gbk"%&gt;&nbsp;&nbsp;</span></li><li>&lt;html&gt;&nbsp;&nbsp;</li><li>&lt;script&nbsp;type="text/javascript"&gt;&nbsp;&nbsp;</li><li>&nbsp;&nbsp;&nbsp;&nbsp;function&nbsp;dosubmit()&nbsp;{ &nbsp;&nbsp;</li><li>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;//document.forms[0].submit(); &nbsp;&nbsp;</li><li>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;alert("1111提交成功！"); &nbsp;&nbsp;</li><li>&nbsp;&nbsp;&nbsp;&nbsp;} &nbsp;&nbsp;</li><li><span>script&gt;&nbsp;&nbsp;</span></li><li>&lt;head&gt;javascript测试<span>head&gt;&nbsp;&nbsp;</span></li><li>&lt;body&gt;&nbsp;&nbsp;</li><li>&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;</li><li>&lt;hr&gt;&nbsp;&nbsp;</li><li>&nbsp;&nbsp;&nbsp;&nbsp;&lt;form&nbsp;action="print.jsp"&nbsp;method="post"&gt;&nbsp;&nbsp;</li><li>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;input&nbsp;type="text"&nbsp;name="hello"/&gt;&nbsp;&nbsp;z</li><li>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;input&nbsp;type="image"&nbsp;&nbsp;src="submit.bmp"&nbsp;name="sub"&nbsp;onclick="dosubmit()"/&gt;&nbsp;&nbsp;</li><li>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</li><li>&nbsp;&nbsp;&nbsp;&nbsp;<span>form&gt;&nbsp;&nbsp;</span></li><li><span>body&gt;&nbsp;&nbsp;</span></li><li><span>html&gt;&nbsp;&nbsp;</span></li><li></li><li></li><li></li><li></li><li></li><li>&lt;form name="form1" method="post" action="&lt;%=request.getContextPath()%&gt;/news/NewsTypeAddAction.sh"<h3><u>onSubmit="return actionCheck();"&gt;</u></h3><br />&lt;table&gt;<br />&lt;tr&gt;<br />&lt;td&gt;新闻类型编号&lt;/td&gt;<br />&lt;td&gt;<br />&lt;input type="text" name="typeid" onBlur="isDigit(this.value)"&gt; &lt;/td&gt;<br />&lt;/tr&gt;<br />&lt;tr&gt;<br />&lt;td&gt;新闻类型名称&lt;/td&gt;<br />&lt;td&gt;<br />&lt;input type="text" name="typename"&gt; &lt;/td&gt;<br />&lt;/tr&gt;<br />&lt;tr&gt;<br />&lt;td&gt;新闻存放目录名称&lt;/td&gt;<br />&lt;td&gt;<br />&lt;input type="text" name="dir"&gt; &lt;/td&gt;<br />&lt;/tr&gt;<br />&lt;tr&gt;<br />&lt;td&gt;使用模版名称&lt;/td&gt;<br />&lt;td&gt;<br />&lt;input type="text" name="templatename"&gt; &lt;/td&gt;<br />&lt;/tr&gt;<br />&lt;tr&gt;<br />&lt;td colspan="2"&gt;<br />&lt;div align="center"&gt;<br />&lt;input type="submit" name="Submit" value="Submit"&gt;<br />&lt;input type="reset" value="Reset"&gt;&nbsp;<br />&lt;/div&gt;&lt;/td&gt;<br />&lt;/tr&gt;<br />&lt;/table&gt;<br />&lt;/form&gt;<br /><strong>&lt;script type="text/javascript"&gt;<br />function isDigit(s)<br />{<br />var patrn=/^[0-9]{1,20}$/;<br />if (!patrn.exec(s)&amp;&amp;s!=""){<br />alert("请您输入数字!");<br />document.form1.typeid.value="";<br />document.form1.typeid.focus();<br />return false;<br />}<br />}<br /><br />function actionCheck()</strong></li><li><strong>{<br />&nbsp;&nbsp;&nbsp;&nbsp; if(document.form1.typeid.value=="")</strong></li><li><strong>&nbsp;&nbsp;&nbsp;&nbsp; {<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp; alert("新闻类型编号不能为空!");<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;document.form1.typeid.value="";<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; document.form1.typeid.focus();<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; return false;<br />}<br />}<br />&lt;/script&gt;</strong></li></ol></div></span></div><img src ="http://www.blogjava.net/xiaomage234/aggbug/364666.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/xiaomage234/" target="_blank">小马歌</a> 2011-11-23 19:32 <a href="http://www.blogjava.net/xiaomage234/archive/2011/11/23/364666.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>ibm文档中心，很好的教程</title><link>http://www.blogjava.net/xiaomage234/archive/2011/11/19/364312.html</link><dc:creator>小马歌</dc:creator><author>小马歌</author><pubDate>Sat, 19 Nov 2011 04:58:00 GMT</pubDate><guid>http://www.blogjava.net/xiaomage234/archive/2011/11/19/364312.html</guid><wfw:comment>http://www.blogjava.net/xiaomage234/comments/364312.html</wfw:comment><comments>http://www.blogjava.net/xiaomage234/archive/2011/11/19/364312.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/xiaomage234/comments/commentRss/364312.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/xiaomage234/services/trackbacks/364312.html</trackback:ping><description><![CDATA[<div><a href="http://www.ibm.com/developerworks/cn/">http://www.ibm.com/developerworks/cn/</a></div><img src ="http://www.blogjava.net/xiaomage234/aggbug/364312.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/xiaomage234/" target="_blank">小马歌</a> 2011-11-19 12:58 <a href="http://www.blogjava.net/xiaomage234/archive/2011/11/19/364312.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>什么是Mashup</title><link>http://www.blogjava.net/xiaomage234/archive/2011/11/19/364310.html</link><dc:creator>小马歌</dc:creator><author>小马歌</author><pubDate>Sat, 19 Nov 2011 04:41:00 GMT</pubDate><guid>http://www.blogjava.net/xiaomage234/archive/2011/11/19/364310.html</guid><wfw:comment>http://www.blogjava.net/xiaomage234/comments/364310.html</wfw:comment><comments>http://www.blogjava.net/xiaomage234/archive/2011/11/19/364310.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/xiaomage234/comments/commentRss/364310.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/xiaomage234/services/trackbacks/364310.html</trackback:ping><description><![CDATA[<div><span style="font-family: arial, 宋体, sans-serif; line-height: 25px; "><div><span style="line-height: 24px; "><div id="lemmaContent-0" style="letter-spacing: 0.5px; width: 690px; overflow-x: hidden; overflow-y: hidden; float: left; "><h2>简介</h2>　　一般使用源应用的API接口，或者是一些rss输出（含atom）作为内容源，合并的web应用用什么技术，则没有什么限制。mashup在geek群体和互联网玩家之中获得了极大的欢迎，mashup未必需要很高的编程技能，只需要熟悉api和网络服务工作方式，都能进行开发，所以很快成为一个流行的网络现象。很多公司例如yahoo/google都为此提供开放接口，以吸引这个群体。<div style="height: 14px; line-height: 14px; font-size: 12px; overflow-x: hidden; overflow-y: hidden; "></div>　　Mashup 是一个非常cool的新的<a target="_blank" href="http://baike.baidu.com/view/330120.htm" style="text-decoration: underline; color: #136ec2; ">应用程序</a>种类。如果你想真正的了解它们，我们需要回过头来看看你现在的计算机，其实它就是一个非常好的帮助你理解Mashup的模型。计算机运行着<a target="_blank" href="http://baike.baidu.com/view/880.htm" style="text-decoration: underline; color: #136ec2; ">操作系统</a>，例如Windows。现在开源的操作系统无疑是一个非常好的APIs 的集合或者一个<a target="_blank" href="http://baike.baidu.com/view/185287.htm" style="text-decoration: underline; color: #136ec2; ">应用程序编程接口</a>，帮助开发者去构建他们的应用程序。计算机本身也是一个很好的为用户提供接口的例子，键盘和鼠标可以被理解为你通过计算机的接口而使用的不同的应用程序。<div style="background-image: initial; background-attachment: initial; background-origin: initial; background-clip: initial; background-color: #f6f6f6; padding-top: 5px; padding-right: 5px; padding-bottom: 3px; padding-left: 5px; margin-top: 5px; margin-right: 5px; margin-bottom: 5px; margin-left: 5px; text-align: center; float: right; width: 195px; position: relative; visibility: visible; "><a title="查看图片" href="http://baike.baidu.com/albums/241257/241257.html#0$969cbf44b2be60eab3b7dc57" target="_blank" style="text-decoration: none; color: #136ec2; background-image: url(http://img.baidu.com/img/baike/s/zoom.gif); background-attachment: initial; background-origin: initial; background-clip: initial; background-color: initial; width: 14px; height: 14px; font-size: 0px; line-height: 0; display: block; position: absolute; right: 4px; bottom: 4px; border-top-width: 1px; border-right-width: 1px; border-bottom-width: 1px; border-left-width: 1px; border-top-style: solid; border-right-style: solid; border-bottom-style: solid; border-left-style: solid; border-top-color: #f6f6f6; border-right-color: #f6f6f6; border-bottom-color: #f6f6f6; border-left-color: #f6f6f6; background-position: 0px 0px; background-repeat: no-repeat no-repeat; ">&nbsp;&nbsp;</a><a href="http://baike.baidu.com/albums/241257/241257.html#0$969cbf44b2be60eab3b7dc57" target="_blank" style="text-decoration: underline; color: #136ec2; "><img log-set-param"="" log-set-param="img_view" title="Mashup" src="http://imgsrc.baidu.com/baike/abpic/item/969cbf44b2be60eab3b7dc57.jpg" style="border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; display: block; "  alt="" /></a><p style="margin-top: 3px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 10px; padding-bottom: 0px; padding-left: 0px; color: #666666; font-size: 12px; font-family: 宋体; font-weight: normal; display: inline; word-wrap: break-word; word-break: break-all; font-style: normal; line-height: 18px; min-height: 18px; zoom: 1; ">Mashup</p></div>一个API可能是帮助电脑接入网络又或者用来提供显示功能。总之，这些APIs 帮助开发者更加容易的去构建他们的应用程序。在过去开发者需要描绘每一个点显示的位置，而现在仅仅需要给出对称坐标，就可以完成一个窗口的绘制。<div style="height: 14px; line-height: 14px; font-size: 12px; overflow-x: hidden; overflow-y: hidden; "></div>　　APIs做的事情是这样的。假如你访问文件系统，那么你所需得到APIs，这是计算机工作的途径。然后你就可以在一个窗口里运行一个应用程序。人们开发一个应用程序通常需要3或4个不同的APIs,或许更多。<div style="height: 30px; line-height: 30px; overflow-x: hidden; overflow-y: hidden; "></div><h2><span editable-title"="" data-edit-id="241257:241257:2" style="font-size: 12px; float: right; display: block; margin-top: 10px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; color: #3366cc; font-weight: normal; "><a href="http://baike.baidu.com/view/241257.htm#" style="text-decoration: underline; color: #136ec2; height: 15px; line-height: 16px; background-image: url(http://img.baidu.com/img/baike/s/edit.gif); background-attachment: initial; background-origin: initial; background-clip: initial; background-color: initial; display: block; width: 52px; padding-left: 18px; background-position: 0% 50%; background-repeat: no-repeat no-repeat; ">编辑本段</a></span><a name="2" style="text-decoration: underline; color: rgb(19, 110, 194); "></a>运行方式</h2>　　这是一个计算机传统的运行方式。现在，我们将Windows，操作系统替换成网络。那么同样的，就会有许多公司来提供哪些APIs。比如yahoo,google.例如一个叫EVDB的公司，它是一个事件日历的数据库，可以提醒你什么时间到哪里做什么事情。也包括像 Amazon 和 eBay，又比如Technorati ，所有这些不同的公司把APIs放到网上使开发者可以访问。<div style="height: 14px; line-height: 14px; font-size: 12px; overflow-x: hidden; overflow-y: hidden; "></div>　　现在假如你是一个Web开发者，你通过一个API 找到你附近哪些地方会有犯罪。然后你访问Google 地图API，把这两个内容整合在一起，那么你就得到了一个标有犯罪纪录的地图。这个新的地图就叫Mashup。因为开发者通过来自多个网站的APIs，把他们合并在一起，成为了一个新的很cool的应用程序。<div style="height: 30px; line-height: 30px; overflow-x: hidden; overflow-y: hidden; "></div><h2><span editable-title"="" data-edit-id="241257:241257:3" style="font-size: 12px; float: right; display: block; margin-top: 10px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; color: #3366cc; font-weight: normal; "><a href="http://baike.baidu.com/view/241257.htm#" style="text-decoration: underline; color: #136ec2; height: 15px; line-height: 16px; background-image: url(http://img.baidu.com/img/baike/s/edit.gif); background-attachment: initial; background-origin: initial; background-clip: initial; background-color: initial; display: block; width: 52px; padding-left: 18px; background-position: 0% 50%; background-repeat: no-repeat no-repeat; ">编辑本段</a></span><a name="3" style="text-decoration: underline; color: rgb(19, 110, 194); "></a>目前</h2>　　越来越多的APIs被开放，这是一个比较明确的方向，每天都会有大概2.5个Mashup产生，预计到2007年每天Mashup的产生数量会增加到10个。<div style="height: 14px; line-height: 14px; font-size: 12px; overflow-x: hidden; overflow-y: hidden; "></div>　　之所以，一天会有10个Mashup产生是因为，开发将会变得越来越容易，你不用再必须变成一个C语言程序员去展示你的创造力，你可以开发很Cool的应用，例如哪里有停车空位的地图，就像在California得Bay 地区的 ParkingCarma 所做的那样。又或者你开发一个地图标记出你的邻居和你想去会见某人，这其实也已经是一个事实存在的应用了，FrozenBear公司正在做这方面的开发。<div style="height: 14px; line-height: 14px; font-size: 12px; overflow-x: hidden; overflow-y: hidden; "></div>　　我们展示这些Mashup的同时，又有新的APIs随时发布到网上，这就形成了一个生态系统，而且这个生态系统比目前现存的所有生态系统都会增长的更快。Windows，你必须成为一个程序员才可以开发应用程序，Linux，Macintosh也同样是如此，但是Mashup却不必， 它将会是今天增长速度最快的一个生态体统。<div style="height: 30px; line-height: 30px; overflow-x: hidden; overflow-y: hidden; "></div><h2><span editable-title"="" data-edit-id="241257:241257:4" style="font-size: 12px; float: right; display: block; margin-top: 10px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; color: #3366cc; font-weight: normal; "><a href="http://baike.baidu.com/view/241257.htm#" style="text-decoration: underline; color: #136ec2; height: 15px; line-height: 16px; background-image: url(http://img.baidu.com/img/baike/s/edit.gif); background-attachment: initial; background-origin: initial; background-clip: initial; background-color: initial; display: block; width: 52px; padding-left: 18px; background-position: 0% 50%; background-repeat: no-repeat no-repeat; ">编辑本段</a></span><a name="4" style="text-decoration: underline; color: rgb(19, 110, 194); "></a>发展</h2>　　<div style="background-image: initial; background-attachment: initial; background-origin: initial; background-clip: initial; background-color: #f6f6f6; padding-top: 5px; padding-right: 5px; padding-bottom: 3px; padding-left: 5px; margin-top: 5px; margin-right: 5px; margin-bottom: 5px; margin-left: 5px; text-align: center; float: right; width: 199px; position: relative; visibility: visible; "><a title="查看图片" href="http://baike.baidu.com/albums/241257/241257.html#0$0b907cd92a596e4410df9b50" target="_blank" style="text-decoration: none; color: #136ec2; background-image: url(http://img.baidu.com/img/baike/s/zoom.gif); background-attachment: initial; background-origin: initial; background-clip: initial; background-color: initial; width: 14px; height: 14px; font-size: 0px; line-height: 0; display: block; position: absolute; right: 4px; bottom: 4px; border-top-width: 1px; border-right-width: 1px; border-bottom-width: 1px; border-left-width: 1px; border-top-style: solid; border-right-style: solid; border-bottom-style: solid; border-left-style: solid; border-top-color: #f6f6f6; border-right-color: #f6f6f6; border-bottom-color: #f6f6f6; border-left-color: #f6f6f6; background-position: 0px 0px; background-repeat: no-repeat no-repeat; ">&nbsp;&nbsp;</a><a href="http://baike.baidu.com/albums/241257/241257.html#0$0b907cd92a596e4410df9b50" target="_blank" style="text-decoration: underline; color: #136ec2; "><img log-set-param"="" log-set-param="img_view" title="Windows" src="http://imgsrc.baidu.com/baike/abpic/item/0b907cd92a596e4410df9b50.jpg" style="border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; display: block; "  alt="" /></a><p style="margin-top: 3px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 10px; padding-bottom: 0px; padding-left: 0px; color: #666666; font-size: 12px; font-family: 宋体; font-weight: normal; display: inline; word-wrap: break-word; word-break: break-all; font-style: normal; line-height: 18px; min-height: 18px; zoom: 1; ">Windows</p></div>Mashup 不仅仅是发展的很快，更好的一个地方是你不再需通过某人才可以发布一个新API到网上。以前你必须要通过<a target="_blank" href="http://baike.baidu.com/view/2353.htm" style="text-decoration: underline; color: #136ec2; ">微软</a>才可以发布一个新的API加入到Windows，这种情况同样出现在Macintosh。另，尽管你也许可以添加一个API直接到Linux，因为它是开源的，但是这对大多开发者来说并不具备这样的权利。<div style="height: 14px; line-height: 14px; font-size: 12px; overflow-x: hidden; overflow-y: hidden; "></div>　　另外，你在发布了一个API到网上之后，不需要再通过谁去批准它，它会自动对所有开发者有效。所有的不同的APIs都会成为更多Mashup的燃料。<div style="height: 14px; line-height: 14px; font-size: 12px; overflow-x: hidden; overflow-y: hidden; "></div>　　越来越多的Mashup出现在网上，越来越多的网络用户去使用这些新的Mashup应用程序。越来越多的开发者加入到开发Mashup这个生态系统当中。在未来两年，你将可以听到关于Mashup的信息。<div style="height: 30px; line-height: 30px; overflow-x: hidden; overflow-y: hidden; "></div><h2><span editable-title"="" data-edit-id="241257:241257:5" style="font-size: 12px; float: right; display: block; margin-top: 10px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; color: #3366cc; font-weight: normal; "><a href="http://baike.baidu.com/view/241257.htm#" style="text-decoration: underline; color: #136ec2; height: 15px; line-height: 16px; background-image: url(http://img.baidu.com/img/baike/s/edit.gif); background-attachment: initial; background-origin: initial; background-clip: initial; background-color: initial; display: block; width: 52px; padding-left: 18px; background-position: 0% 50%; background-repeat: no-repeat no-repeat; ">编辑本段</a></span><a name="5" style="text-decoration: underline; color: rgb(19, 110, 194); "></a>典型应用</h2><h3><a name="5_1" style="text-decoration: underline; color: rgb(19, 110, 194); "></a>地图 Mashup</h3>　　在这个阶段的<a target="_blank" href="http://baike.baidu.com/view/3226.htm" style="text-decoration: underline; color: #136ec2; ">信息技术</a>中，人们搜集大量有关事物和行为的数据，二者都常常具有位置注释信息。所有这些包含位置数据的不同数据集均可利用地图通过令人惊奇的图形化方式呈现出来。mashup 蓬勃发展的一种主要动力就是 Google 公开了自己的 Google Maps API。这仿佛打开了一道大门，让 Web 开发人员(包括爱好者、修补程序开发人员和其他一些人)可以在地图中包含所有类型的数据(从原子弹灾难到<a target="_blank" href="http://baike.baidu.com/view/88690.htm" style="text-decoration: underline; color: #136ec2; ">波士顿</a>的 CowParade 奶牛都可以)。为了不落于人后，Microsoft(Virtual Earth)、Yahoo(Yahoo Maps)和 AOL(MapQuest)也很快相继公开了自己的 API。<h3><a name="5_2" style="text-decoration: underline; color: rgb(19, 110, 194); "></a>视频和图象 Mashup</h3>　　图像主机和<a target="_blank" href="http://baike.baidu.com/view/1405540.htm" style="text-decoration: underline; color: #136ec2; ">社交网络</a>站点(例如 Flickr 使用自己的 API 来共享图像)的兴起导致出现了很多有趣的 mashup。由于内容提供者拥有与其保存的图像相关的元数据(例如谁拍的照片，照片的内容是什么，在何时何地拍摄的等等)，mashup 的设计者可以将这些照片和其他与元数据相关的信息放到一起。例如，mashup 可以对歌曲或诗词进行分析，从而将相关照片拼接在一起，或者基于相同的照片元数据(标题、时间戳或其他元数据)显示社交网络图。另外一个例子可能以一个 Web 站点(例如 CNN 之类的新闻站点)作为输入，并在新闻中通过照片匹配而将照片中的内容以文字的形式呈现出来。<h3><a name="5_3" style="text-decoration: underline; color: rgb(19, 110, 194); "></a>搜索和购物 Mashup</h3>　　搜索和购物 mashup 在 mashup 这个术语出现之前就已经存在很长时间了。在 Web API 出现之前，有相当多的购物工具，例如 BizRate、PriceGrabber、MySimon 和 Google 的 Froogle，都使用了 B2B 技术或屏幕抓取的方式来累计相关的价格数据。为了促进 mashup 和其他有趣的 Web 应用程序的发展，诸如 eBay 和 Amazon 之类的消费网站已经为通过编程访问自己的内容而发布了自己的 API。<h3><a name="5_4" style="text-decoration: underline; color: rgb(19, 110, 194); "></a>新闻 Mashup</h3>　　新闻源(例如纽约时报、BBC 或路透社)已从 2002 年起使用 RSS 和 Atom 之类的联合技术来发布各个主题的新闻提要。以联合技术为基础的 mashup 可以聚集一名用户的提要，并将其通过 Web 呈现出来，创建个性化的报纸，从而满足读者独特的兴趣。<h3><a name="5_5" style="text-decoration: underline; color: rgb(19, 110, 194); "></a>微博 Mashup</h3>　　将多个微博在一个平台上进行聚合显示， 在一个平台上可以同时绑定多个微博(腾讯微博、新浪微博、搜狐微博、网易微博、人人网、豆瓣、饭否、嘀咕、Follow5、天涯微博、人间网、做啥、9911、同学网、开心网等)，从而满足用户同步多个平台的要求，提供了微博信息汇总表，让用户方便查看自己所有平台的粉丝，关注和微博数，轻松实现在不同微博间自由切换。并且提供多微博评论列表读取，跨平台分享，聚合收藏等功能。使用户可在同一屏幕中同步收发信息，实现了真正意义上的社交网站双向聚合。类似网站功能的有玛撒网，微博通等。<div style="height: 30px; line-height: 30px; overflow-x: hidden; overflow-y: hidden; clear: both; "></div><div style="clear: both; font-size: 0px; line-height: 0; height: 0px; visibility: visible; "></div></div><div style="clear: both; font-size: 0px; line-height: 0; height: 0px; visibility: visible; "></div><div id="lemmaExtend" style="font-size: 12px; "><dl log-set-param"="" data-nslog-type="1" id="viewExtRead" log-set-param="ext_reader" style="margin-top: 0px; margin-right: 0px; margin-bottom: 30px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; "><dt style="margin-top: 0px; margin-right: 0px; margin-bottom: 10px; margin-left: 0px; padding-top: 2px; padding-right: 0px; padding-bottom: 5px; padding-left: 0px; border-bottom-width: 1px; border-bottom-style: dashed; border-bottom-color: #cccccc; font-weight: bold; line-height: 1; font-size: 14px; ">扩展阅读：</dt><dd style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; color: #333333; word-wrap: break-word; word-break: break-all; "><ul style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; list-style-type: none; list-style-position: initial; list-style-image: initial; "><li style="margin-top: 12px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; list-style-type: none; zoom: 1; width: 690px; font-size: 12px; "><span style="float: left; "><span style="float: left; font-size: 10px; font-weight: bold; height: 16px; line-height: 16px; text-align: right; padding-left: 4px; background-image: initial; background-attachment: initial; background-origin: initial; background-clip: initial; background-color: #eeeeee; color: #999999; background-position: initial initial; background-repeat: initial initial; ">1</span></span><p line-1"="" style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 26px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; "><a target="_blank" href="http://dotnet.csdn.net/n/20060316/88236.html" style="text-decoration: underline; color: #136ec2; ">http://dotnet.csdn.net/n/20060316/88236.html</a></p></li><li style="margin-top: 12px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; list-style-type: none; zoom: 1; width: 690px; font-size: 12px; "><span style="float: left; "><span style="float: left; font-size: 10px; font-weight: bold; height: 16px; line-height: 16px; text-align: right; padding-left: 4px; background-image: initial; background-attachment: initial; background-origin: initial; background-clip: initial; background-color: #eeeeee; color: #999999; background-position: initial initial; background-repeat: initial initial; ">2</span></span><p line-1"="" style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 26px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; "><a target="_blank" href="http://www.robotbb.com/" style="text-decoration: underline; color: #136ec2; ">http://www.robotbb.com</a></p></li><li style="margin-top: 12px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; list-style-type: none; zoom: 1; width: 690px; font-size: 12px; "><span style="float: left; "><span style="float: left; font-size: 10px; font-weight: bold; height: 16px; line-height: 16px; text-align: right; padding-left: 4px; background-image: initial; background-attachment: initial; background-origin: initial; background-clip: initial; background-color: #eeeeee; color: #999999; background-position: initial initial; background-repeat: initial initial; ">3</span></span><p line-1"="" style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 26px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; ">IBM Developworks上有更详细的资料：<a target="_blank" href="http://www.ibm.com/developerworks/cn/xml/x-mashups.html" style="text-decoration: underline; color: #136ec2; ">http://www.ibm.com/developerworks/cn/xml/x-mashups.html</a></p></li></ul></dd></dl></div></span></div><div><span style="line-height: 24px; "></span></div></span></div><img src ="http://www.blogjava.net/xiaomage234/aggbug/364310.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/xiaomage234/" target="_blank">小马歌</a> 2011-11-19 12:41 <a href="http://www.blogjava.net/xiaomage234/archive/2011/11/19/364310.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>使用 JSONP 实现跨域通信，第 1 部分: 结合 JSONP 和 jQuery 快速构建强大的 mashup【转】</title><link>http://www.blogjava.net/xiaomage234/archive/2011/11/19/364309.html</link><dc:creator>小马歌</dc:creator><author>小马歌</author><pubDate>Sat, 19 Nov 2011 04:40:00 GMT</pubDate><guid>http://www.blogjava.net/xiaomage234/archive/2011/11/19/364309.html</guid><wfw:comment>http://www.blogjava.net/xiaomage234/comments/364309.html</wfw:comment><comments>http://www.blogjava.net/xiaomage234/archive/2011/11/19/364309.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/xiaomage234/comments/commentRss/364309.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/xiaomage234/services/trackbacks/364309.html</trackback:ping><description><![CDATA[<div><span style="font-family: Simsun; line-height: normal; "><table bgcolor="#FFFFFF" width="100%" cellpadding="0" cellspacing="0"><tbody><tr><td style="font-size: 14px; ">由&nbsp;<a href="&#109;&#97;&#105;&#108;&#116;&#111;&#58;&#121;&#97;&#110;&#103;&#46;&#121;&#46;&#121;&#105;&#64;&#103;&#109;&#97;&#105;&#108;&#46;&#99;&#111;&#109;" style="font-size: 14px; ">yangyi</a>&nbsp;于 2009-05-31 22:28:36 提供</td></tr><tr><td style="font-size: 14px; "><br /><br /><center></center><p>2009 年 5 月 25 日</p><blockquote>随着公开提供的 Web 服务 API 不断增加，现在可以轻松地从不同 Web 源获取资源并构建 mashup &#8212;&#8212; 只要您能访问正确的 API 和工具。探究如何能够结合高深的跨域调用技术（JSONP）和灵活的 JavaScript 库（jQuery），以快速构建强大的 mashup。</blockquote><p><a name="intro" style="font-size: 14px; ">简介</a></p><p>Asynchronous JavaScript and XML (Ajax) 是驱动新一代 Web 站点（流行术语为 Web 2.0 站点）的关键技术。Ajax 允许在不干扰 Web 应用程序的显示和行为的情况下在后台进行数据检索。使用&nbsp;<code>XMLHttpRequest</code>&nbsp;函数获取数据，它是一种 API，允许客户端 JavaScript 通过 HTTP 连接到远程服务器。Ajax 也是许多 mashup 的驱动力，它可将来自多个地方的内容集成为单一 Web 应用程序。</p><p>不过，由于受到浏览器的限制，该方法不允许跨域通信。如果尝试从不同的域请求数据，会出现安全错误。如果能控制数据驻留的远程服务器并且每个请求都前往同一域，就可以避免这些安全错误。但是，如果仅停留在自己的服务器上，Web 应用程序还有什么用处呢？如果需要从多个第三方服务器收集数据时，又该怎么办？</p><p><a name="same_origin_policy" style="font-size: 14px; ">理解同源策略限制</a></p><p>同源策略阻止从一个域上加载的脚本获取或操作另一个域上的文档属性。也就是说，受到请求的 URL 的域必须与当前 Web 页面的域相同。这意味着浏览器隔离来自不同源的内容，以防止它们之间的操作。这个浏览器策略很旧，从 Netscape Navigator 2.0 版本开始就存在。</p><p>克服该限制的一个相对简单的方法是让 Web 页面向它源自的 Web 服务器请求数据，并且让 Web 服务器像代理一样将请求转发给真正的第三方服务器。尽管该技术获得了普遍使用，但它是不可伸缩的。另一种方式是使用框架要素在当前 Web 页面中创建新区域，并且使用&nbsp;<code>GET</code>&nbsp;请求获取任何第三方资源。不过，获取资源后，框架中的内容会受到同源策略的限制。</p><p>克服该限制更理想方法是在 Web 页面中插入动态脚本元素，该页面源指向其他域中的服务 URL 并且在自身脚本中获取数据。脚本加载时它开始执行。该方法是可行的，因为同源策略不阻止动态脚本插入，并且将脚本看作是从提供 Web 页面的域上加载的。但如果该脚本尝试从另一个域上加载文档，就不会成功。幸运的是，通过添加 JavaScript Object Notation (JSON) 可以改进该技术。</p><p><a name="json_jsonp" style="font-size: 14px; ">JSON 和 JSONP</a></p><p>JSON 是用于在浏览器和服务器之间交换信息的轻量级数据格式（与 XML 相比）。JOSON 依赖于 JavaScript 开发人员，因为它是 JavaScript 对象的字符串表示。例如，假设有一个含两个属性的 ticker 对象：symbol 和 price。这是在 JavaScript 中定义 ticker 对象的方式：</p><table width="100%" cellpadding="0" cellspacing="0" border="0"><tbody><tr><td style="font-size: 14px; background-color: #eeeeee; border-top-width: 1px; border-right-width: 1px; border-bottom-width: 1px; border-left-width: 1px; border-top-style: solid; border-right-style: solid; border-bottom-style: solid; border-left-style: solid; border-top-color: #cccccc; border-right-color: #cccccc; border-bottom-color: #cccccc; border-left-color: #cccccc; padding-top: 5px; padding-right: 5px; padding-bottom: 5px; padding-left: 5px; "><pre style="margin-top: 0px; margin-bottom: 0px; font-family: 'Andale Mono', 'Lucida Console', Monaco, fixed, monospace; font-size: 11px; ">var ticker = {symbol: 'IBM', price: 91.42};</pre></td></tr></tbody></table><br /><p>并且这是它的 JSON 表示方式：</p><table width="100%" cellpadding="0" cellspacing="0" border="0"><tbody><tr><td style="font-size: 14px; background-color: #eeeeee; border-top-width: 1px; border-right-width: 1px; border-bottom-width: 1px; border-left-width: 1px; border-top-style: solid; border-right-style: solid; border-bottom-style: solid; border-left-style: solid; border-top-color: #cccccc; border-right-color: #cccccc; border-bottom-color: #cccccc; border-left-color: #cccccc; padding-top: 5px; padding-right: 5px; padding-bottom: 5px; padding-left: 5px; "><pre style="margin-top: 0px; margin-bottom: 0px; font-family: 'Andale Mono', 'Lucida Console', Monaco, fixed, monospace; font-size: 11px; ">{symbol: 'IBM', price: 91.42}</pre></td></tr></tbody></table><br /><p>从&nbsp;<a href="http://www.chineselinuxuniversity.net/articles/24069.shtml#resources" style="font-size: 14px; ">参考资料</a>&nbsp;查找更多有关 JSON 和将其作为数据内部交换格式的信息。清单 1 定义了一个 JavaScript 函数，调用该函数时会显示 IBM 的股价。（我们没有详细介绍如何将该函数添加到 Web 页面）。</p><br /><a name="N100BF" style="font-size: 14px; "><strong>清单 1. 定义 showPrice 函数</strong></a><br /><table width="100%" cellpadding="0" cellspacing="0" border="0"><tbody><tr><td style="font-size: 14px; background-color: #eeeeee; border-top-width: 1px; border-right-width: 1px; border-bottom-width: 1px; border-left-width: 1px; border-top-style: solid; border-right-style: solid; border-bottom-style: solid; border-left-style: solid; border-top-color: #cccccc; border-right-color: #cccccc; border-bottom-color: #cccccc; border-left-color: #cccccc; padding-top: 5px; padding-right: 5px; padding-bottom: 5px; padding-left: 5px; "><pre style="margin-top: 0px; margin-bottom: 0px; font-family: 'Andale Mono', 'Lucida Console', Monaco, fixed, monospace; font-size: 11px; ">function showPrice(data) {     alert("Symbol: " + data.symbol + ", Price: " + data.price); }                 </pre></td></tr></tbody></table><br /><p>可以将 JSON 数据作为参数传递，以调用该函数：</p><table width="100%" cellpadding="0" cellspacing="0" border="0"><tbody><tr><td style="font-size: 14px; background-color: #eeeeee; border-top-width: 1px; border-right-width: 1px; border-bottom-width: 1px; border-left-width: 1px; border-top-style: solid; border-right-style: solid; border-bottom-style: solid; border-left-style: solid; border-top-color: #cccccc; border-right-color: #cccccc; border-bottom-color: #cccccc; border-left-color: #cccccc; padding-top: 5px; padding-right: 5px; padding-bottom: 5px; padding-left: 5px; "><pre style="margin-top: 0px; margin-bottom: 0px; font-family: 'Andale Mono', 'Lucida Console', Monaco, fixed, monospace; font-size: 11px; ">showPrice({symbol: 'IBM', price: 91.42}); // alerts: Symbol: IBM, Price: 91.42                 </pre></td></tr></tbody></table><br /><p>现在准备将这两个步骤包含到 Web 页面，如清单 2 所示。</p><br /><a name="N100D1" style="font-size: 14px; "><strong>清单 2. 在 Web 页面中包含 showPrice 函数和参数</strong></a><br /><table width="100%" cellpadding="0" cellspacing="0" border="0"><tbody><tr><td style="font-size: 14px; background-color: #eeeeee; border-top-width: 1px; border-right-width: 1px; border-bottom-width: 1px; border-left-width: 1px; border-top-style: solid; border-right-style: solid; border-bottom-style: solid; border-left-style: solid; border-top-color: #cccccc; border-right-color: #cccccc; border-bottom-color: #cccccc; border-left-color: #cccccc; padding-top: 5px; padding-right: 5px; padding-bottom: 5px; padding-left: 5px; "><pre style="margin-top: 0px; margin-bottom: 0px; font-family: 'Andale Mono', 'Lucida Console', Monaco, fixed, monospace; font-size: 11px; ">&lt;script type="text/javascript"&gt; function showPrice(data) {     alert("Symbol: " + data.symbol + ", Price: " + data.price); } &lt;/script&gt; &lt;script type="text/javascript"&gt;showPrice({symbol: 'IBM', price: 91.42});&lt;/script&gt; </pre></td></tr></tbody></table><br /><p>加载页面后，应该看如图 1 所示的警告。</p><br /><a name="ticker" style="font-size: 14px; "><strong>图 1. IBM ticker</strong></a><br /><img alt="IBM ticker" height="126" src="http://www.ibm.com/developerworks/cn/web/wa-aj-jsonp1/ticker.jpg" width="326" />&nbsp;<br /><p>至此，本文已展示了如何将静态 JSON 数据作为参数调用 JavaScript 函数。不过，通过在函数调用中动态包装 JSON 数据可以用动态数据调用函数，这是一种动态 JavaScript 插入的技术。要查看其效果，将下面一行放入名为 ticker.js 的独立 JavaScript 文件中。</p><table width="100%" cellpadding="0" cellspacing="0" border="0"><tbody><tr><td style="font-size: 14px; background-color: #eeeeee; border-top-width: 1px; border-right-width: 1px; border-bottom-width: 1px; border-left-width: 1px; border-top-style: solid; border-right-style: solid; border-bottom-style: solid; border-left-style: solid; border-top-color: #cccccc; border-right-color: #cccccc; border-bottom-color: #cccccc; border-left-color: #cccccc; padding-top: 5px; padding-right: 5px; padding-bottom: 5px; padding-left: 5px; "><pre style="margin-top: 0px; margin-bottom: 0px; font-family: 'Andale Mono', 'Lucida Console', Monaco, fixed, monospace; font-size: 11px; ">showPrice({symbol: 'IBM', price: 91.42});</pre></td></tr></tbody></table><br /><p>现在改变 Web 页面中的脚本，使其和清单 3 一样。</p><br /><a name="N100F5" style="font-size: 14px; "><strong>清单 3. 动态 JavaScript 插入代码</strong></a><br /><table width="100%" cellpadding="0" cellspacing="0" border="0"><tbody><tr><td style="font-size: 14px; background-color: #eeeeee; border-top-width: 1px; border-right-width: 1px; border-bottom-width: 1px; border-left-width: 1px; border-top-style: solid; border-right-style: solid; border-bottom-style: solid; border-left-style: solid; border-top-color: #cccccc; border-right-color: #cccccc; border-bottom-color: #cccccc; border-left-color: #cccccc; padding-top: 5px; padding-right: 5px; padding-bottom: 5px; padding-left: 5px; "><pre style="margin-top: 0px; margin-bottom: 0px; font-family: 'Andale Mono', 'Lucida Console', Monaco, fixed, monospace; font-size: 11px; ">&lt;script type="text/javascript"&gt; // This is our function to be called with JSON data function showPrice(data) {     alert("Symbol: " + data.symbol + ", Price: " + data.price); } var url = &#8220;ticker.js&#8221;; // URL of the external script // this shows dynamic script insertion var script = document.createElement('script'); script.setAttribute('src', url);  // load the script document.getElementsByTagName('head')[0].appendChild(script);  &lt;/script&gt; 				</pre></td></tr></tbody></table><br /><p>在清单 3 所示的例子中，动态插入的 JavaScript 代码位于 ticker.js 文件中，它将真正的 JSON 数据作为参数调用<code>showPrice()</code>函数。</p><p>前面已经提到，同源策略不阻止将动态脚本元素插入文档中。也就是说，可以动态插入来自不同域的 JavaScript，并且这些域都携带 JSON 数据。这其实是真正的 JSONP（JSON with Padding）：打包在函数调用中的 JSON 数据。注意，为了完成该操作，Web 页面必须在插入时具有已经定义好的回调函数，也就是我们例子中的&nbsp;<code>showPrice()</code>。</p><p>不过，所谓的 JSONP 服务（或 Remote JSON Service）是一种带有附加功能的 Web 服务，该功能支持在特定于用户的函数调用中打包返回的 JSON 数据。这种方法依赖于接受回调函数名作为请求参数的远程服务。然后该服务生成对该函数的调用，将 JSON 数据作为参数传递，在到达客户端时将其插入 Web 页面并开始执行。</p><br /><table border="0" cellspacing="0" cellpadding="0" width="100%"><tbody><tr><td style="font-size: 14px; "><img width="100%" src="http://www.ibm.com/i/v14/rules/blue_rule.gif" height="1" alt="" /><br /><img alt="" width="8" height="6" border="0" src="http://www.ibm.com/i/c.gif" /></td></tr></tbody></table><table cellspacing="0" cellpadding="0" align="right"><tbody><tr align="right"><td style="font-size: 14px; "><img width="100%" height="4" src="http://www.ibm.com/i/c.gif" alt="" /><br /><table border="0" cellpadding="0" cellspacing="0"><tbody><tr><td valign="middle" style="font-size: 14px; "><img width="16" src="http://www.ibm.com/i/v14/icons/u_bold.gif" height="16" border="0" alt="" /><br /></td><td valign="top" align="right" style="font-size: 14px; "><a href="http://www.chineselinuxuniversity.net/articles/24069.shtml#main" style="font-size: 12px; font-family: verdana, nsimSun, arial, sans-serif; line-height: 13px; "><strong>回页首</strong></a></td></tr></tbody></table></td></tr></tbody></table><br /><br /><p><a name="jquery_support" style="font-size: 14px; ">jQuery 的 JSONP 支持</a></p><p>从 1.2 版本开始，jQuery 拥有对 JSONP 回调的本地支持。如果指定了 JSONP 回调，就可以加载位于另一个域的 JSON 数据，回调的语法为：<code>url?callback=?</code>。</p><p>jQuery 自动将&nbsp;<strong>?</strong>&nbsp;替换为要调用的生成函数名。清单 4 显示了该代码。</p><br /><a name="N10124" style="font-size: 14px; "><strong>清单 4. 使用 JSONP 回调</strong></a><br /><table width="100%" cellpadding="0" cellspacing="0" border="0"><tbody><tr><td style="font-size: 14px; background-color: #eeeeee; border-top-width: 1px; border-right-width: 1px; border-bottom-width: 1px; border-left-width: 1px; border-top-style: solid; border-right-style: solid; border-bottom-style: solid; border-left-style: solid; border-top-color: #cccccc; border-right-color: #cccccc; border-bottom-color: #cccccc; border-left-color: #cccccc; padding-top: 5px; padding-right: 5px; padding-bottom: 5px; padding-left: 5px; "><pre style="margin-top: 0px; margin-bottom: 0px; font-family: 'Andale Mono', 'Lucida Console', Monaco, fixed, monospace; font-size: 11px; ">jQuery.getJSON(url+"&amp;callback=?", function(data) {     alert("Symbol: " + data.symbol + ", Price: " + data.price); }); </pre></td></tr></tbody></table><br /><p>为此，jQuery 将一个全局函数附加到插入脚本时需要调用的窗口对象。另外，jQuery 也能优化非跨域调用。如果向同一个域发出请求，jQuery 就将其转化为普通 Ajax 请求。</p><p><a name="sample_jsonp" style="font-size: 14px; ">使用 JSONP 支持的示例服务</a></p><p>在上一个例子中，使用了静态文件（ticker.js）将 JavaScript 动态插入到 Web 页面中。尽管返回了 JSONP 回复，但它不允许您在 URL 中定义回调函数名。这不是 JSONP 服务。因此，如何才能将其转换为真正的 JSONP 服务呢？可使用的方法很多。这里我们将分别使用 PHP 和 Java 展示两个示例。</p><p>首先，假设您的服务在所请求的 URL 中接受了一个名为&nbsp;<code>callback</code>&nbsp;的参数。（参数名不重要，但是客户和服务器必须都同意该名称）。另外假设向服务发送的请求是这样的：</p><table width="100%" cellpadding="0" cellspacing="0" border="0"><tbody><tr><td style="font-size: 14px; background-color: #eeeeee; border-top-width: 1px; border-right-width: 1px; border-bottom-width: 1px; border-left-width: 1px; border-top-style: solid; border-right-style: solid; border-bottom-style: solid; border-left-style: solid; border-top-color: #cccccc; border-right-color: #cccccc; border-bottom-color: #cccccc; border-left-color: #cccccc; padding-top: 5px; padding-right: 5px; padding-bottom: 5px; padding-left: 5px; "><pre style="margin-top: 0px; margin-bottom: 0px; font-family: 'Andale Mono', 'Lucida Console', Monaco, fixed, monospace; font-size: 11px; ">http://www.yourdomain.com/jsonp/ticker?symbol=IBM&amp;callback=showPrice</pre></td></tr></tbody></table><br /><p>在这种情况下，<code>symbol</code>&nbsp;是表示请求 ticker symbol 的请求参数，而&nbsp;<code>callback</code>&nbsp;是 Web 应用程序的回调函数的名称。使用清单 5 所示的代码可以通过 jQuery 的 JSONP 支持调用该服务。</p><br /><a name="N1014F" style="font-size: 14px; "><strong>清单 5. 调用回调服务</strong></a><br /><table width="100%" cellpadding="0" cellspacing="0" border="0"><tbody><tr><td style="font-size: 14px; background-color: #eeeeee; border-top-width: 1px; border-right-width: 1px; border-bottom-width: 1px; border-left-width: 1px; border-top-style: solid; border-right-style: solid; border-bottom-style: solid; border-left-style: solid; border-top-color: #cccccc; border-right-color: #cccccc; border-bottom-color: #cccccc; border-left-color: #cccccc; padding-top: 5px; padding-right: 5px; padding-bottom: 5px; padding-left: 5px; "><pre style="margin-top: 0px; margin-bottom: 0px; font-family: 'Andale Mono', 'Lucida Console', Monaco, fixed, monospace; font-size: 11px; ">jQuery.getJSON("http://www.yourdomain.com/jsonp/ticker?symbol=IBM&amp;callback=?",  function(data) {     alert("Symbol: " + data.symbol + ", Price: " + data.price); }); </pre></td></tr></tbody></table><br /><p>注意，我们使用&nbsp;<code>?</code>&nbsp;作为回调函数名，而非真实的函数名。因为 jQuery 会用生成的函数名替换&nbsp;<code>?</code>。所以您不用定义类似于<code>showPrice()</code>&nbsp;的函数。</p><p>清单 6 显示了用 PHP 实现的 JSONP 服务的一段代码。</p><br /><a name="N10169" style="font-size: 14px; "><strong>清单 6. 用 PHP 实现的 JSONP 服务的代码片段</strong></a><br /><table width="100%" cellpadding="0" cellspacing="0" border="0"><tbody><tr><td style="font-size: 14px; background-color: #eeeeee; border-top-width: 1px; border-right-width: 1px; border-bottom-width: 1px; border-left-width: 1px; border-top-style: solid; border-right-style: solid; border-bottom-style: solid; border-left-style: solid; border-top-color: #cccccc; border-right-color: #cccccc; border-bottom-color: #cccccc; border-left-color: #cccccc; padding-top: 5px; padding-right: 5px; padding-bottom: 5px; padding-left: 5px; "><pre style="margin-top: 0px; margin-bottom: 0px; font-family: 'Andale Mono', 'Lucida Console', Monaco, fixed, monospace; font-size: 11px; ">$jsonData = getDataAsJson($_GET['symbol']); echo $_GET['callback'] . '(' . $jsonData . ');'; // prints: jsonp1232617941775({"symbol" : "IBM", "price" : "91.42"}); </pre></td></tr></tbody></table><br /><p>清单 7 显示了具有同样功能的 Java&#8482; Servlet 方法。</p><br /><a name="N10176" style="font-size: 14px; "><strong>清单 7. 用 Java servlet 实现的 JSONP 服务</strong></a><br /><table width="100%" cellpadding="0" cellspacing="0" border="0"><tbody><tr><td style="font-size: 14px; background-color: #eeeeee; border-top-width: 1px; border-right-width: 1px; border-bottom-width: 1px; border-left-width: 1px; border-top-style: solid; border-right-style: solid; border-bottom-style: solid; border-left-style: solid; border-top-color: #cccccc; border-right-color: #cccccc; border-bottom-color: #cccccc; border-left-color: #cccccc; padding-top: 5px; padding-right: 5px; padding-bottom: 5px; padding-left: 5px; "><pre style="margin-top: 0px; margin-bottom: 0px; font-family: 'Andale Mono', 'Lucida Console', Monaco, fixed, monospace; font-size: 11px; ">@Override protected void doGet(HttpServletRequest req, HttpServletResponse resp)    throws ServletException, IOException { 	String jsonData = getDataAsJson(req.getParameter("symbol")); 	String output = req.getParameter("callback") + "(" + jsonData + ");";  	resp.setContentType("text/javascript");            	PrintWriter out = resp.getWriter(); 	out.println(output); 	// prints: jsonp1232617941775({"symbol" : "IBM", "price" : "91.42"}); } </pre></td></tr></tbody></table><br /><p>那么，如果要构建 mashup 应该怎么办，是从第三方服务器收集内容，并在单一的 Web 页面中显示它们吗？答案很简单：您必须使用第三方 JSONP 服务。这种服务并不少。</p><p><a name="sample_jsonp_services" style="font-size: 14px; ">现成的 JSONP 服务</a></p><p>知道如何使用 JSONP 之后，可以开始使用一些现成的 JSONP Web 服务来构建应用程序和 mashup。下面为接下来的开发项目做准备。（提示：您可以复制特定的 URL 并将其粘贴到浏览器的地址栏，以检查生成的 JSONP 响应）。</p><p>Digg API：来自 Digg 的头条新闻：</p><table width="100%" cellpadding="0" cellspacing="0" border="0"><tbody><tr><td style="font-size: 14px; background-color: #eeeeee; border-top-width: 1px; border-right-width: 1px; border-bottom-width: 1px; border-left-width: 1px; border-top-style: solid; border-right-style: solid; border-bottom-style: solid; border-left-style: solid; border-top-color: #cccccc; border-right-color: #cccccc; border-bottom-color: #cccccc; border-left-color: #cccccc; padding-top: 5px; padding-right: 5px; padding-bottom: 5px; padding-left: 5px; "><pre style="margin-top: 0px; margin-bottom: 0px; font-family: 'Andale Mono', 'Lucida Console', Monaco, fixed, monospace; font-size: 11px; ">http://services.digg.com/stories/top?appkey=http%3A%2F%2Fmashup.com&amp;type=javascript &amp;callback=? </pre></td></tr></tbody></table><br /><p>Geonames API：邮编的位置信息：</p><table width="100%" cellpadding="0" cellspacing="0" border="0"><tbody><tr><td style="font-size: 14px; background-color: #eeeeee; border-top-width: 1px; border-right-width: 1px; border-bottom-width: 1px; border-left-width: 1px; border-top-style: solid; border-right-style: solid; border-bottom-style: solid; border-left-style: solid; border-top-color: #cccccc; border-right-color: #cccccc; border-bottom-color: #cccccc; border-left-color: #cccccc; padding-top: 5px; padding-right: 5px; padding-bottom: 5px; padding-left: 5px; "><pre style="margin-top: 0px; margin-bottom: 0px; font-family: 'Andale Mono', 'Lucida Console', Monaco, fixed, monospace; font-size: 11px; ">http://www.geonames.org/postalCodeLookupJSON?postalcode=10504&amp;country=US&amp;callback=?</pre></td></tr></tbody></table><br /><p>Flickr API：来自 Flickr 的最新猫图片：</p><table width="100%" cellpadding="0" cellspacing="0" border="0"><tbody><tr><td style="font-size: 14px; background-color: #eeeeee; border-top-width: 1px; border-right-width: 1px; border-bottom-width: 1px; border-left-width: 1px; border-top-style: solid; border-right-style: solid; border-bottom-style: solid; border-left-style: solid; border-top-color: #cccccc; border-right-color: #cccccc; border-bottom-color: #cccccc; border-left-color: #cccccc; padding-top: 5px; padding-right: 5px; padding-bottom: 5px; padding-left: 5px; "><pre style="margin-top: 0px; margin-bottom: 0px; font-family: 'Andale Mono', 'Lucida Console', Monaco, fixed, monospace; font-size: 11px; ">http://api.flickr.com/services/feeds/photos_public.gne?tags=cat&amp;tagmode=any &amp;format=json&amp;jsoncallback=?                 </pre></td></tr></tbody></table><br /><p>Yahoo Local Search API：在邮编为 10504 的地区搜索比萨：</p><table width="100%" cellpadding="0" cellspacing="0" border="0"><tbody><tr><td style="font-size: 14px; background-color: #eeeeee; border-top-width: 1px; border-right-width: 1px; border-bottom-width: 1px; border-left-width: 1px; border-top-style: solid; border-right-style: solid; border-bottom-style: solid; border-left-style: solid; border-top-color: #cccccc; border-right-color: #cccccc; border-bottom-color: #cccccc; border-left-color: #cccccc; padding-top: 5px; padding-right: 5px; padding-bottom: 5px; padding-left: 5px; "><pre style="margin-top: 0px; margin-bottom: 0px; font-family: 'Andale Mono', 'Lucida Console', Monaco, fixed, monospace; font-size: 11px; ">http://local.yahooapis.com/LocalSearchService/V3/localSearch?appid=YahooDemo&amp;query=pizza &amp;zip=10504&amp;results=2&amp;output=json&amp;callback=? </pre></td></tr></tbody></table><br /><br /><table border="0" cellspacing="0" cellpadding="0" width="100%"><tbody><tr><td style="font-size: 14px; "><img width="100%" src="http://www.ibm.com/i/v14/rules/blue_rule.gif" height="1" alt="" /><br /><img alt="" width="8" height="6" border="0" src="http://www.ibm.com/i/c.gif" /></td></tr></tbody></table><table cellspacing="0" cellpadding="0" align="right"><tbody><tr align="right"><td style="font-size: 14px; "><img width="100%" height="4" src="http://www.ibm.com/i/c.gif" alt="" /><br /><table border="0" cellpadding="0" cellspacing="0"><tbody><tr><td valign="middle" style="font-size: 14px; "><img width="16" src="http://www.ibm.com/i/v14/icons/u_bold.gif" height="16" border="0" alt="" /><br /></td><td valign="top" align="right" style="font-size: 14px; "><a href="http://www.chineselinuxuniversity.net/articles/24069.shtml#main" style="font-size: 12px; font-family: verdana, nsimSun, arial, sans-serif; line-height: 13px; "><strong>回页首</strong></a></td></tr></tbody></table></td></tr></tbody></table><br /><br /><p><a name="cautionary_note" style="font-size: 14px; ">重要提示</a></p><p>JSONP 是构建 mashup 的强大技术，但不幸的是，它并不是所有跨域通信需求的万灵药。它有一些缺陷，在提交开发资源之前必须认真考虑它们。第一，也是最重要的一点，没有关于 JSONP 调用的错误处理。如果动态脚本插入有效，就执行调用；如果无效，就静默失败。失败是没有任何提示的。例如，不能从服务器捕捉到 404 错误，也不能取消或重新开始请求。不过，等待一段时间还没有响应的话，就不用理它了。（未来的 jQuery 版本可能有终止 JSONP 请求的特性）。</p><p>JSONP 的另一个主要缺陷是被不信任的服务使用时会很危险。因为 JSONP 服务返回打包在函数调用中的 JSON 响应，而函数调用是由浏览器执行的，这使宿主 Web 应用程序更容易受到各类攻击。如果打算使用 JSONP 服务，了解它能造成的威胁非常重要。（参见&nbsp;<a href="http://www.chineselinuxuniversity.net/articles/24069.shtml#resources" style="font-size: 14px; ">参考资料</a>&nbsp;了解更多信息）。</p><br /><table border="0" cellspacing="0" cellpadding="0" width="100%"><tbody><tr><td style="font-size: 14px; "><img width="100%" src="http://www.ibm.com/i/v14/rules/blue_rule.gif" height="1" alt="" /><br /><img alt="" width="8" height="6" border="0" src="http://www.ibm.com/i/c.gif" /></td></tr></tbody></table><table cellspacing="0" cellpadding="0" align="right"><tbody><tr align="right"><td style="font-size: 14px; "><img width="100%" height="4" src="http://www.ibm.com/i/c.gif" alt="" /><br /><table border="0" cellpadding="0" cellspacing="0"><tbody><tr><td valign="middle" style="font-size: 14px; "><img width="16" src="http://www.ibm.com/i/v14/icons/u_bold.gif" height="16" border="0" alt="" /><br /></td><td valign="top" align="right" style="font-size: 14px; "><a href="http://www.chineselinuxuniversity.net/articles/24069.shtml#main" style="font-size: 12px; font-family: verdana, nsimSun, arial, sans-serif; line-height: 13px; "><strong>回页首</strong></a></td></tr></tbody></table></td></tr></tbody></table><br /><br /><p><a name="conclusion" style="font-size: 14px; ">结束语</a></p><p>在该系列的第一篇文章中，我们讲解了如何结合使用 JSONP 和 jQuery 快速构建强大的 mashup。主要主题包括：</p><ul><li style="font-size: 14px; ">浏览器同源策略的限制以及解决办法</li><li style="font-size: 14px; ">作为一种有效的跨域通信技术，JSONP 能够绕过当前浏览器的同源策略限制</li><li style="font-size: 14px; ">JSONP 使 Web 应用程序开发人员能够快速构建 mashup</li><li style="font-size: 14px; ">示例 JSONP 服务及其使用：Ticker 服务</li></ul><p>本系列的下一篇文章将介绍 Yahoo! 查询语言（YQL），这种单端点 JSONP 服务允许您跨 Web 查询、过滤和合并数据。最后还使用 YQL 和 jQuery 构建 mashup 应用程序。</p><br /><br /><p><a name="resources" style="font-size: 14px; ">参考资料</a></p><ul><li style="font-size: 14px; ">了解&nbsp;<a href="http://json.org/" style="font-size: 14px; ">JSON</a>，它是针对 Java 和其他语言的 JavaScript Object Notation API。<br /><br /></li><li style="font-size: 14px; ">阅读 &#8220;<a href="https://www.ibm.com/developerworks/cn/web/wa-ajaxintro10/" style="font-size: 14px; ">掌握 Ajax，第 10 部分: 使用 JSON 进行数据传输</a>&#8221;，并了解在 Ajax 应用程序中使用 JSON 作为数据交换格式。<br /><br /></li><li style="font-size: 14px; ">通过包含三部分的系列文章 &#8220;<a href="https://www.ibm.com/developerworks/cn/web/wa-jquery1/" style="font-size: 14px; ">使用 jQuery</a>&#8221;了解 jQuery。<br /><br /></li><li style="font-size: 14px; "><a href="http://code.google.com/p/browsersec/wiki/Part2#Same-origin_policy" style="font-size: 14px; ">Browser Security Handbook</a>&nbsp;提供关于同源策略的详细描述。<br /><br /></li><li style="font-size: 14px; ">&#8220;<a href="https://www.ibm.com/developerworks/cn/xml/x-ajaxsecurity.html" style="font-size: 14px; ">征服 Ajax 应用程序的安全威胁</a>&#8221;为确保 mashup 应用程序的安全提供技巧和最佳实践。<br /><br /></li><li style="font-size: 14px; ">&#8220;<a href="https://www.ibm.com/developerworks/cn/xml/x-securemashups/" style="font-size: 14px; ">打造安全 Ajax mashup 的未来</a>&#8221;讲解了如何为混合 Web 应用程序改进浏览器。<br /><br /></li><li style="font-size: 14px; ">浏览&nbsp;<a href="http://www.ibm.com/developerworks/apps/SendTo?bookstore=safari" style="font-size: 14px; ">技术书店</a>，阅读有关这些主题和其他技术主题的图书。</li></ul></td></tr></tbody></table></span></div><img src ="http://www.blogjava.net/xiaomage234/aggbug/364309.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/xiaomage234/" target="_blank">小马歌</a> 2011-11-19 12:40 <a href="http://www.blogjava.net/xiaomage234/archive/2011/11/19/364309.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>代码分享 5个有趣的 JavaScript 片段</title><link>http://www.blogjava.net/xiaomage234/archive/2011/08/03/355657.html</link><dc:creator>小马歌</dc:creator><author>小马歌</author><pubDate>Wed, 03 Aug 2011 04:04:00 GMT</pubDate><guid>http://www.blogjava.net/xiaomage234/archive/2011/08/03/355657.html</guid><wfw:comment>http://www.blogjava.net/xiaomage234/comments/355657.html</wfw:comment><comments>http://www.blogjava.net/xiaomage234/archive/2011/08/03/355657.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/xiaomage234/comments/commentRss/355657.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/xiaomage234/services/trackbacks/355657.html</trackback:ping><description><![CDATA[&nbsp;&nbsp;&nbsp;&nbsp; 摘要: 很多人认为编程语言只是用于工作，没有什么乐趣，其实，只要我们发挥奇思妙想，再死板的东西也有有趣的一面。这篇文章告诉大家：使用JavaScript，可以做很多很多有趣的事情。以下代码拷贝到地址栏回车即可运行，赶紧试试吧。　　1. 网页射击游戏　　这个游戏可以在任何网页里面玩，把下面代码粘贴到地址栏回车，按空格键进行射击，W键可前进，A、D键或者方向键可改变射击方向。javascript:var%20...&nbsp;&nbsp;<a href='http://www.blogjava.net/xiaomage234/archive/2011/08/03/355657.html'>阅读全文</a><img src ="http://www.blogjava.net/xiaomage234/aggbug/355657.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/xiaomage234/" target="_blank">小马歌</a> 2011-08-03 12:04 <a href="http://www.blogjava.net/xiaomage234/archive/2011/08/03/355657.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>PHP十年前灭掉Perl，如今也将面临危机</title><link>http://www.blogjava.net/xiaomage234/archive/2011/07/25/355000.html</link><dc:creator>小马歌</dc:creator><author>小马歌</author><pubDate>Mon, 25 Jul 2011 08:33:00 GMT</pubDate><guid>http://www.blogjava.net/xiaomage234/archive/2011/07/25/355000.html</guid><wfw:comment>http://www.blogjava.net/xiaomage234/comments/355000.html</wfw:comment><comments>http://www.blogjava.net/xiaomage234/archive/2011/07/25/355000.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/xiaomage234/comments/commentRss/355000.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/xiaomage234/services/trackbacks/355000.html</trackback:ping><description><![CDATA[<div><span style="color: #444444; font-family: Helvetica, Arial, sans-serif; line-height: 29px; "><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 6px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 10px; padding-left: 0px; word-break: break-all; word-wrap: break-word; text-indent: 2em; ">本文来源于国外一位博友的文章，他在<a href="http://www.phpchina.com/?action-viewnews-itemid-37345" target="_self" style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; word-break: break-all; word-wrap: break-word; color: #617b85; text-decoration: none; "><u style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; word-break: break-all; word-wrap: break-word; "><strong style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; word-break: break-all; word-wrap: break-word; font-style: normal; font-weight: 700; ">博客</strong></u></a>中写道：&#8220;是到了<a href="http://www.phpchina.com/?action-viewnews-itemid-37345" target="_self" style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; word-break: break-all; word-wrap: break-word; color: #617b85; text-decoration: none; "><u style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; word-break: break-all; word-wrap: break-word; "><strong style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; word-break: break-all; word-wrap: break-word; font-style: normal; font-weight: 700; ">PHP</strong></u></a>落幕的时候了。就在我这个顽固的PHP分子正要把一个现有的Ruby on Rails代码库转换成PHP时，我要说这样的话&#8221;。</p><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 6px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 10px; padding-left: 0px; word-break: break-all; word-wrap: break-word; text-indent: 2em; "><strong style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; word-break: break-all; word-wrap: break-word; ">历史在重演</strong></p><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 6px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 10px; padding-left: 0px; word-break: break-all; word-wrap: break-word; text-indent: 2em; ">作者认为PHP将亡，因为我以前见到过。大概十年之前，PHP灭掉了Perl。当然了，并不十分彻底；它还坚守在某些环境里，它还有相当可观数量的顽固粉丝，遗留下来的<a href="http://www.phpchina.com/?action-viewnews-itemid-37345" target="_self" style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; word-break: break-all; word-wrap: break-word; color: #617b85; text-decoration: none; "><u style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; word-break: break-all; word-wrap: break-word; "><strong style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; word-break: break-all; word-wrap: break-word; font-style: normal; font-weight: 700; ">应用</strong></u></a>程序也需要维护，持续几十年。但这种语言对于新一代的人，特别是&nbsp;<a href="http://www.phpchina.com/?action-viewnews-itemid-37345" target="_self" style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; word-break: break-all; word-wrap: break-word; color: #617b85; text-decoration: none; "><u style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; word-break: break-all; word-wrap: break-word; "><strong style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; word-break: break-all; word-wrap: break-word; font-style: normal; font-weight: 700; ">web</strong></u></a><a href="http://www.phpchina.com/?action-viewnews-itemid-37345" target="_self" style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; word-break: break-all; word-wrap: break-word; color: #617b85; text-decoration: none; "><u style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; word-break: break-all; word-wrap: break-word; "><strong style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; word-break: break-all; word-wrap: break-word; font-style: normal; font-weight: 700; ">开发</strong></u></a>者，它在1999年就开始灭亡了，到2005年左右几乎完全死了。</p><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 6px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 10px; padding-left: 0px; word-break: break-all; word-wrap: break-word; text-indent: 2em; "></p><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 6px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 10px; padding-left: 0px; word-break: break-all; word-wrap: break-word; text-indent: 2em; ">作为在那个时期出现的新的web开发者，事情显的很明白而且水到渠成：Perl已经不适应新的应用开发环境了。在Perl里，页面需要冗长的公式化的CGI方式实现，而这些在PHP里却可以用基本的、缺省的编程方式实现。Perl语言里到处都是旧时代的特征 &#8212; 引用，不方便的数据结构，还有其他许多的小的古怪语法语义 &#8212;&#8212; 这使得web开发冗长，不稳定，不方便。无怪乎没有一个出色的web应用是用Perl写成的，而用PHP你却能做的又快又简单，尽管PHP存在着在当时就显而易见的缺陷。</p><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 6px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 10px; padding-left: 0px; word-break: break-all; word-wrap: break-word; text-indent: 2em; "></p><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 6px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 10px; padding-left: 0px; word-break: break-all; word-wrap: break-word; text-indent: 2em; ">在1999年支持Perl反对PHP的争论有很多：Perl要快的多，有更多的程序库和驱动支持，CPAN是个神奇的地方，里面预先写好的代码能让你绝大部分任务省去80%的工作量。现在看起来这些就有点可笑了，但&#8220;PHP缺乏可扩展性&#8221;却是个真正的缺点。但总之PHP赢了，因为上面所说的这些问题并不是这种语言固有的。PHP解释器可以变得更快，程序库可以被开发出来，PERA和PECL目前已经变得相当庞大，这还不包括各种厂商希望人们去使用他们的API而提供的非正式的程序库。</p><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 6px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 10px; padding-left: 0px; word-break: break-all; word-wrap: break-word; text-indent: 2em; "></p><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 6px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 10px; padding-left: 0px; word-break: break-all; word-wrap: break-word; text-indent: 2em; "><strong style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; word-break: break-all; word-wrap: break-word; ">时间在推移</strong></p><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 6px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 10px; padding-left: 0px; word-break: break-all; word-wrap: break-word; text-indent: 2em; ">十年之后，我可以感觉到历史大潮正在重演。开发人员对语言的期望在前进。如果说 Perl最缺乏的是PHP里令人惊讶的灵活的&#8220;关联数组&#8221;(也就是智 能哈希表)，那么PHP现在缺乏的就是lambdas和方法链(method chaining)了。同时PHP往往是用在只要20行代码就能写出一个网页的地方，而如今却是如果你不使用什么MVC框架之类的东西就会被认为没有把事情做对。公式化的代码表明了问题所在：这种语言需要一个框架来替人们做这些事情。</p><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 6px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 10px; padding-left: 0px; word-break: break-all; word-wrap: break-word; text-indent: 2em; "></p><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 6px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 10px; padding-left: 0px; word-break: break-all; word-wrap: break-word; text-indent: 2em; ">退回到以前，我认为那些顽固的使用Perl来做web开发的人很傻。现在，经历了十年的PHP开发，我处在相同的位置上了。我可以在一个小时里用 PHP敲出一个不错的网站，在一两天里开发出一个优秀的网站。PHP的性能众人皆知，我可以无限的扩展它。我雇佣过的每个开发人员都会它，我集成过的每个系统里都有一个用它写出的打包的代码库。我深陷于PHP的方便性，尽管它对于我的任务并不是一个合适的语言。<br /><div><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 6px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 10px; padding-left: 0px; word-break: break-all; word-wrap: break-word; text-indent: 2em; "><strong style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; word-break: break-all; word-wrap: break-word; ">转向Ruby on Rails</strong></p><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 6px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 10px; padding-left: 0px; word-break: break-all; word-wrap: break-word; text-indent: 2em; ">最明显有潜在能力继任PHP的是Ruby on Rails。Ruby是一个新的、干净的语言，具有现代的语言特征，松散、优雅的语法(很像Python)。Rails省去了我们常见的任务，省去了集成 web应用里的公式化的做法，把PHP里三、四行的习惯写法变成了first-class语言结构。这看起来极其像我需要的PHP替代品、能让开发工作再一次提速的东西。</p><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 6px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 10px; padding-left: 0px; word-break: break-all; word-wrap: break-word; text-indent: 2em; "></p><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 6px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 10px; padding-left: 0px; word-break: break-all; word-wrap: break-word; text-indent: 2em; ">我每天使用Rails，修改一个喜爱这种框架和语言的有经验的Rails专家所写的Rails应用，七个月后，我却不能断言Rails是一个正确的选择了，原因很难表达。我这篇文章的目的就是想试图把原因说清楚。</p><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 6px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 10px; padding-left: 0px; word-break: break-all; word-wrap: break-word; text-indent: 2em; "></p><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 6px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 10px; padding-left: 0px; word-break: break-all; word-wrap: break-word; text-indent: 2em; ">我的主要的抱怨，必须要提的，就是性能。我之前就说过这种问题不应该被当作一种语言的致命缺陷，它只是语言实现中的暂时的问题。所以我不能把这当作一个真正的问题，尽管它是我把现在的应用移植到PHP的最主要的一个原因。我可以让Rails跑的跟PHP一样快，但那需要提供2到4倍高的硬件条件。我估计五年内将还会这样，五年后我也许不必把程序移植到PHP。但现在，它不能满足我的要求。</p><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 6px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 10px; padding-left: 0px; word-break: break-all; word-wrap: break-word; text-indent: 2em; "></p><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 6px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 10px; padding-left: 0px; word-break: break-all; word-wrap: break-word; text-indent: 2em; ">第二，我讨厌Active Record。Active Record是一种模式，并不是Ruby固有的，在Rails的最新版本里是可选择的，但是对它的使用和这种模式已经深入到了Rails的DNA里了。我之前曾解释过为什么我认为这数据库上的ORM不是个好做法，所以我不会再重复解释,但有一点我需要总结的就是你省去了手工写CRUD所获得的效能要大于 ActiveRecord做傻事所损失的效能，要花时间搞清楚它是怎么工作的，顺应框架原则，防止它做这样的事情。</p><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 6px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 10px; padding-left: 0px; word-break: break-all; word-wrap: break-word; text-indent: 2em; "></p><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 6px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 10px; padding-left: 0px; word-break: break-all; word-wrap: break-word; text-indent: 2em; ">第三，我十分的不信任代码自动生成。工具能帮你生成模板式的代码很有用，但你的程序了却多出了成堆的毫无用处的代码来实现这些目的，这就变的不好了。代码生成喜欢&#8220;神奇推理&#8221;，因为生成器并不确定代码某些特别有用的特征究竟是专门写出的还是语言环境固有自带的。神奇推理是危险的。</p><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 6px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 10px; padding-left: 0px; word-break: break-all; word-wrap: break-word; text-indent: 2em; "></p><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 6px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 10px; padding-left: 0px; word-break: break-all; word-wrap: break-word; text-indent: 2em; ">代码生成让我想到了Ruby on Rails的一个可能是最根本的问题，就是它并不是一种语言。Ruby是一种语言。但Ruby，它在解决了PHP上的一些基本问题外，并没有解决核心问题，那就是现代web应用需要一系列的改进：像routing,model/view分类，drop-in功能性等都是很常见的特征。Rails里有，但这跟PHP里的Zend，Symfony 和 Code Igniter之类的MVC框架一样只是绑上去的绷带。</p><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 6px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 10px; padding-left: 0px; word-break: break-all; word-wrap: break-word; text-indent: 2em; "></p><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 6px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 10px; padding-left: 0px; word-break: break-all; word-wrap: break-word; text-indent: 2em; "><strong style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; word-break: break-all; word-wrap: break-word; ">那么缺的是什么?</strong></p><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 6px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 10px; padding-left: 0px; word-break: break-all; word-wrap: break-word; text-indent: 2em; ">能够取代PHP的语言必须十分优秀于PHP，就如同PHP优秀于Perl一样。它必须承担起web应用的主要实现任务，就像PHP那样，你的代码的 主要功能就是输出网页 &#8212;&#8212; 一个有点激进的要求，它要不适合去做其它的事情，例如当中shell脚本语言。我希望有这样一种语言，它能够承担起我开发一个MVC式的web应用时的所有的任务，所有功能都是核心内置的，不能仅是一个程序包。</p><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 6px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 10px; padding-left: 0px; word-break: break-all; word-wrap: break-word; text-indent: 2em; "></p><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 6px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 10px; padding-left: 0px; word-break: break-all; word-wrap: break-word; text-indent: 2em; ">问题是，没有这样的一种语言。有一段时间服务器端JavaScript看起来将会成为下一个重要的语言，它能统一web应用前端和后端的编程语言。但是这些JavaScript上的伟大思想总是徘徊在一些跑题的行为上，比如 nodejs：事件驱动模式非常的激进和强大，能让你开发出高性能的应用程序，最大化的使用新式硬件，但这是一种开发服务器端应用程序的思路，不是web 页面。并且你仍然需要去写一大堆可怕的web页面。另外一些CommonJS的成果例如ejScript开始尝试着取代PHP，但仍没有解决框架问题。</p><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 6px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 10px; padding-left: 0px; word-break: break-all; word-wrap: break-word; text-indent: 2em; "></p><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 6px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 10px; padding-left: 0px; word-break: break-all; word-wrap: break-word; text-indent: 2em; "><strong style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; word-break: break-all; word-wrap: break-word; ">仍在等待</strong></p><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 6px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 10px; padding-left: 0px; word-break: break-all; word-wrap: break-word; text-indent: 2em; ">我不得不做出结论，PHP的替代者还不存在。Ruby on Rails很好，但并不比一个PHP之上的类似的MVC框架强多少，更别提由于Ruby自身的效率不高和ActiveRecord的ORM恶搞带来的双重打击。Python看起来并不感兴趣于作为下一代的web语言，JavaScript的服务器端解决方案还刚刚只是个开始。</p><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 6px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 10px; padding-left: 0px; word-break: break-all; word-wrap: break-word; text-indent: 2em; "></p><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 6px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 10px; padding-left: 0px; word-break: break-all; word-wrap: break-word; text-indent: 2em; ">我等待下一个大目标的出现。我希望能从PHP上转走，真的。我可不想成为Perl式的古董。但不管怎样，这种语言看起来还不存在。我判断错了吗？</p></div></p></span></div><img src ="http://www.blogjava.net/xiaomage234/aggbug/355000.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/xiaomage234/" target="_blank">小马歌</a> 2011-07-25 16:33 <a href="http://www.blogjava.net/xiaomage234/archive/2011/07/25/355000.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title> AJAX（XMLHttpRequest）进行跨域请求方法详解</title><link>http://www.blogjava.net/xiaomage234/archive/2011/07/25/354998.html</link><dc:creator>小马歌</dc:creator><author>小马歌</author><pubDate>Mon, 25 Jul 2011 08:22:00 GMT</pubDate><guid>http://www.blogjava.net/xiaomage234/archive/2011/07/25/354998.html</guid><wfw:comment>http://www.blogjava.net/xiaomage234/comments/354998.html</wfw:comment><comments>http://www.blogjava.net/xiaomage234/archive/2011/07/25/354998.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/xiaomage234/comments/commentRss/354998.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/xiaomage234/services/trackbacks/354998.html</trackback:ping><description><![CDATA[&nbsp;&nbsp;&nbsp;&nbsp; 摘要: 注意：以下代码请在Firefox 3.5、Chrome 3.0、Safari 4之后的版本中进行测试。IE8的实现方法与其他浏览不同。&nbsp;跨域请求，顾名思义，就是一个站点中的资源去访问另外一个不同域名站点上的资源。这种情况很常见，比如说通过 style 标签加载外部样式表文件、通过 img 标签加载外部图片、通过 script 标签加载外部脚本文件、通过 Webfont 加载字体文件等等。...&nbsp;&nbsp;<a href='http://www.blogjava.net/xiaomage234/archive/2011/07/25/354998.html'>阅读全文</a><img src ="http://www.blogjava.net/xiaomage234/aggbug/354998.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/xiaomage234/" target="_blank">小马歌</a> 2011-07-25 16:22 <a href="http://www.blogjava.net/xiaomage234/archive/2011/07/25/354998.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>HTML Adobe AIR HelloWorld项目</title><link>http://www.blogjava.net/xiaomage234/archive/2011/07/22/354860.html</link><dc:creator>小马歌</dc:creator><author>小马歌</author><pubDate>Fri, 22 Jul 2011 08:39:00 GMT</pubDate><guid>http://www.blogjava.net/xiaomage234/archive/2011/07/22/354860.html</guid><wfw:comment>http://www.blogjava.net/xiaomage234/comments/354860.html</wfw:comment><comments>http://www.blogjava.net/xiaomage234/archive/2011/07/22/354860.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/xiaomage234/comments/commentRss/354860.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/xiaomage234/services/trackbacks/354860.html</trackback:ping><description><![CDATA[<div><span style="color: #333333; font-family: Arial; line-height: 26px; "><p style="line-height: 21px; text-indent: 17.95pt; margin-top: 0cm; margin-right: 0cm; margin-bottom: 0pt; margin-left: 0cm; "><span style="font-size: small; "><span style="font-family: 宋体; ">这里我们通过一个简单的</span><span style="font-family: 'Times New Roman'; ">HelloWorld</span><span style="font-family: 宋体; ">项目演示</span><span style="font-family: 'Times New Roman'; ">Air</span><span style="font-family: 宋体; ">项目的开发过程，本文演示的是在</span><span style="font-family: 'Times New Roman'; ">Windows</span><span style="font-family: 宋体; ">操作系统下，使用</span><span style="font-family: 'Times New Roman'; ">HTML</span><span style="font-family: 宋体; ">技术来开发</span><span style="font-family: 'Times New Roman'; ">Air</span><span style="font-family: 宋体; ">应用的过程，在不同操作系统下，使用不同的开发技术（比如：</span><span style="font-family: 'Times New Roman'; ">flash/flex</span><span style="font-family: 宋体; ">）开发过程可能会略有不同。</span></span></p><h2><span style="font-family: 黑体; "><span style="font-size: large; ">建立开发环境</span></span></h2><p style="line-height: 21px; text-indent: 17.95pt; margin-top: 0cm; margin-right: 0cm; margin-bottom: 0pt; margin-left: 0cm; "><span style="font-size: small; "><span style="font-family: 宋体; ">一个完整的</span><span style="font-family: 'Times New Roman'; ">Air</span><span style="font-family: 宋体; ">开发环境需要安装</span><span style="font-family: 'Times New Roman'; ">AirRuntime</span><span style="font-family: 宋体; ">、</span><span style="font-family: 'Times New Roman'; ">AirSDK</span><span style="font-family: 宋体; ">、</span><span style="font-family: 'Times New Roman'; ">JavaRuntime</span><span style="font-family: 宋体; ">，总体来说安装与配置过程还是比较简单的。其中</span><span style="font-family: 'Times New Roman'; ">AirRuntime</span><span style="font-family: 宋体; ">、</span><span style="font-family: 'Times New Roman'; ">JavaRuntime</span><span style="font-family: 宋体; ">的安装非常简单，我们只需要下载，并执行下载文件安装即可，和安装一个普通的应用程序没什么两样，下载地址：</span></span></p><p style="line-height: 21px; text-indent: 17.95pt; margin-top: 0cm; margin-right: 0cm; margin-bottom: 0pt; margin-left: 0cm; "><span style="font-size: small; "><span style="font-family: 'Times New Roman'; ">AirRuntime</span><span style="font-family: 宋体; ">：</span><a href="http://get.adobe.com/cn/air/" style="color: #336699; text-decoration: none; "><span style="font-family: 'Times New Roman'; color: #0000ff; ">http://get.adobe.com/cn/air/</span></a></span></p><p style="line-height: 21px; text-indent: 17.95pt; margin-top: 0cm; margin-right: 0cm; margin-bottom: 0pt; margin-left: 0cm; "><span style="font-size: small; "><span style="font-family: 'Times New Roman'; ">JavaRuntime</span><span style="font-family: 宋体; ">：</span><a href="http://www.java.com/zh_CN/" style="color: #336699; text-decoration: none; "><span style="font-family: 'Times New Roman'; color: #0000ff; ">http://www.java.com/zh_CN/</span></a></span></p><p style="line-height: 21px; text-indent: 17.95pt; margin-top: 0cm; margin-right: 0cm; margin-bottom: 0pt; margin-left: 0cm; "><span style="font-size: small; "><span style="font-family: 宋体; ">需要说一下的是</span><span style="font-family: 'Times New Roman'; ">AirSDK</span><span style="font-family: 宋体; ">的安装，首先我们要下载它：</span><a href="http://www.adobe.com/products/air/tools/sdk/" style="color: #336699; text-decoration: none; "><span style="font-family: 'Times New Roman'; ">http://www.adobe.com/products/air/tools/sdk/</span></a></span></p><p style="line-height: 21px; text-indent: 17.95pt; margin-top: 0cm; margin-right: 0cm; margin-bottom: 0pt; margin-left: 0cm; "><span style="font-size: small; "><span style="font-family: 宋体; ">下载后我们会得到一个</span><span style="font-family: 'Times New Roman'; ">AdobeAIRSDK.zip</span><span style="font-family: 宋体; ">文件，您可以将它解压到任何一个目录下，例如解压到&#8220;</span><span style="font-family: 'Times New Roman'; ">D:/AirSDK/</span><span style="font-family: 宋体; ">&#8221;。解压后只需要在</span><span style="font-family: 'Times New Roman'; ">path</span><span style="font-family: 宋体; ">环境变量中加入&#8220;</span><span style="font-family: 'Times New Roman'; ">D:/AirSDK/bin</span><span style="font-family: 宋体; ">&#8221;。这样，我们的开发环境就搭建好了，下面让我们来开发应用程序吧。</span></span></p><h2><span style="font-family: 黑体; "><span style="font-size: large; ">编写应用程序</span></span></h2><p style="line-height: 21px; text-indent: 17.95pt; margin-top: 0cm; margin-right: 0cm; margin-bottom: 0pt; margin-left: 0cm; "><span style="font-size: small; "><span style="font-family: 宋体; ">每一个</span><span style="font-family: 'Times New Roman'; ">Air</span><span style="font-family: 宋体; ">应用都需要一个应用程序配置文件（以下称为：项目描述文件），这个文件使用</span><span style="font-family: 'Times New Roman'; ">XML</span><span style="font-family: 宋体; ">格式，用于配置项目相关的信息，比如程序入口，初始窗体的一些设置等。</span><span style="font-family: 'Times New Roman'; ">Air</span><span style="font-family: 宋体; ">运行时框架也是通过此文件才能得知应用程序的入口信息。</span></span></p><p style="line-height: 21px; text-indent: 17.95pt; margin-top: 0cm; margin-right: 0cm; margin-bottom: 0pt; margin-left: 0cm; "><span style="font-size: small; "><span style="font-family: 宋体; ">在这个程序配置文件中我们可以指定应用程序入口</span><span style="font-family: 'Times New Roman'; ">HTML</span><span style="font-family: 宋体; ">文件，这样，我们就可以通过这个</span><span style="font-family: 'Times New Roman'; ">HTML</span><span style="font-family: 宋体; ">文件来开启</span><span style="font-family: 'Times New Roman'; ">Air</span><span style="font-family: 宋体; ">应用之旅。下面我们将制作一个</span><span style="font-family: 'Times New Roman'; ">Air</span><span style="font-family: 宋体; ">应用，整个应用由&#8220;</span><span style="font-family: 'Times New Roman'; ">application.xml</span><span style="font-family: 宋体; ">&#8221;、&#8220;</span><span style="font-family: 'Times New Roman'; ">HelloWorld.html</span><span style="font-family: 宋体; ">&#8221;两个文件组成。我们先来看看项目描述文件。</span></span></p><h3><span style="font-family: 宋体; "><span style="font-size: large; ">创建项目描述文件</span></span></h3><p style="line-height: 21px; text-indent: 17.95pt; margin-top: 0cm; margin-right: 0cm; margin-bottom: 0pt; margin-left: 0cm; "><span style="font-size: small; "><span style="font-family: 宋体; ">我们先来建立一个目录来存放</span><span style="font-family: 'Times New Roman'; ">Air</span><span style="font-family: 宋体; ">应用的文件，比如：&#8220;</span><span style="font-family: 'Times New Roman'; ">D:/airApps/HelloWorld</span><span style="font-family: 宋体; ">&#8221;。在</span><span style="font-family: 'Times New Roman'; ">HelloWorld</span><span style="font-family: 宋体; ">建立一个</span><span style="font-family: 'Times New Roman'; ">application.xml</span><span style="font-family: 宋体; ">文件，其内容如下：</span></span></p><p style="line-height: 21px; text-indent: 17.95pt; margin-top: 0cm; margin-right: 0cm; margin-bottom: 0pt; margin-left: 0cm; "><span style="font-family: 'Times New Roman'; font-size: small; ">&lt;?xml version="1.0" encoding="UTF-8"?&gt;</span></p><p style="line-height: 21px; text-indent: 17.95pt; margin-top: 0cm; margin-right: 0cm; margin-bottom: 0pt; margin-left: 0cm; "><span style="font-family: 'Times New Roman'; font-size: small; ">&lt;application xmlns="http://ns.adobe.com/air/application/1.5"&gt;</span></p><p style="line-height: 21px; text-indent: 17.95pt; margin-top: 0cm; margin-right: 0cm; margin-bottom: 0pt; margin-left: 0cm; "><span style="font-family: 'Times New Roman'; font-size: small; ">&lt;id&gt;com.keda.examples.HelloAir&lt;/id&gt;</span></p><p style="line-height: 21px; text-indent: 17.95pt; margin-top: 0cm; margin-right: 0cm; margin-bottom: 0pt; margin-left: 0cm; "><span style="font-family: 'Times New Roman'; font-size: small; ">&lt;version&gt;0.1&lt;/version&gt;</span></p><p style="line-height: 21px; text-indent: 17.95pt; margin-top: 0cm; margin-right: 0cm; margin-bottom: 0pt; margin-left: 0cm; "><span style="font-family: 'Times New Roman'; font-size: small; ">&lt;filename&gt;HelloAir&lt;/filename&gt;</span></p><p style="line-height: 21px; text-indent: 17.95pt; margin-top: 0cm; margin-right: 0cm; margin-bottom: 0pt; margin-left: 0cm; "><span style="font-family: 'Times New Roman'; font-size: small; ">&lt;initialWindow&gt;</span></p><p style="line-height: 21px; text-indent: 17.95pt; margin-top: 0cm; margin-right: 0cm; margin-bottom: 0pt; margin-left: 0cm; "><span style="font-family: 'Times New Roman'; "><span style="font-size: small; "><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;content&gt; HelloWorld.html&lt;/content&gt;</span></span></span></p><p style="line-height: 21px; text-indent: 17.95pt; margin-top: 0cm; margin-right: 0cm; margin-bottom: 0pt; margin-left: 0cm; "><span style="font-family: 'Times New Roman'; "><span style="font-size: small; "><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;visible&gt;true&lt;/visible&gt;</span></span></span></p><p style="line-height: 21px; text-indent: 17.95pt; margin-top: 0cm; margin-right: 0cm; margin-bottom: 0pt; margin-left: 0cm; "><span style="font-family: 'Times New Roman'; "><span style="font-size: small; "><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;width&gt;400&lt;/width&gt;</span></span></span></p><p style="line-height: 21px; text-indent: 17.95pt; margin-top: 0cm; margin-right: 0cm; margin-bottom: 0pt; margin-left: 0cm; "><span style="font-family: 'Times New Roman'; "><span style="font-size: small; "><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;height&gt;200&lt;/height&gt;</span></span></span></p><p style="line-height: 21px; text-indent: 17.95pt; margin-top: 0cm; margin-right: 0cm; margin-bottom: 0pt; margin-left: 0cm; "><span style="font-family: 'Times New Roman'; font-size: small; ">&lt;/initialWindow&gt;</span></p><p style="line-height: 21px; text-indent: 17.95pt; margin-top: 0cm; margin-right: 0cm; margin-bottom: 0pt; margin-left: 0cm; "><span style="font-family: 'Times New Roman'; font-size: small; ">&lt;/application&gt;</span></p><p style="line-height: 21px; text-indent: 17.95pt; margin-top: 0cm; margin-right: 0cm; margin-bottom: 0pt; margin-left: 0cm; "><span style="font-family: 宋体; "><span style="font-size: small; ">简单解释一下：</span></span></p><p style="line-height: 21px; text-indent: -21pt; margin-top: 0cm; margin-right: 0cm; margin-bottom: 0pt; margin-left: 38.95pt; "><span style="font-family: 'Times New Roman'; "><strong><span><span style="font-size: small; ">1.<span style="font: normal normal normal 7pt/normal 'Times New Roman'; ">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span></span></span></strong><strong><span style="font-size: small; ">&lt;application&gt;&nbsp;</span></strong></span><span style="font-size: small; "><strong><span style="font-family: 宋体; ">元素，包括</span><span style="font-family: 'Times New Roman'; ">&nbsp;AIR&nbsp;</span></strong><strong><span style="font-family: 宋体; ">命名空间属性：</span></strong></span></p><p style="line-height: 21px; text-indent: 17.95pt; margin-top: 0cm; margin-right: 0cm; margin-bottom: 0pt; margin-left: 0cm; "><span style="font-size: small; "><span style="font-family: 'Times New Roman'; ">&lt;application xmlns="http://ns.adobe.com/air/application/1.5"&gt;&nbsp;</span><span style="font-family: 宋体; ">该命名空间的最后一部分&#8220;</span><span style="font-family: 'Times New Roman'; ">1.5</span><span style="font-family: 宋体; ">&#8221;</span>&nbsp;<span style="font-family: 宋体; ">指定了应用程序所需的运行时版</span></span></p><p style="line-height: 21px; text-indent: 17.95pt; margin-top: 0cm; margin-right: 0cm; margin-bottom: 0pt; margin-left: 0cm; "><span style="font-family: 宋体; "><span style="font-size: small; ">本。</span></span></p><p style="line-height: 21px; text-indent: -21pt; margin-top: 0cm; margin-right: 0cm; margin-bottom: 0pt; margin-left: 38.95pt; "><span style="font-family: 'Times New Roman'; "><strong><span><span style="font-size: small; ">2.<span style="font: normal normal normal 7pt/normal 'Times New Roman'; ">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span></span></span></strong><strong><span style="font-size: small; ">&lt;id&gt;&nbsp;</span></strong></span><strong><span style="font-size: small; "><span style="font-family: 宋体; ">元素：</span></span></strong></p><p style="line-height: 21px; text-indent: 17.95pt; margin-top: 0cm; margin-right: 0cm; margin-bottom: 0pt; margin-left: 0cm; "><span style="font-size: small; "><span style="font-family: 'Times New Roman'; ">&lt;id&gt;examples.html.HelloWorld&lt;/id&gt;&nbsp;</span><span style="font-family: 宋体; ">应用程序</span><span style="font-family: 'Times New Roman'; ">&nbsp;ID&nbsp;</span><span style="font-family: 宋体; ">与发布者</span><span style="font-family: 'Times New Roman'; ">&nbsp;ID&nbsp;</span><span style="font-family: 宋体; ">（</span><span style="font-family: 'Times New Roman'; ">AIR&nbsp;</span><span style="font-family: 宋体; ">从对应用程序包进行签名时使用的证书中获取）一起</span></span></p><p style="line-height: 21px; text-indent: 17.95pt; margin-top: 0cm; margin-right: 0cm; margin-bottom: 0pt; margin-left: 0cm; "><span style="font-size: small; "><span style="font-family: 宋体; ">可以标识唯一的应用程序。建议采用的形式为以点分隔的反向</span><span style="font-family: 'Times New Roman'; ">&nbsp;DNS&nbsp;</span><span style="font-family: 宋体; ">样式的字符串，如</span><span style="font-family: 'Times New Roman'; ">&nbsp;"com.company.AppName"</span><span style="font-family: 宋体; ">。应用程</span></span></p><p style="line-height: 21px; text-indent: 17.95pt; margin-top: 0cm; margin-right: 0cm; margin-bottom: 0pt; margin-left: 0cm; "><span style="font-size: small; "><span style="font-family: 宋体; ">序</span><span style="font-family: 'Times New Roman'; ">&nbsp;ID&nbsp;</span><span style="font-family: 宋体; ">可用于安装、访问专用应用程序文件系统存储目录、访问专用加密存储以及应用程序间的通信。</span></span></p><p style="line-height: 21px; text-indent: -21pt; margin-top: 0cm; margin-right: 0cm; margin-bottom: 0pt; margin-left: 38.95pt; "><span style="font-family: 'Times New Roman'; "><strong><span><span style="font-size: small; ">3.<span style="font: normal normal normal 7pt/normal 'Times New Roman'; ">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span></span></span></strong><strong><span style="font-size: small; ">&lt;version&gt;&nbsp;</span></strong></span><strong><span style="font-size: small; "><span style="font-family: 宋体; ">元素：</span></span></strong></p><p style="line-height: 21px; text-indent: 17.95pt; margin-top: 0cm; margin-right: 0cm; margin-bottom: 0pt; margin-left: 0cm; "><span style="font-size: small; "><span style="font-family: 'Times New Roman'; ">&lt;version&gt;0.1&lt;/version&gt;&nbsp;</span><span style="font-family: 宋体; ">可帮助用户确定安装哪个版本的应用程序。</span></span></p><p style="line-height: 21px; text-indent: -21pt; margin-top: 0cm; margin-right: 0cm; margin-bottom: 0pt; margin-left: 38.95pt; "><span style="font-family: 'Times New Roman'; "><strong><span><span style="font-size: small; ">4.<span style="font: normal normal normal 7pt/normal 'Times New Roman'; ">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span></span></span></strong><strong><span style="font-size: small; ">&lt;filename&gt;&nbsp;</span></strong></span><strong><span style="font-size: small; "><span style="font-family: 宋体; ">元素：</span></span></strong></p><p style="line-height: 21px; text-indent: 17.95pt; margin-top: 0cm; margin-right: 0cm; margin-bottom: 0pt; margin-left: 0cm; "><span style="font-size: small; "><span style="font-family: 'Times New Roman'; ">&lt;filename&gt;HelloWorld&lt;/filename&gt;&nbsp;</span><span style="font-family: 宋体; ">用于操作系统中应用程序可执行文件、安装目录和对应用程序的其它引用的名称。</span></span></p><p style="line-height: 21px; text-indent: -21pt; margin-top: 0cm; margin-right: 0cm; margin-bottom: 0pt; margin-left: 38.95pt; "><strong><span><span style="font-family: 'Times New Roman'; "><span style="font-size: small; ">5.<span style="font: normal normal normal 7pt/normal 'Times New Roman'; ">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span></span></span></span></strong><span style="font-size: small; "><strong><span style="font-family: 宋体; ">包含下列子元素的</span><span style="font-family: 'Times New Roman'; ">&nbsp;&lt;initialWindow&gt;&nbsp;</span></strong><strong><span style="font-family: 宋体; ">元素，为初始应用程序窗口指定属性：</span></strong></span></p><p style="line-height: 21px; text-indent: 17.95pt; margin-top: 0cm; margin-right: 0cm; margin-bottom: 0pt; margin-left: 0cm; "><span style="font-size: small; "><span style="font-family: 'Times New Roman'; ">&lt;content&gt;HelloWorld.html&lt;/content&gt;&nbsp;</span><span style="font-family: 宋体; ">标识</span><span style="font-family: 'Times New Roman'; ">&nbsp;AIR&nbsp;</span><span style="font-family: 宋体; ">要加载的根</span><span style="font-family: 'Times New Roman'; ">&nbsp;HTML&nbsp;</span><span style="font-family: 宋体; ">文件。</span></span></p><p style="line-height: 21px; text-indent: 17.95pt; margin-top: 0cm; margin-right: 0cm; margin-bottom: 0pt; margin-left: 0cm; "><span style="font-size: small; "><span style="font-family: 'Times New Roman'; ">&lt;visible&gt;true&lt;/visible&gt;&nbsp;</span><span style="font-family: 宋体; ">使窗口立即可见。</span></span></p><p style="line-height: 21px; text-indent: 17.95pt; margin-top: 0cm; margin-right: 0cm; margin-bottom: 0pt; margin-left: 0cm; "><span style="font-size: small; "><span style="font-family: 'Times New Roman'; ">&lt;width&gt;400&lt;/width&gt;&nbsp;</span><span style="font-family: 宋体; ">设置窗口宽度（以像素为单位）。</span></span></p><p style="line-height: 21px; text-indent: 17.95pt; margin-top: 0cm; margin-right: 0cm; margin-bottom: 0pt; margin-left: 0cm; "><span style="font-size: small; "><span style="font-family: 'Times New Roman'; ">&lt;height&gt;200&lt;/height&gt;&nbsp;</span><span style="font-family: 宋体; ">设置窗口高度。</span></span></p><h3><span style="font-size: large; "><span style="font-family: 宋体; ">创建入口</span><span style="font-family: 'Times New Roman'; ">HTML</span><span style="font-family: 宋体; ">页面</span></span></h3><p style="line-height: 21px; text-indent: 17.95pt; margin-top: 0cm; margin-right: 0cm; margin-bottom: 0pt; margin-left: 0cm; "><span style="font-size: small; "><span style="font-family: 宋体; ">新建&#8220;</span><span style="font-family: 'Times New Roman'; ">HelloWorld.html</span><span style="font-family: 宋体; ">&#8221;内容如下：</span></span></p><p style="line-height: 21px; text-indent: 17.95pt; margin-top: 0cm; margin-right: 0cm; margin-bottom: 0pt; margin-left: 0cm; "><span style="font-family: 'Times New Roman'; font-size: small; ">&lt;html&gt;</span></p><p style="line-height: 21px; text-indent: 17.95pt; margin-top: 0cm; margin-right: 0cm; margin-bottom: 0pt; margin-left: 0cm; "><span style="font-family: 'Times New Roman'; font-size: small; ">&lt;head&gt;</span></p><p style="line-height: 21px; text-indent: 17.95pt; margin-top: 0cm; margin-right: 0cm; margin-bottom: 0pt; margin-left: 0cm; "><span style="font-family: 'Times New Roman'; font-size: small; ">&lt;title&gt;Hello World&lt;/title&gt;</span></p><p style="line-height: 21px; text-indent: 17.95pt; margin-top: 0cm; margin-right: 0cm; margin-bottom: 0pt; margin-left: 0cm; "><span style="font-family: 'Times New Roman'; font-size: small; ">&lt;/head&gt;</span></p><p style="line-height: 21px; text-indent: 17.95pt; margin-top: 0cm; margin-right: 0cm; margin-bottom: 0pt; margin-left: 0cm; "><span style="font-family: 'Times New Roman'; font-size: small; ">&lt;body &gt;</span></p><p style="line-height: 21px; text-indent: 17.95pt; margin-top: 0cm; margin-right: 0cm; margin-bottom: 0pt; margin-left: 0cm; "><span style="font-family: 'Times New Roman'; font-size: small; ">&lt;h1&gt;Hello World&lt;/h1&gt;</span></p><p style="line-height: 21px; text-indent: 17.95pt; margin-top: 0cm; margin-right: 0cm; margin-bottom: 0pt; margin-left: 0cm; "><span style="font-family: 'Times New Roman'; font-size: small; ">&lt;/body&gt;</span></p><p style="line-height: 21px; text-indent: 17.95pt; margin-top: 0cm; margin-right: 0cm; margin-bottom: 0pt; margin-left: 0cm; "><span style="font-family: 'Times New Roman'; font-size: small; ">&lt;/html&gt;</span></p><p style="line-height: 21px; text-indent: 17.95pt; margin-top: 0cm; margin-right: 0cm; margin-bottom: 0pt; margin-left: 0cm; "><span style="font-size: small; "><span style="font-family: 'Times New Roman'; ">HTML</span><span style="font-family: 宋体; ">很简单，这里不多说了。到这里我们的</span><span style="font-family: 'Times New Roman'; ">Air</span><span style="font-family: 宋体; ">应用就编写完成了，下面让我们调试运行一下。</span></span></p><h2><span style="font-size: large; "><span style="font-family: 黑体; ">调试运行</span><span style="font-family: Arial; ">Air</span><span style="font-family: 黑体; ">应用</span></span></h2><p style="line-height: 21px; text-indent: 17.95pt; margin-top: 0cm; margin-right: 0cm; margin-bottom: 0pt; margin-left: 0cm; "><span style="font-size: small; "><span style="font-family: 宋体; ">在</span><span style="font-family: 'Times New Roman'; ">Dos</span><span style="font-family: 宋体; ">命令行下进入&#8220;</span><span style="font-family: 'Times New Roman'; ">D:/airApps/HelloWorld</span><span style="font-family: 宋体; ">&#8221;，然后使用</span><span style="font-family: 'Times New Roman'; ">adl</span><span style="font-family: 宋体; ">命令进行高度。命令如下：</span></span></p><p style="line-height: 21px; text-indent: 17.95pt; margin-top: 0cm; margin-right: 0cm; margin-bottom: 0pt; margin-left: 0cm; "><span style="font-family: 'Times New Roman'; font-size: small; ">adl application.xml</span></p><p style="line-height: 21px; text-indent: 17.95pt; margin-top: 0cm; margin-right: 0cm; margin-bottom: 0pt; margin-left: 0cm; "><span style="font-family: 宋体; "><span style="font-size: small; ">看看运行结果：</span></span></p><p style="line-height: 21px; text-indent: 17.95pt; margin-top: 0cm; margin-right: 0cm; margin-bottom: 0pt; margin-left: 0cm; "><span style="font-family: 宋体; "><img src="http://p.blog.csdn.net/images/p_blog_csdn_net/yneos/EntryImages/20091215/image001.png" alt="" style="border-top-style: none; border-right-style: none; border-bottom-style: none; border-left-style: none; border-width: initial; border-color: initial; " /></span></p><p style="line-height: 21px; text-indent: 17.95pt; margin-top: 0cm; margin-right: 0cm; margin-bottom: 0pt; margin-left: 0cm; ">&nbsp;</p><h2><span style="font-family: 黑体; "><span style="font-size: large; ">打包和分发</span></span></h2><p style="line-height: 21px; text-indent: 17.95pt; margin-top: 0cm; margin-right: 0cm; margin-bottom: 0pt; margin-left: 0cm; "><span style="font-size: small; "><span style="font-family: 宋体; ">在</span><span style="font-family: 'Times New Roman'; ">Air</span><span style="font-family: 宋体; ">应用打包之前需要</span><span style="font-family: 'Times New Roman'; ">Air</span><span style="font-family: 宋体; ">的证书，</span><span style="font-family: 'Times New Roman'; ">Air</span><span style="font-family: 宋体; ">证书有两种，一种是</span><span style="font-family: 'Times New Roman'; ">Air</span><span style="font-family: 宋体; ">颁发的，另一种是自签名证书，这种证书我们可以直接通过命令行生成并使用，自签名证书打包的应用在安装时不会显示机构名称，如下图所示：</span></span></p><p style="line-height: 21px; text-indent: 17.95pt; margin-top: 0cm; margin-right: 0cm; margin-bottom: 0pt; margin-left: 0cm; "><span style="font-size: small; "><span style="font-family: 宋体; "><img src="http://p.blog.csdn.net/images/p_blog_csdn_net/yneos/EntryImages/20091215/image003.png" alt="" style="border-top-style: none; border-right-style: none; border-bottom-style: none; border-left-style: none; border-width: initial; border-color: initial; " /></span></span></p><p style="line-height: 21px; text-indent: 17.95pt; margin-top: 0cm; margin-right: 0cm; margin-bottom: 0pt; margin-left: 0cm; ">&nbsp;</p><p style="line-height: 21px; text-indent: 17.95pt; margin-top: 0cm; margin-right: 0cm; margin-bottom: 0pt; margin-left: 0cm; "><span style="font-family: 宋体; "><span style="font-size: small; ">但作为学习自签名证书还是比较适用的，下面简介一下自签名证书的生成。</span></span></p><p style="line-height: 21px; text-indent: 17.95pt; margin-top: 0cm; margin-right: 0cm; margin-bottom: 0pt; margin-left: 0cm; ">&nbsp;</p><h3><span style="font-family: 宋体; "><span style="font-size: large; ">生成证书</span></span></h3><p style="line-height: 21px; text-indent: 17.95pt; margin-top: 0cm; margin-right: 0cm; margin-bottom: 0pt; margin-left: 0cm; "><span style="font-size: small; "><span style="font-family: 宋体; ">命令格式说明：</span><span style="font-family: 'Times New Roman'; ">adt -certificate -cn name [-ou org_unit][-o org_name][-c country] key_type pfx_file password</span></span></p><p style="line-height: 21px; text-indent: 17.95pt; margin-top: 0cm; margin-right: 0cm; margin-bottom: 0pt; margin-left: 0cm; "><span style="font-size: small; "><span style="font-family: 'Times New Roman'; ">-cn name&nbsp;</span><span style="font-family: 宋体; ">分配的作为新证书公共名称的字符串。</span></span></p><p style="line-height: 21px; text-indent: 17.95pt; margin-top: 0cm; margin-right: 0cm; margin-bottom: 0pt; margin-left: 0cm; "><span style="font-size: small; "><span style="font-family: 'Times New Roman'; ">-ou org_unit&nbsp;</span><span style="font-family: 宋体; ">分配的作为证书颁发组织单位的字符串。（可选。）</span></span></p><p style="line-height: 21px; text-indent: 17.95pt; margin-top: 0cm; margin-right: 0cm; margin-bottom: 0pt; margin-left: 0cm; "><span style="font-size: small; "><span style="font-family: 'Times New Roman'; ">-o org_name&nbsp;</span><span style="font-family: 宋体; ">被分配作为证书颁发组织的字符串。（可选。）</span></span></p><p style="line-height: 21px; text-indent: 17.95pt; margin-top: 0cm; margin-right: 0cm; margin-bottom: 0pt; margin-left: 0cm; "><span style="font-size: small; "><span style="font-family: 'Times New Roman'; ">-c country&nbsp;</span><span style="font-family: 宋体; ">双字母</span><span style="font-family: 'Times New Roman'; ">&nbsp;ISO-3166&nbsp;</span><span style="font-family: 宋体; ">国家</span><span style="font-family: 'Times New Roman'; ">/&nbsp;</span><span style="font-family: 宋体; ">地区代码。如果提供的代码无效，则不会生成证书。（可选。）</span></span></p><p style="line-height: 21px; text-indent: 17.95pt; margin-top: 0cm; margin-right: 0cm; margin-bottom: 0pt; margin-left: 0cm; "><span style="font-size: small; "><span style="font-family: 'Times New Roman'; ">key_type&nbsp;</span><span style="font-family: 宋体; ">用于证书的密钥类型，即&#8220;</span><span style="font-family: 'Times New Roman'; ">1024-RSA</span><span style="font-family: 宋体; ">&#8221;</span>&nbsp;<span style="font-family: 宋体; ">或&#8220;</span><span style="font-family: 'Times New Roman'; ">2048-RSA</span><span style="font-family: 宋体; ">&#8221;。</span></span></p><p style="line-height: 21px; text-indent: 17.95pt; margin-top: 0cm; margin-right: 0cm; margin-bottom: 0pt; margin-left: 0cm; "><span style="font-size: small; "><span style="font-family: 'Times New Roman'; ">pfx_file&nbsp;</span><span style="font-family: 宋体; ">证书文件的生成路径。</span></span></p><p style="line-height: 21px; text-indent: 17.95pt; margin-top: 0cm; margin-right: 0cm; margin-bottom: 0pt; margin-left: 0cm; "><span style="font-size: small; "><span style="font-family: 'Times New Roman'; ">password&nbsp;</span><span style="font-family: 宋体; ">新证书的密码。当使用此证书对</span><span style="font-family: 'Times New Roman'; ">&nbsp;AIR&nbsp;</span><span style="font-family: 宋体; ">文件签名时需要提供密码。</span></span></p><p style="line-height: 21px; text-indent: 17.95pt; margin-top: 0cm; margin-right: 0cm; margin-bottom: 0pt; margin-left: 0cm; "><span style="font-family: 宋体; "><span style="font-size: small; ">例如本程序证书使用以下命令生成：</span></span></p><p style="line-height: 21px; text-indent: 17.95pt; margin-top: 0cm; margin-right: 0cm; margin-bottom: 0pt; margin-left: 0cm; "><span style="font-family: 'Times New Roman'; font-size: small; ">adt -certificate -cn HelloWorld -ou it.kedacom.com -o KEDACOM 2048-RSA HelloWorld.p12 kedacom</span></p><h3><span style="font-family: 宋体; "><span style="font-size: large; ">打包分发</span></span></h3><p style="line-height: 21px; text-indent: 17.95pt; margin-top: 0cm; margin-right: 0cm; margin-bottom: 0pt; margin-left: 0cm; "><span style="font-family: 宋体; "><span style="font-size: small; ">证书生成之后我们就可以进行打包了，</span></span></p><p style="line-height: 21px; text-indent: 17.95pt; margin-top: 0cm; margin-right: 0cm; margin-bottom: 0pt; margin-left: 0cm; "><span style="font-family: 'Times New Roman'; font-size: small; ">adt &#8211;package -tsa none -storetype pkcs12 -keystore HelloWorld.p12 HelloWorld.air application.xml HelloWorld.html</span></p><p style="line-height: 21px; text-indent: 17.95pt; margin-top: 0cm; margin-right: 0cm; margin-bottom: 0pt; margin-left: 0cm; "><span style="font-size: small; "><span style="font-family: 宋体; ">系统将提示您输入生成证书时的密码：</span><span style="font-family: 'Times New Roman'; ">kedacom</span><span style="font-family: 宋体; ">。</span></span></p><p style="line-height: 21px; text-indent: 17.95pt; margin-top: 0cm; margin-right: 0cm; margin-bottom: 0pt; margin-left: 0cm; "><span style="font-size: small; "><span style="font-family: 'Times New Roman'; ">HelloWorld.air&nbsp;</span><span style="font-family: 宋体; ">参数表示</span><span style="font-family: 'Times New Roman'; ">&nbsp;ADT&nbsp;</span><span style="font-family: 宋体; ">生成的</span><span style="font-family: 'Times New Roman'; ">&nbsp;AIR&nbsp;</span><span style="font-family: 宋体; ">文件。</span><span style="font-family: 'Times New Roman'; ">HelloWorld-app.xml&nbsp;</span><span style="font-family: 宋体; ">表示应用程序描述符文件。后面的参数表示应</span></span></p><p style="line-height: 21px; text-indent: 17.95pt; margin-top: 0cm; margin-right: 0cm; margin-bottom: 0pt; margin-left: 0cm; "><span style="font-family: 宋体; "><span style="font-size: small; ">用程序所使用的文件。此示例仅使用了两个文件，但可以包含任意数量的文件和目录。</span></span></p><p style="line-height: 21px; text-indent: 17.95pt; margin-top: 0cm; margin-right: 0cm; margin-bottom: 0pt; margin-left: 0cm; "><span style="font-size: small; "><span style="font-family: 宋体; ">至此，我们的应用就已经完成了，您可以通过双击生成的</span><span style="font-family: 'Times New Roman'; ">.air</span><span style="font-family: 宋体; ">安装包来安装我们的应用。</span></span></p><p style="line-height: 21px; text-indent: 17.95pt; margin-top: 0cm; margin-right: 0cm; margin-bottom: 0pt; margin-left: 0cm; "><span style="font-size: small; "><span style="font-family: 宋体; ">用命令行工具进行打包还是比较繁琐的，推荐使用</span><span style="font-family: 'Times New Roman'; ">Aptana Studio</span><span style="font-family: 宋体; ">来开发</span><span style="font-family: 'Times New Roman'; ">Air</span><span style="font-family: 宋体; ">应用，项目创建、证书的生成、打包都有图形化工具可以使用。</span></span></p><p style="line-height: 21px; text-indent: 17.95pt; margin-top: 0cm; margin-right: 0cm; margin-bottom: 0pt; margin-left: 0cm; "><span style="font-size: small; "><span style="font-family: 'Times New Roman'; ">Aptana Studio</span><span style="font-family: 宋体; ">下载地址：</span><a href="http://www.aptana.org/studio/download" style="color: #336699; text-decoration: none; "><span style="font-family: 'Times New Roman'; color: #0000ff; ">http://www.aptana.org/studio/download</span></a></span></p></span></div><img src ="http://www.blogjava.net/xiaomage234/aggbug/354860.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/xiaomage234/" target="_blank">小马歌</a> 2011-07-22 16:39 <a href="http://www.blogjava.net/xiaomage234/archive/2011/07/22/354860.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>gmail 邮件中css无效style无效background image背景图片无效不显示的解决办法[转]</title><link>http://www.blogjava.net/xiaomage234/archive/2011/07/13/354253.html</link><dc:creator>小马歌</dc:creator><author>小马歌</author><pubDate>Wed, 13 Jul 2011 06:14:00 GMT</pubDate><guid>http://www.blogjava.net/xiaomage234/archive/2011/07/13/354253.html</guid><wfw:comment>http://www.blogjava.net/xiaomage234/comments/354253.html</wfw:comment><comments>http://www.blogjava.net/xiaomage234/archive/2011/07/13/354253.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/xiaomage234/comments/commentRss/354253.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/xiaomage234/services/trackbacks/354253.html</trackback:ping><description><![CDATA[<div><span style="color: #333333; font-family: Arial; line-height: 26px; "><p>gmail 邮件中css无效style无效background image背景图片无效不显示的解决办法</p><p>几乎每个会员制网站都需要通过后台发送邮件来与会员进行沟通，如注册确认、营销推广。这些由站方发给会员的信件，往往纯<br />文本格式已不能满足界面和交互的要 求，这时候我们就需要发送HTML页面。由于HTML邮件不是独立的HOST在本站的页面，是寄人篱下的。所以编写HTML邮件与编写HTML页面有很大 的不同。因为，各面向网民的主流邮箱都或多或少的会对它们接收到的HTML邮件在后台进行过滤。毫无疑问，JS代码是被严格过滤掉的，包括所有的事件监听 属性，如onclick、onmouseover，这是基于邮件安全性的考虑。不仅如此，CSS代码也会被部分过滤。本人要讲的就是如何编写不被各大主流 邮箱过滤的，能正常显示的HTML邮件。</p><p>gmail会自动过滤掉 head里的&lt;style&gt;设置的css，所以必须要把css写在html里面。</p><p>例如 &lt;div style=&#8221;font-size:14px;&#8221;&gt;</p><p>另外，gmail不支持在css里定义background里的image，包括background:url(&#8221;&#8230;&#8221;)和background-image:url(&#8220;..&#8221;)</p><p>解决办法是 在div的外面加上一层 &nbsp;&lt;table&gt;和&lt;td&gt;</p><p>并在&lt;td&gt;里加上background属性，例如</p><p>&lt;table&gt;</p><p>&lt;tr&gt;</p><p>&lt;td &nbsp;background=&#8221;http://www.vivizu.com/test.jpg&#8221;&gt;</p><p>&lt;div&gt;test&lt;/div&gt;</p><p>&lt;/td&gt;</p><p>&lt;/tr&gt;</p><p>&lt;/table&gt;</p><p>呵呵 ，就可以看到背景图片了</p></span></div><img src ="http://www.blogjava.net/xiaomage234/aggbug/354253.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/xiaomage234/" target="_blank">小马歌</a> 2011-07-13 14:14 <a href="http://www.blogjava.net/xiaomage234/archive/2011/07/13/354253.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>别忘了优化jQuery 性能</title><link>http://www.blogjava.net/xiaomage234/archive/2011/06/16/352452.html</link><dc:creator>小马歌</dc:creator><author>小马歌</author><pubDate>Thu, 16 Jun 2011 10:05:00 GMT</pubDate><guid>http://www.blogjava.net/xiaomage234/archive/2011/06/16/352452.html</guid><wfw:comment>http://www.blogjava.net/xiaomage234/comments/352452.html</wfw:comment><comments>http://www.blogjava.net/xiaomage234/archive/2011/06/16/352452.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/xiaomage234/comments/commentRss/352452.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/xiaomage234/services/trackbacks/352452.html</trackback:ping><description><![CDATA[<div><span style="color: #333333; font-family: Tahoma, Helvetica, Arial, sans-serif; line-height: 24px; "><p style="line-height: 2; margin-top: 0px; margin-right: 0px; margin-bottom: 1.25em; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; text-indent: 2em; ">现在<strong style="color: black; background-color: #a0ffff; ">jquery</strong>应用的越来越多, 有些同学在享受爽快淋漓coding时就将<strong style="color: black; background-color: #ff9999; ">性能</strong>问题忽略了, 比如我.&nbsp;<strong style="color: black; background-color: #a0ffff; ">jquery</strong>虽在诸多的js类库中<strong style="color: black; background-color: #ff9999; ">性能</strong>表现还算优秀, 但毕竟不是在用原生的javascript开发,&nbsp;<strong style="color: black; background-color: #ff9999; ">性能</strong>问题还是需要引起重视的.&nbsp;<br />在twitter上发现了&lt;<strong style="color: black; background-color: #a0ffff; ">jQuery</strong>&nbsp;Performance Rules&gt;这篇文章, 简单的摘译了一下:</p><ul style="margin-top: 0px; margin-right: 30px; margin-bottom: 0px; margin-left: 30px; padding-top: 0px; padding-right: 0px; padding-bottom: 1.5em; padding-left: 0px; "><li style="list-style-type: none; list-style-position: initial; list-style-image: initial; "><h2>1. 总是从ID选择器开始继承</h2><p style="line-height: 2; margin-top: 0px; margin-right: 0px; margin-bottom: 1.25em; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; text-indent: 2em; ">在<strong style="color: black; background-color: #a0ffff; ">jquery</strong>中最快的选择器是ID选择器. 因为它直接来自于Javascript的getElementById()方法.&nbsp;<br />复制代码 代码如下:</p><p style="line-height: 2; margin-top: 0px; margin-right: 0px; margin-bottom: 1.25em; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; text-indent: 2em; ">&lt;div id="content"&gt;&nbsp;<br />&lt;form method="post" action="/"&gt;&nbsp;<br />&lt;h2&gt;Traffic Light&lt;/h2&gt;&nbsp;<br />&lt;ul id="traffic_light"&gt;&nbsp;<br />&lt;li&gt;&lt;input type="radio" class="on" name="light" value="red" /&gt; Red&lt;/li&gt;&nbsp;<br />&lt;li&gt;&lt;input type="radio" class="off" name="light" value="yellow" /&gt; Yellow&lt;/li&gt;&nbsp;<br />&lt;li&gt;&lt;input type="radio" class="off" name="light" value="green" /&gt; Green&lt;/li&gt;&nbsp;<br />&lt;/ul&gt;&nbsp;<br />&lt;input class="button" id="traffic_button" type="submit" value="Go" /&gt;&nbsp;<br />&lt;/form&gt;&nbsp;<br />&lt;/div&gt;</p><p style="line-height: 2; margin-top: 0px; margin-right: 0px; margin-bottom: 1.25em; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; text-indent: 2em; ">像这样选择按钮是低效的:&nbsp;<br />复制代码 代码如下:</p><p style="line-height: 2; margin-top: 0px; margin-right: 0px; margin-bottom: 1.25em; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; text-indent: 2em; ">var traffic_button = $(&#8216;#content .button&#8217;);</p><p style="line-height: 2; margin-top: 0px; margin-right: 0px; margin-bottom: 1.25em; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; text-indent: 2em; ">用ID直接选择按钮效率更高:&nbsp;<br />复制代码 代码如下:</p><p style="line-height: 2; margin-top: 0px; margin-right: 0px; margin-bottom: 1.25em; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; text-indent: 2em; ">var traffic_button = $(&#8216;#traffic_button&#8217;);</p><p style="line-height: 2; margin-top: 0px; margin-right: 0px; margin-bottom: 1.25em; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; text-indent: 2em; ">选择多个元素</p><p style="line-height: 2; margin-top: 0px; margin-right: 0px; margin-bottom: 1.25em; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; text-indent: 2em; ">提到多元素选择其实是在说DOM遍历和循环, 这些都是比较慢的东西.为了提高<strong style="color: black; background-color: #ff9999; ">性能</strong>, 最好从就近的ID开始继承.&nbsp;<br />代码如下:</p><p style="line-height: 2; margin-top: 0px; margin-right: 0px; margin-bottom: 1.25em; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; text-indent: 2em; ">var traffic_lights = $(&#8216;#traffic_light input&#8217;);</p><p style="line-height: 2; margin-top: 0px; margin-right: 0px; margin-bottom: 1.25em; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; text-indent: 2em; ">&nbsp;</p></li><li style="list-style-type: none; list-style-position: initial; list-style-image: initial; "><h2>2. 在class前使用tag</h2><p style="line-height: 2; margin-top: 0px; margin-right: 0px; margin-bottom: 1.25em; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; text-indent: 2em; ">第二快的选择器是tag选择器($(&#8216;head&#8217;)). 同理,因为它来自原生的getElementsByTagName() 方法.&nbsp;<br />代码如下:</p><p style="line-height: 2; margin-top: 0px; margin-right: 0px; margin-bottom: 1.25em; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; text-indent: 2em; ">&lt;div id="content"&gt;&nbsp;<br />&lt;form method="post" action="/"&gt;&nbsp;<br />&lt;h2&gt;Traffic Light&lt;/h2&gt;&nbsp;<br />&lt;ul id="traffic_light"&gt;&nbsp;<br />&lt;li&gt;&lt;input type="radio" class="on" name="light" value="red" /&gt; Red&lt;/li&gt;&nbsp;<br />&lt;li&gt;&lt;input type="radio" class="off" name="light" value="yellow" /&gt; Yellow&lt;/li&gt;&nbsp;<br />&lt;li&gt;&lt;input type="radio" class="off" name="light" value="green" /&gt; Green&lt;/li&gt;&nbsp;<br />&lt;/ul&gt;&nbsp;<br />&lt;input class="button" id="traffic_button" type="submit" value="Go" /&gt;&nbsp;<br />&lt;/form&gt;&nbsp;<br />&lt;/div&gt;</p><p style="line-height: 2; margin-top: 0px; margin-right: 0px; margin-bottom: 1.25em; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; text-indent: 2em; ">总是用一个tag name来限制(修饰)class (并且不要忘记就近的ID):&nbsp;<br />代码如下:</p><p style="line-height: 2; margin-top: 0px; margin-right: 0px; margin-bottom: 1.25em; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; text-indent: 2em; ">var active_light = $(&#8216;#traffic_light input.on&#8217;);</p><p style="line-height: 2; margin-top: 0px; margin-right: 0px; margin-bottom: 1.25em; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; text-indent: 2em; ">注意: 在<strong style="color: black; background-color: #a0ffff; ">jquery</strong>中Class是最慢的选择器. IE浏览器下它会遍历所有DOM节点不管它用在那里.</p><p style="line-height: 2; margin-top: 0px; margin-right: 0px; margin-bottom: 1.25em; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; text-indent: 2em; ">不要用用tag name来修饰ID. 下面的例子将会遍历所有的div元素来查找id为&#8217;content&#8217;的哪一个节点:&nbsp;<br />代码如下:</p><p style="line-height: 2; margin-top: 0px; margin-right: 0px; margin-bottom: 1.25em; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; text-indent: 2em; ">var content = $(&#8216;div#content&#8217;);</p><p style="line-height: 2; margin-top: 0px; margin-right: 0px; margin-bottom: 1.25em; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; text-indent: 2em; ">用ID修饰ID也是画蛇添足:&nbsp;<br />代码如下:</p><p style="line-height: 2; margin-top: 0px; margin-right: 0px; margin-bottom: 1.25em; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; text-indent: 2em; ">var traffic_light = $(&#8216;#content #traffic_light&#8217;);</p></li><li style="list-style-type: none; list-style-position: initial; list-style-image: initial; "><h2>3. 将<strong style="color: black; background-color: #a0ffff; ">jquery</strong>对象缓存起来</h2><p style="line-height: 2; margin-top: 0px; margin-right: 0px; margin-bottom: 1.25em; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; text-indent: 2em; ">要养成将<strong style="color: black; background-color: #a0ffff; ">jquery</strong>对象缓存进变量的习惯.</p><p style="line-height: 2; margin-top: 0px; margin-right: 0px; margin-bottom: 1.25em; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; text-indent: 2em; ">永远不要这样做:&nbsp;<br />代码如下:</p><p style="line-height: 2; margin-top: 0px; margin-right: 0px; margin-bottom: 1.25em; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; text-indent: 2em; ">$(&#8216;#traffic_light input.on).bind(&#8216;click&#8217;, function(){&#8230;});&nbsp;<br />$(&#8216;#traffic_light input.on).css(&#8216;border&#8217;, &#8217;3px dashed yellow&#8217;);&nbsp;<br />$(&#8216;#traffic_light input.on).css(&#8216;background-color&#8217;, &#8216;orange&#8217;);&nbsp;<br />$(&#8216;#traffic_light input.on).fadeIn(&#8216;slow&#8217;);</p><p style="line-height: 2; margin-top: 0px; margin-right: 0px; margin-bottom: 1.25em; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; text-indent: 2em; ">最好先将对象缓存进一个变量然后再操作:&nbsp;<br />代码如下:</p><p style="line-height: 2; margin-top: 0px; margin-right: 0px; margin-bottom: 1.25em; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; text-indent: 2em; ">var $active_light = $(&#8216;#traffic_light input.on&#8217;);&nbsp;<br />$active_light.bind(&#8216;click&#8217;, function(){&#8230;});&nbsp;<br />$active_light.css(&#8216;border&#8217;, &#8217;3px dashed yellow&#8217;);&nbsp;<br />$active_light.css(&#8216;background-color&#8217;, &#8216;orange&#8217;);&nbsp;<br />$active_light.fadeIn(&#8216;slow&#8217;);</p><p style="line-height: 2; margin-top: 0px; margin-right: 0px; margin-bottom: 1.25em; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; text-indent: 2em; ">为了记住我们本地变量是<strong style="color: black; background-color: #a0ffff; ">jquery</strong>的封装, 通常用一个$作为变量前缀. 记住,永远不要让相同的选择器在你的代码里出现多次.</p><p style="line-height: 2; margin-top: 0px; margin-right: 0px; margin-bottom: 1.25em; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; text-indent: 2em; ">缓存<strong style="color: black; background-color: #a0ffff; ">jquery</strong>结果,备用</p><p style="line-height: 2; margin-top: 0px; margin-right: 0px; margin-bottom: 1.25em; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; text-indent: 2em; ">如果你打算将<strong style="color: black; background-color: #a0ffff; ">jquery</strong>结果对象用在程序的其它部分,或者你的function会多次执行, 那么就将他们缓存到一个全局变量中.</p><p style="line-height: 2; margin-top: 0px; margin-right: 0px; margin-bottom: 1.25em; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; text-indent: 2em; ">定义一个全局容器来存放<strong style="color: black; background-color: #a0ffff; ">jquery</strong>结果, 我们就可以在其它函数引用它们:&nbsp;<br />代码如下:</p><p style="line-height: 2; margin-top: 0px; margin-right: 0px; margin-bottom: 1.25em; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; text-indent: 2em; ">// 在全局范围定义一个对象 (例如: window对象)&nbsp;<br />window.$my =&nbsp;<br />{&nbsp;<br />// 初始化所有可能会不止一次要使用的查询&nbsp;<br />head : $(&#8216;head&#8217;),&nbsp;<br />traffic_light : $(&#8216;#traffic_light&#8217;),&nbsp;<br />traffic_button : $(&#8216;#traffic_button&#8217;)&nbsp;<br />};</p><p style="line-height: 2; margin-top: 0px; margin-right: 0px; margin-bottom: 1.25em; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; text-indent: 2em; ">function do_something()&nbsp;<br />{&nbsp;<br />// 现在你可以引用存储的结果并操作它们&nbsp;<br />var script = document.createElement(&#8216;script&#8217;);&nbsp;<br />$my.head.<a name="baidusnap2" style="color: rgb(4, 129, 181); text-decoration: none; "></a><strong style="color: black; background-color: #99ff99; ">append</strong>(script);</p><p style="line-height: 2; margin-top: 0px; margin-right: 0px; margin-bottom: 1.25em; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; text-indent: 2em; ">// 当你在函数内部操作是, 可以继续将查询存入全局对象中去.&nbsp;<br />$my.cool_results = $(&#8216;#some_ul li&#8217;);&nbsp;<br />$my.other_results = $(&#8216;#some_table td&#8217;);</p><p style="line-height: 2; margin-top: 0px; margin-right: 0px; margin-bottom: 1.25em; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; text-indent: 2em; ">// 将全局函数作为一个普通的<strong style="color: black; background-color: #a0ffff; ">jquery</strong>对象去使用.&nbsp;<br />$my.other_results.css(&#8216;border-color&#8217;, &#8216;red&#8217;);&nbsp;<br />$my.traffic_light.css(&#8216;border-color&#8217;, &#8216;green&#8217;);&nbsp;<br />}</p></li><li style="list-style-type: none; list-style-position: initial; list-style-image: initial; "><h2>4. 掌握强大的链式操作</h2><p style="line-height: 2; margin-top: 0px; margin-right: 0px; margin-bottom: 1.25em; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; text-indent: 2em; ">上面的例子也可以写成这样:&nbsp;<br />代码如下:</p><p style="line-height: 2; margin-top: 0px; margin-right: 0px; margin-bottom: 1.25em; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; text-indent: 2em; ">var $active_light = $(&#8216;#traffic_light input.on&#8217;);$active_light.bind(&#8216;click&#8217;, function(){&#8230;})&nbsp;<br />.css(&#8216;border&#8217;, &#8217;3px dashed yellow&#8217;)&nbsp;<br />.css(&#8216;background-color&#8217;, &#8216;orange&#8217;)&nbsp;<br />.fadeIn(&#8216;slow&#8217;);</p><p style="line-height: 2; margin-top: 0px; margin-right: 0px; margin-bottom: 1.25em; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; text-indent: 2em; ">这样可以写更少的代码, 让我们的js更轻量.</p></li><li style="list-style-type: none; list-style-position: initial; list-style-image: initial; "><h2>5. 使用子查询</h2><p style="line-height: 2; margin-top: 0px; margin-right: 0px; margin-bottom: 1.25em; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; text-indent: 2em; "><strong style="color: black; background-color: #a0ffff; ">jQuery</strong>&nbsp;允许我们对一个已包装的对象使用附加的选择器操作. 因为我们已经在保存了一个父级对象在变量里, 这样大大提高对其子元素的操作:&nbsp;<br />代码如下:</p><p style="line-height: 2; margin-top: 0px; margin-right: 0px; margin-bottom: 1.25em; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; text-indent: 2em; ">&lt;div id="content"&gt;&nbsp;<br />&lt;form method="post" action="/"&gt;&nbsp;<br />&lt;h2&gt;Traffic Light&lt;/h2&gt;&nbsp;<br />&lt;ul id="traffic_light"&gt;&nbsp;<br />&lt;li&gt;&lt;input type="radio" class="on" name="light" value="red" /&gt; Red&lt;/li&gt;&nbsp;<br />&lt;li&gt;&lt;input type="radio" class="off" name="light" value="yellow" /&gt; Yellow&lt;/li&gt;&nbsp;<br />&lt;li&gt;&lt;input type="radio" class="off" name="light" value="green" /&gt; Green&lt;/li&gt;&nbsp;<br />&lt;/ul&gt;&nbsp;<br />&lt;input class="button" id="traffic_button" type="submit" value="Go" /&gt;&nbsp;<br />&lt;/form&gt;&nbsp;<br />&lt;/div&gt;</p><p style="line-height: 2; margin-top: 0px; margin-right: 0px; margin-bottom: 1.25em; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; text-indent: 2em; ">例如, 我们可以用子查询的方法来抓取到亮或不亮的灯, 并缓存起来以备后续操作.&nbsp;<br />代码如下:</p><p style="line-height: 2; margin-top: 0px; margin-right: 0px; margin-bottom: 1.25em; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; text-indent: 2em; ">var $traffic_light = $(&#8216;#traffic_light&#8217;),&nbsp;<br />$active_light = $traffic_light.find(&#8216;input.on&#8217;),&nbsp;<br />$inactive_lights = $traffic_light.find(&#8216;input.off&#8217;);</p><p style="line-height: 2; margin-top: 0px; margin-right: 0px; margin-bottom: 1.25em; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; text-indent: 2em; ">提示: 你可以用逗号分隔的方法一次声明多个局部变量&#8211;节省字节数</p></li><li style="list-style-type: none; list-style-position: initial; list-style-image: initial; "><h2>6. 对直接的DOM操作进行限制</h2><p style="line-height: 2; margin-top: 0px; margin-right: 0px; margin-bottom: 1.25em; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; text-indent: 2em; ">这里的基本思想是在内存中建立你确实想要的东西，然后更新DOM 。这并不是一个<strong style="color: black; background-color: #a0ffff; ">jQuery</strong>最佳实践，但必须进行有效的JavaScript操作 。直接的DOM操作速度很慢。</p><p style="line-height: 2; margin-top: 0px; margin-right: 0px; margin-bottom: 1.25em; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; text-indent: 2em; ">例如,你想动态的创建一组列表元素, 千万不要这么做:&nbsp;<br />代码如下:</p><p style="line-height: 2; margin-top: 0px; margin-right: 0px; margin-bottom: 1.25em; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; text-indent: 2em; ">var top_100_list = [...], // 假设这里是100个独一无二的字符串&nbsp;<br />$mylist = $(&#8216;#mylist&#8217;); //&nbsp;<strong style="color: black; background-color: #a0ffff; ">jQuery</strong>&nbsp;选择到 &lt;ul&gt; 元素for (var i=0, l=top_100_list.length; i&lt;l; i++)&nbsp;<br />{&nbsp;<br />$mylist.<strong style="color: black; background-color: #99ff99; ">append</strong>(&#8216;&lt;li&gt;&#8217; + top_100_list[i] + &#8216;&lt;/li&gt;&#8217;);&nbsp;<br />}</p><p style="line-height: 2; margin-top: 0px; margin-right: 0px; margin-bottom: 1.25em; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; text-indent: 2em; ">我们应该将整套元素字符串在插入进dom中之前全部创建好:&nbsp;<br />代码如下:</p><p style="line-height: 2; margin-top: 0px; margin-right: 0px; margin-bottom: 1.25em; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; text-indent: 2em; ">var top_100_list = [...],&nbsp;<br />$mylist = $(&#8216;#mylist&#8217;),&nbsp;<br />top_100_li = ""; // 这个变量将用来存储我们的列表元素for (var i=0, l=top_100_list.length; i&lt;l; i++)&nbsp;<br />{&nbsp;<br />top_100_li += &#8216;&lt;li&gt;&#8217; + top_100_list[i] + &#8216;&lt;/li&gt;&#8217;;&nbsp;<br />}&nbsp;<br />$mylist.html(top_100_li);</p><p style="line-height: 2; margin-top: 0px; margin-right: 0px; margin-bottom: 1.25em; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; text-indent: 2em; ">我们在插入之前将多个元素包裹进一个单独的父级节点会更快:&nbsp;<br />代码如下:</p><p style="line-height: 2; margin-top: 0px; margin-right: 0px; margin-bottom: 1.25em; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; text-indent: 2em; ">var top_100_list = [...],&nbsp;<br />$mylist = $(&#8216;#mylist&#8217;),&nbsp;<br />top_100_ul = &#8216;&lt;ul id="#mylist"&gt;&#8217;;for (var i=0, l=top_100_list.length; i&lt;l; i++)&nbsp;<br />{&nbsp;<br />top_100_ul += &#8216;&lt;li&gt;&#8217; + top_100_list[i] + &#8216;&lt;/li&gt;&#8217;;&nbsp;<br />}&nbsp;<br />top_100_ul += &#8216;&lt;/ul&gt;&#8217;; //关闭无序列表&nbsp;<br />$mylist.replaceWith(top_100_ul);</p><p style="line-height: 2; margin-top: 0px; margin-right: 0px; margin-bottom: 1.25em; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; text-indent: 2em; ">如果你做了以上几条还是担心有<strong style="color: black; background-color: #ff9999; ">性能</strong>问题,那么:&nbsp;<br /># 试试<strong style="color: black; background-color: #a0ffff; ">jquery</strong>的 clone() 方法, 它会创建一个节点树的副本, 它允许以"离线"的方式进行dom操作, 当你操作完成后再将其放回到节点树里.&nbsp;<br /># 使用 DOM DocumentFragments. 正如<strong style="color: black; background-color: #a0ffff; ">jQuery</strong>作者所言, 它的<strong style="color: black; background-color: #ff9999; ">性能</strong>要明显优于直接的dom操作.</p></li><li style="list-style-type: none; list-style-position: initial; list-style-image: initial; "><h2>7. 冒泡</h2><p style="line-height: 2; margin-top: 0px; margin-right: 0px; margin-bottom: 1.25em; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; text-indent: 2em; ">除非在特殊情况下, 否则每一个js事件(例如:click, mouseover, 等.)都会冒泡到父级节点. 当我们需要给多个元素调用同个函数时这点会很有用.</p><p style="line-height: 2; margin-top: 0px; margin-right: 0px; margin-bottom: 1.25em; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; text-indent: 2em; ">代替这种效率很差的多元素事件监听的方法就是, 你只需向它们的父节点绑定一次, 并且可以计算出哪个节点触发了事件.</p><p style="line-height: 2; margin-top: 0px; margin-right: 0px; margin-bottom: 1.25em; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; text-indent: 2em; ">例如, 我们要为一个拥有很多输入框的表单绑定这样的行为: 当输入框被选中时为它添加一个class</p><p style="line-height: 2; margin-top: 0px; margin-right: 0px; margin-bottom: 1.25em; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; text-indent: 2em; ">像这样绑定事件是低效的:&nbsp;<br />代码如下:</p><p style="line-height: 2; margin-top: 0px; margin-right: 0px; margin-bottom: 1.25em; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; text-indent: 2em; ">$(&#8216;#entryform input).bind(&#8216;focus&#8217;, function(){&nbsp;<br />$(this).addClass(&#8216;selected&#8217;);&nbsp;<br />}).bind(&#8216;blur&#8217;, function(){&nbsp;<br />$(this).removeClass(&#8216;selected&#8217;);&nbsp;<br />});</p><p style="line-height: 2; margin-top: 0px; margin-right: 0px; margin-bottom: 1.25em; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; text-indent: 2em; ">我们需要在父级监听获取焦点和失去焦点的事件:&nbsp;<br />代码如下:</p><p style="line-height: 2; margin-top: 0px; margin-right: 0px; margin-bottom: 1.25em; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; text-indent: 2em; ">$(&#8216;#entryform&#8217;).bind(&#8216;focus&#8217;, function(e){&nbsp;<br />var cell = $(e.target); // e.target grabs the node that triggered the event.&nbsp;<br />cell.addClass(&#8216;selected&#8217;);&nbsp;<br />}).bind(&#8216;blur&#8217;, function(e){&nbsp;<br />var cell = $(e.target);&nbsp;<br />cell.removeClass(&#8216;selected&#8217;);&nbsp;<br />});</p><p style="line-height: 2; margin-top: 0px; margin-right: 0px; margin-bottom: 1.25em; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; text-indent: 2em; ">父级元素扮演了一个调度员的角色, 它可以基于目标元素绑定事件. 如果你发现你给很多元素绑定了同一个事件监听, 那么你肯定哪里做错了.</p></li><li style="list-style-type: none; list-style-position: initial; list-style-image: initial; "><h2>8. 消除无效查询</h2><p style="line-height: 2; margin-top: 0px; margin-right: 0px; margin-bottom: 1.25em; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; text-indent: 2em; ">尽管<strong style="color: black; background-color: #a0ffff; ">jquery</strong>可以很优雅的处理没有匹配元素的情况, 但它还是需要花费时间去寻找. 如果你整站只有一个全局js, 那么极有可能把所有的<strong style="color: black; background-color: #a0ffff; ">jquery</strong>函数塞进$(document)ready(function(){//所有你引以为傲的代码})里.&nbsp;<br />只运行在页面里用到的函数. 大多数有效的方法就是使用行内初始化函数, 这样你的模板就能准确的控制何时何处该执行js.&nbsp;<br />例如, 你的"文章"页面模板, 你可能会引用如下的代码在body结束处:&nbsp;<br />代码如下:</p><p style="line-height: 2; margin-top: 0px; margin-right: 0px; margin-bottom: 1.25em; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; text-indent: 2em; ">&lt;script type="text/javascript&gt;&nbsp;<br />mylib.article.init();&nbsp;<br />&lt;/script&gt;&nbsp;<br />&lt;/body&gt;</p><p style="line-height: 2; margin-top: 0px; margin-right: 0px; margin-bottom: 1.25em; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; text-indent: 2em; ">如果你的页面模板包含一些多变的模块可能不会出现在页面中, 或者为了视觉呈现的原因你需要它们能够快速加载, 你可以将初始化函数紧跟在模块之后.&nbsp;<br />代码如下:</p><p style="line-height: 2; margin-top: 0px; margin-right: 0px; margin-bottom: 1.25em; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; text-indent: 2em; ">&lt;ul id="traffic_light"&gt;&nbsp;<br />&lt;li&gt;&lt;input type="radio" class="on" name="light" value="red" /&gt; Red&lt;/li&gt;&nbsp;<br />&lt;li&gt;&lt;input type="radio" class="off" name="light" value="yellow" /&gt; Yellow&lt;/li&gt;&nbsp;<br />&lt;li&gt;&lt;input type="radio" class="off" name="light" value="green" /&gt; Green&lt;/li&gt;&nbsp;<br />&lt;/ul&gt;&nbsp;<br />&lt;script type="text/javascript&gt;&nbsp;<br />mylib.traffic_light.init();&nbsp;<br />&lt;/script&gt;</p><p style="line-height: 2; margin-top: 0px; margin-right: 0px; margin-bottom: 1.25em; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; text-indent: 2em; ">你的全局js库可能会是这样子的:&nbsp;<br />代码如下:</p><p style="line-height: 2; margin-top: 0px; margin-right: 0px; margin-bottom: 1.25em; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; text-indent: 2em; ">var mylib =&nbsp;<br />{&nbsp;<br />article_page :&nbsp;<br />{&nbsp;<br />init : function()&nbsp;<br />{&nbsp;<br />// Article 特有的<strong style="color: black; background-color: #a0ffff; ">jQuery</strong>函数.&nbsp;<br />}&nbsp;<br />},&nbsp;<br />traffic_light :&nbsp;<br />{&nbsp;<br />init : function()&nbsp;<br />{&nbsp;<br />// Traffic light 特有的<strong style="color: black; background-color: #a0ffff; ">jQuery</strong>函数.&nbsp;<br />}&nbsp;<br />}&nbsp;<br />}</p></li><li style="list-style-type: none; list-style-position: initial; list-style-image: initial; "><h2>9. 推迟到 $(window).load</h2><p style="line-height: 2; margin-top: 0px; margin-right: 0px; margin-bottom: 1.25em; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; text-indent: 2em; "><strong style="color: black; background-color: #a0ffff; ">jquery</strong>对于开发者来说有一个很诱人的东西, 可以把任何东西挂到$(document).ready下冒充事件. 在大多数例子中你都会发现这样的情况.</p><p style="line-height: 2; margin-top: 0px; margin-right: 0px; margin-bottom: 1.25em; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; text-indent: 2em; ">尽管$(document).rady 确实很有用, 它可以在页面渲染时,其它元素还没下载完成就执行. 如果你发现你的页面一直是载入中的状态, 很有可能就是$(document).ready函数引起的.</p><p style="line-height: 2; margin-top: 0px; margin-right: 0px; margin-bottom: 1.25em; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; text-indent: 2em; ">你可以通过将<strong style="color: black; background-color: #a0ffff; ">jquery</strong>函数绑定到$(window).load 事件的方法来减少页面载入时的cpu使用率. 它会在所有的html(包括&lt;iframe&gt;)被下载完成后执行.&nbsp;<br />代码如下:</p><p style="line-height: 2; margin-top: 0px; margin-right: 0px; margin-bottom: 1.25em; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; text-indent: 2em; ">$(window).load(function(){&nbsp;<br />// 页面完全载入后才初始化的<strong style="color: black; background-color: #a0ffff; ">jQuery</strong>函数.&nbsp;<br />});</p><p style="line-height: 2; margin-top: 0px; margin-right: 0px; margin-bottom: 1.25em; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; text-indent: 2em; ">多余的功能例如拖放, 视觉特效和动画, 预载入隐藏图像,等等. 都是适合这种技术的场合.</p></li><li style="list-style-type: none; list-style-position: initial; list-style-image: initial; "><h2>10. 压缩js</h2><p style="line-height: 2; margin-top: 0px; margin-right: 0px; margin-bottom: 1.25em; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; text-indent: 2em; ">推荐一个js在线压缩地址:&nbsp;<br /><a href="http://dean.edwards.name/packer/" style="color: #0481b5; text-decoration: none; ">http://dean.edwards.name/packer/</a>&nbsp;<br /><a href="http://www.jb51.net/tools/packer.htm" style="color: #0481b5; text-decoration: none; ">http://www.jb51.net/tools/packer.htm</a></p></li><li style="list-style-type: none; list-style-position: initial; list-style-image: initial; "><h2>11. 全面掌握<strong style="color: black; background-color: #a0ffff; ">jquery</strong>库</h2><p style="line-height: 2; margin-top: 0px; margin-right: 0px; margin-bottom: 1.25em; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; text-indent: 2em; ">知己知彼, 百战百胜. 只有更深入的了解<strong style="color: black; background-color: #a0ffff; ">jQuery</strong>才能更灵活的使用它. 这里提供一个<strong style="color: black; background-color: #a0ffff; ">jQuery</strong>的速查手册, 可以打印出来随身携带. 要是有能力将<strong style="color: black; background-color: #a0ffff; ">jQuery</strong>源码通读一遍那就更好了.</p></li></ul><p style="line-height: 2; margin-top: 0px; margin-right: 0px; margin-bottom: 1.25em; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; text-indent: 2em; ">文来自：<strong style="color: black; background-color: #a0ffff; ">jQuery</strong>&nbsp;Performance Rules ; 译文来自：Rlog.cn . 若转载请注明出处, 谢谢&nbsp;<br />详细出处参考：http://www.jb51.net/article/22221.htm</p></span></div><img src ="http://www.blogjava.net/xiaomage234/aggbug/352452.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/xiaomage234/" target="_blank">小马歌</a> 2011-06-16 18:05 <a href="http://www.blogjava.net/xiaomage234/archive/2011/06/16/352452.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>BigPipe学习研究</title><link>http://www.blogjava.net/xiaomage234/archive/2011/06/13/352215.html</link><dc:creator>小马歌</dc:creator><author>小马歌</author><pubDate>Mon, 13 Jun 2011 08:56:00 GMT</pubDate><guid>http://www.blogjava.net/xiaomage234/archive/2011/06/13/352215.html</guid><wfw:comment>http://www.blogjava.net/xiaomage234/comments/352215.html</wfw:comment><comments>http://www.blogjava.net/xiaomage234/archive/2011/06/13/352215.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/xiaomage234/comments/commentRss/352215.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/xiaomage234/services/trackbacks/352215.html</trackback:ping><description><![CDATA[&nbsp;&nbsp;&nbsp;&nbsp; 摘要: 1. 技术背景 FaceBook页面加载技术试想这样一个场景，一个经常访问的网站，每次打开它的页面都要要花费6 秒；同时另外一个网站提供了相似的服务，但响应时间只需3 秒，那么你会如何选择呢？数据表明，如果用户打开一个网站，等待3~4 秒还没有任何反应，他们会变得急躁，焦虑，抱怨，甚至关闭网页并且不再访问，这是非常糟糕的情况。所以，网页加载的速度十分重要,尤其对于拥有遍布全球的5亿用户的Faceb...&nbsp;&nbsp;<a href='http://www.blogjava.net/xiaomage234/archive/2011/06/13/352215.html'>阅读全文</a><img src ="http://www.blogjava.net/xiaomage234/aggbug/352215.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/xiaomage234/" target="_blank">小马歌</a> 2011-06-13 16:56 <a href="http://www.blogjava.net/xiaomage234/archive/2011/06/13/352215.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>在 IE 中调试 JavaScript</title><link>http://www.blogjava.net/xiaomage234/archive/2011/06/02/351606.html</link><dc:creator>小马歌</dc:creator><author>小马歌</author><pubDate>Thu, 02 Jun 2011 07:49:00 GMT</pubDate><guid>http://www.blogjava.net/xiaomage234/archive/2011/06/02/351606.html</guid><wfw:comment>http://www.blogjava.net/xiaomage234/comments/351606.html</wfw:comment><comments>http://www.blogjava.net/xiaomage234/archive/2011/06/02/351606.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/xiaomage234/comments/commentRss/351606.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/xiaomage234/services/trackbacks/351606.html</trackback:ping><description><![CDATA[<div><span style="font-family: Simsun; line-height: normal; font-size: medium; "><p style="font-family: arial, nsimsun, sans-serif; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0.3em; padding-right: 5px; padding-bottom: 0.7em; padding-left: 5px; font-size: 0.76em; "><a name="major1"><span style="font-size: 1.5em; font-weight: bold; ">简介</span></a></p><p style="font-family: arial, nsimsun, sans-serif; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0.3em; padding-right: 5px; padding-bottom: 0.7em; padding-left: 5px; font-size: 0.76em; ">虽然越来越多的用户转向使用 FireFox 等非 IE 内核浏览器，但是 Internet Explorer(IE, 6 以及后续版本 ) 仍然有着超过 50% 的市场占有率，大部分产品产品都需要支持 IE。不过 IE 缺少像 FireFox 上那么多调试 JavaScript 代码的插件，使得在 IE 上调试 JavaScript 代码比较困难，很多开发人员喜欢通过加入 alert 语句来进行调试，很大程度上降低了开发效率。 本文详细介绍了在 IE 中进行 JavaScript 调试所用到的工具，并通过一个例子演示了如何使用这些工具， 可以让读者掌握在 IE 上调试 JavaScript 的方法和技巧，加快他们在 IE 上开发 Web 应用的速度。</p><div style="clear: both; background-image: url(http://www.ibm.com/i/solid.gif); background-attachment: initial; background-origin: initial; background-clip: initial; background-color: #ffffff; height: 1px; background-position: initial initial; background-repeat: repeat no-repeat; "></div><p ibm-back-to-top"="" style="font-family: arial, nsimsun, sans-serif; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 5px; padding-right: 5px; padding-bottom: 5px; padding-left: 5px; font-size: 0.76em; clear: both; text-align: right; height: 15px; "><a href="http://www.ibm.com/developerworks/cn/web/1105_libo_iejsdebug/index.html?ca=drs-#ibm-pcon" style="color: #4c6e94; display: inline; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 18px; text-decoration: none; background-image: url(http://www.ibm.com/i/v16/icons/u_bold.gif); background-attachment: initial; background-origin: initial; background-clip: initial; background-color: initial; font-weight: bold; background-position: 0px -1px; background-repeat: no-repeat no-repeat; ">回页首</a></p><p style="font-family: arial, nsimsun, sans-serif; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0.3em; padding-right: 5px; padding-bottom: 0.7em; padding-left: 5px; font-size: 0.76em; "><a name="major2"><span style="font-size: 1.5em; font-weight: bold; ">IE 上的调试工具</span></a></p><p style="font-family: arial, nsimsun, sans-serif; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0.3em; padding-right: 5px; padding-bottom: 0.7em; padding-left: 5px; font-size: 0.76em; ">IE 上可选择的 JavaScript 调试工具不多，主要是 Microsoft 脚本编辑器 (Microsoft Script Editor) 以及 IE Developer Toolbar。</p><p style="font-family: arial, nsimsun, sans-serif; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0.3em; padding-right: 5px; padding-bottom: 0.7em; padding-left: 5px; font-size: 0.76em; "><a name="minor2.1"><span style="font-size: 1.2em; font-weight: bold; ">Microsoft 脚本编辑器</span></a></p><p style="font-family: arial, nsimsun, sans-serif; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0.3em; padding-right: 5px; padding-bottom: 0.7em; padding-left: 5px; font-size: 0.76em; ">Microsoft 脚本编辑器是 Microsoft Office 中的一个小组件，它是一个很完备的 JavaScript 编辑和调试工具， 提供了丰富的调试功能。如果没有安装的话，可以运行 Office 的安装程序，选择&#8221;自定义安装&#8221;类型，然后 在自定义安装向导页面，选中&#8220;选择应用程序的高级自定义&#8221;, 在接下来的高级自定义页面，依次定位到 Microsoft Office-&gt;Office 工具 -&gt;HTML 源文件编辑 -&gt;Web 脚本创作 -&gt; 站点调试，选择&#8220;从本机运行全部程序&#8221;， 如下图所示。然后按照向导，完成安装即可。</p><br /><a name="fig1"><strong style="padding-top: 0.3em; padding-right: 5px; padding-bottom: 0.7em; padding-left: 5px; font-size: 0.76em; font-family: arial, sans-serif; ">图 1. 安装 Microsoft 脚本编辑器</strong></a><br /><img alt="安装 Microsoft 脚本编辑器" height="441" src="http://www.ibm.com/developerworks/cn/web/1105_libo_iejsdebug/figure01.gif" width="511" style="border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; padding-top: 0.3em; padding-right: 5px; padding-bottom: 0.7em; padding-left: 5px; " />&nbsp;<br /><p style="font-family: arial, nsimsun, sans-serif; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0.3em; padding-right: 5px; padding-bottom: 0.7em; padding-left: 5px; font-size: 0.76em; ">如果没有购买 Office 套件，可以从&nbsp;<a href="http://www.ibm.com/developerworks/cn/web/1105_libo_iejsdebug/index.html?ca=drs-#resources" style="color: #4c6e94; ">参考资料</a>列表中下载安装 Microsoft Script Debugger。它是免费的， 比 Microsoft Script Editor 更轻量级，缺点是调试功能，特别是跟踪变量的功能还比较原始。 所以在这里我们还是推荐使用 Microsoft 脚本编辑器。</p><p style="font-family: arial, nsimsun, sans-serif; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0.3em; padding-right: 5px; padding-bottom: 0.7em; padding-left: 5px; font-size: 0.76em; "><a name="minor2.2"><span style="font-size: 1.2em; font-weight: bold; ">IE Developer Toolbar</span></a></p><p style="font-family: arial, nsimsun, sans-serif; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0.3em; padding-right: 5px; padding-bottom: 0.7em; padding-left: 5px; font-size: 0.76em; ">IE Developer Toolbar ，是 IE 上的一个插件，用来探究和理解 Web 页面的便捷工具，最主要的功能包括： 查看并修改页面的 DOM 对象；查看选中元素或者标签的各种属性，包括 HTML 和 CSS 属性以及 JavaScript 事件等。 之所以这里要用到它，是因为在一个设计完备的产品中，页面上的很多元素，包括附加在这些元素上的各种事件， 都是在运行时动态创建的，单纯通过查看源代码，很难找到我们要调试的 JavaScript 函数。在这种情况下， 使用 IE Developer Toolbar，只需要通过鼠标选中目标元素，就可以立即帮助我们找到那些在运行时附加在它上面 的 JavaSscript 函数或者事件。</p><p style="font-family: arial, nsimsun, sans-serif; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0.3em; padding-right: 5px; padding-bottom: 0.7em; padding-left: 5px; font-size: 0.76em; ">可以从&nbsp;<a href="http://www.ibm.com/developerworks/cn/web/1105_libo_iejsdebug/index.html?ca=drs-#resources" style="color: #4c6e94; ">参考资料</a>列表中下载安装 IE Developer Toolbar。安装成功后，会看到它的图标 被加到了 IE 的标准按钮栏上，如下图所示。</p><br /><a name="fig2"><strong style="padding-top: 0.3em; padding-right: 5px; padding-bottom: 0.7em; padding-left: 5px; font-size: 0.76em; font-family: arial, sans-serif; ">图 2. IE Developer Toolbar 图标</strong></a><br /><img alt="IE Developer Toolbar 图标" height="111" src="http://www.ibm.com/developerworks/cn/web/1105_libo_iejsdebug/figure02.gif" width="513" style="border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; padding-top: 0.3em; padding-right: 5px; padding-bottom: 0.7em; padding-left: 5px; " />&nbsp;<br /><p style="font-family: arial, nsimsun, sans-serif; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0.3em; padding-right: 5px; padding-bottom: 0.7em; padding-left: 5px; font-size: 0.76em; "><a name="minor2.3"><span style="font-size: 1.2em; font-weight: bold; ">在 IE 中启用脚本调试功能</span></a></p><p style="font-family: arial, nsimsun, sans-serif; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0.3em; padding-right: 5px; padding-bottom: 0.7em; padding-left: 5px; font-size: 0.76em; ">在我们能够进行 JavaScript 代码调试之前，需要先启用 IE 的脚本调试功能。</p><p style="font-family: arial, nsimsun, sans-serif; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0.3em; padding-right: 5px; padding-bottom: 0.7em; padding-left: 5px; font-size: 0.76em; ">在 IE 菜单的工具菜单中，依次点击：Internet 选项 -&gt; 高级 -&gt; 浏览，取消选中"禁用脚本调试 (Internet Explorer)"和 "禁用脚本调试 ( 其他 )"，如下图所示 .</p><br /><a name="fig3"><strong style="padding-top: 0.3em; padding-right: 5px; padding-bottom: 0.7em; padding-left: 5px; font-size: 0.76em; font-family: arial, sans-serif; ">图 3. 启用脚本调试功能</strong></a><br /><img alt="启用脚本调试功能" height="447" src="http://www.ibm.com/developerworks/cn/web/1105_libo_iejsdebug/figure03.gif" width="425" style="border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; padding-top: 0.3em; padding-right: 5px; padding-bottom: 0.7em; padding-left: 5px; " />&nbsp;<br /><div style="clear: both; background-image: url(http://www.ibm.com/i/solid.gif); background-attachment: initial; background-origin: initial; background-clip: initial; background-color: #ffffff; height: 1px; background-position: initial initial; background-repeat: repeat no-repeat; "></div><p ibm-back-to-top"="" style="font-family: arial, nsimsun, sans-serif; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 5px; padding-right: 5px; padding-bottom: 5px; padding-left: 5px; font-size: 0.76em; clear: both; text-align: right; height: 15px; "><a href="http://www.ibm.com/developerworks/cn/web/1105_libo_iejsdebug/index.html?ca=drs-#ibm-pcon" style="color: #4c6e94; display: inline; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 18px; text-decoration: none; background-image: url(http://www.ibm.com/i/v16/icons/u_bold.gif); background-attachment: initial; background-origin: initial; background-clip: initial; background-color: initial; font-weight: bold; background-position: 0px -1px; background-repeat: no-repeat no-repeat; ">回页首</a></p><p style="font-family: arial, nsimsun, sans-serif; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0.3em; padding-right: 5px; padding-bottom: 0.7em; padding-left: 5px; font-size: 0.76em; "><a name="major3"><span style="font-size: 1.5em; font-weight: bold; ">调试方法</span></a></p><p style="font-family: arial, nsimsun, sans-serif; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0.3em; padding-right: 5px; padding-bottom: 0.7em; padding-left: 5px; font-size: 0.76em; "><a name="minor3.1"><span style="font-size: 1.2em; font-weight: bold; ">被动调试</span></a></p><p style="font-family: arial, nsimsun, sans-serif; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0.3em; padding-right: 5px; padding-bottom: 0.7em; padding-left: 5px; font-size: 0.76em; ">被动调试，也可以称为自动调试，当 IE 碰到 JavaScript 语法及运行时错误，或者选中了查看 -&gt; 脚本调试器 -&gt; 在下一条语句中断， IE 会自动弹出一个"实时调试"窗口，让你选择调试器进行调试，我们选择"新实例 Microsoft Script Editor"，然后点击"是"按钮， 就可以进行调试了，如下图所示。不过这种被动调试方式没有可控性，而且我们平时多是调试逻辑而不是语法错误， 这里就不做详细介绍了。</p><br /><a name="fig4"><strong style="padding-top: 0.3em; padding-right: 5px; padding-bottom: 0.7em; padding-left: 5px; font-size: 0.76em; font-family: arial, sans-serif; ">图 4. 实时调试对话框</strong></a><br /><img alt="实时调试对话框" height="399" src="http://www.ibm.com/developerworks/cn/web/1105_libo_iejsdebug/figure04.gif" width="386" style="border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; padding-top: 0.3em; padding-right: 5px; padding-bottom: 0.7em; padding-left: 5px; " />&nbsp;<br /><p style="font-family: arial, nsimsun, sans-serif; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0.3em; padding-right: 5px; padding-bottom: 0.7em; padding-left: 5px; font-size: 0.76em; "><a name="minor3.2"><span style="font-size: 1.2em; font-weight: bold; ">主动调试 - 使用 debugger 语句</span></a></p><p style="font-family: arial, nsimsun, sans-serif; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0.3em; padding-right: 5px; padding-bottom: 0.7em; padding-left: 5px; font-size: 0.76em; ">我们可以在所要调试的某条语句或者函数中，加入 debugger 语句，这样当 IE 执行到这个 debugger; 语句时，就会弹出实时调试窗口， 让我们进行调试。使用这种调试方法，需要我们知道要在什么地方加入 debugger 语句。我们上面提到，有时候并不是很好确定应该 在哪个函数中加入，这就需要使用 IE Developer Toolbar 来帮助我们进行定位。</p><p style="font-family: arial, nsimsun, sans-serif; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0.3em; padding-right: 5px; padding-bottom: 0.7em; padding-left: 5px; font-size: 0.76em; ">下面我们将以一个例子来说明如何使用 IE Developer Toolbar 来定位目标函数，进而使用 MS Script Editor 进行调试。</p><div style="clear: both; background-image: url(http://www.ibm.com/i/solid.gif); background-attachment: initial; background-origin: initial; background-clip: initial; background-color: #ffffff; height: 1px; background-position: initial initial; background-repeat: repeat no-repeat; "></div><p ibm-back-to-top"="" style="font-family: arial, nsimsun, sans-serif; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 5px; padding-right: 5px; padding-bottom: 5px; padding-left: 5px; font-size: 0.76em; clear: both; text-align: right; height: 15px; "><a href="http://www.ibm.com/developerworks/cn/web/1105_libo_iejsdebug/index.html?ca=drs-#ibm-pcon" style="color: #4c6e94; display: inline; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 18px; text-decoration: none; background-image: url(http://www.ibm.com/i/v16/icons/u_bold.gif); background-attachment: initial; background-origin: initial; background-clip: initial; background-color: initial; font-weight: bold; background-position: 0px -1px; background-repeat: no-repeat no-repeat; ">回页首</a></p><p style="font-family: arial, nsimsun, sans-serif; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0.3em; padding-right: 5px; padding-bottom: 0.7em; padding-left: 5px; font-size: 0.76em; "><a name="major4"><span style="font-size: 1.5em; font-weight: bold; ">应用示例</span></a></p><p style="font-family: arial, nsimsun, sans-serif; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0.3em; padding-right: 5px; padding-bottom: 0.7em; padding-left: 5px; font-size: 0.76em; ">如下图所示，main.htm( 所有的代码都可以在&nbsp;<a href="http://www.ibm.com/developerworks/cn/web/1105_libo_iejsdebug/index.html?ca=drs-#download" style="color: #4c6e94; ">下载</a>部分中获得 ) 是一个用来显示个人信息的页面。 这些信息存储在一个 XML 文件 (data.xml) 中，	 使用 JavaScript(main.js) 进行 XSLT 转换 (data.xsl)，来生成页面内容 .</p><br /><a name="fig5"><strong style="padding-top: 0.3em; padding-right: 5px; padding-bottom: 0.7em; padding-left: 5px; font-size: 0.76em; font-family: arial, sans-serif; ">图 5. 应用示例</strong></a><br /><img alt="应用示例" height="351" src="http://www.ibm.com/developerworks/cn/web/1105_libo_iejsdebug/figure05.gif" width="504" style="border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; padding-top: 0.3em; padding-right: 5px; padding-bottom: 0.7em; padding-left: 5px; " />&nbsp;<br /><p style="font-family: arial, nsimsun, sans-serif; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0.3em; padding-right: 5px; padding-bottom: 0.7em; padding-left: 5px; font-size: 0.76em; ">在&#8220;年龄&#8221;字段的输入框里面，我们只允许输入 0-9 的数字。但是我们可以发现，如果输入 025，在焦点从输入框移出后， 数字会变成 21，这种行为是不正确的，我们可以想到问题应该出在该输入框的 onblur 事件的代码里面。</p><p style="font-family: arial, nsimsun, sans-serif; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0.3em; padding-right: 5px; padding-bottom: 0.7em; padding-left: 5px; font-size: 0.76em; ">那么 onblur 事件对应到哪个函数里面呢？页面上的大部分元素，包括年龄输入框，都是在页面加载后，由 JavaScript 动态生成的， 查看页面的源文件并不能帮我们找到这个函数。这时候就用到 IE Developer Toolbar 了。</p><p style="font-family: arial, nsimsun, sans-serif; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0.3em; padding-right: 5px; padding-bottom: 0.7em; padding-left: 5px; font-size: 0.76em; "><a name="minor4.1"><span style="font-size: 1.2em; font-weight: bold; ">定位目标函数</span></a></p><p style="font-family: arial, nsimsun, sans-serif; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0.3em; padding-right: 5px; padding-bottom: 0.7em; padding-left: 5px; font-size: 0.76em; ">点击 IE 标准按钮工具栏上 IE Developer Toolbar 的图标，IE Developer Toolbar 的界面就出现在页面的底部。 点击 IE Developer Toolbar 界面左上角的&#8220;单击选择元素&#8221;图标 , 然后点击年龄输入框， 在 IE Developer Toolbar 的属性 (Attribute) 面板，就可以看到 onblur 对应的函数了，如下图所示。</p><br /><a name="fig6"><strong style="padding-top: 0.3em; padding-right: 5px; padding-bottom: 0.7em; padding-left: 5px; font-size: 0.76em; font-family: arial, sans-serif; ">图 6. 使用 IE Developer Toolbar 定位目标函数</strong></a><br /><img alt="使用 IE Developer Toolbar 定位目标函数" height="530" src="http://www.ibm.com/developerworks/cn/web/1105_libo_iejsdebug/figure06.gif" width="570" style="border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; padding-top: 0.3em; padding-right: 5px; padding-bottom: 0.7em; padding-left: 5px; " />&nbsp;<br /><p style="font-family: arial, nsimsun, sans-serif; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0.3em; padding-right: 5px; padding-bottom: 0.7em; padding-left: 5px; font-size: 0.76em; "><a name="minor4.2"><span style="font-size: 1.2em; font-weight: bold; ">调试代码</span></a></p><p style="font-family: arial, nsimsun, sans-serif; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0.3em; padding-right: 5px; padding-bottom: 0.7em; padding-left: 5px; font-size: 0.76em; ">通过查找，我们在 main.js 里面找到 fieldBlur 函数，在这个函数的第一行，我们加入 debugger; 语句。然后刷新页面，在年龄输入框输入 025， 然后用鼠标点击输入框以外的页面，IE 会弹出&#8220;实时调试&#8221;对话框，选择&#8220;新实例 Microsoft Script Editor&#8221;。在打开的窗口中，我们可以看到 脚本在 debugger; 语句处暂停执行，如下图所示。</p><br /><a name="fig7"><strong style="padding-top: 0.3em; padding-right: 5px; padding-bottom: 0.7em; padding-left: 5px; font-size: 0.76em; font-family: arial, sans-serif; ">图 7. 使用 Microsoft Script Editor 进行调试</strong></a><br /><img alt="使用 Microsoft Script Editor 进行调试" height="300" src="http://www.ibm.com/developerworks/cn/web/1105_libo_iejsdebug/figure07.gif" width="558" style="border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; padding-top: 0.3em; padding-right: 5px; padding-bottom: 0.7em; padding-left: 5px; " />&nbsp;<br /><p style="font-family: arial, nsimsun, sans-serif; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0.3em; padding-right: 5px; padding-bottom: 0.7em; padding-left: 5px; font-size: 0.76em; ">按两次 F10 键 ( 逐过程单步执行 )，代码将执行到 element.value = parseInt(element.value); 语句。分别选中 element.value 和 parseInt(element.value)， 然后点击右键菜单中的&#8220;添加监视&#8221;项，通过对比它们的值，可以看到问题出在 parseInt 函数：字符串&#8220;025&#8221;被转换成了 21。通过查询函数手册， 发现我们没有给 parseInt 函数指定转换的基数 10，这样&#8220;025&#8221;被当作八进制数处理了。为了验证，我们可以在&#8220;监视 %1&#8221;面板， 手动加入 parsetInt(element.value, 10)，可以看到转换后是正确的了。</p><br /><a name="fig8"><strong style="padding-top: 0.3em; padding-right: 5px; padding-bottom: 0.7em; padding-left: 5px; font-size: 0.76em; font-family: arial, sans-serif; ">图 8. 变量监视窗口</strong></a><br /><img alt="变量监视窗口" height="172" src="http://www.ibm.com/developerworks/cn/web/1105_libo_iejsdebug/figure08.gif" width="555" style="border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; padding-top: 0.3em; padding-right: 5px; padding-bottom: 0.7em; padding-left: 5px; " />&nbsp;<br /><p style="font-family: arial, nsimsun, sans-serif; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0.3em; padding-right: 5px; padding-bottom: 0.7em; padding-left: 5px; font-size: 0.76em; ">这样我们就很顺利地找到了问题的原因和解决办法。</p><div style="clear: both; background-image: url(http://www.ibm.com/i/solid.gif); background-attachment: initial; background-origin: initial; background-clip: initial; background-color: #ffffff; height: 1px; background-position: initial initial; background-repeat: repeat no-repeat; "></div><p ibm-back-to-top"="" style="font-family: arial, nsimsun, sans-serif; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 5px; padding-right: 5px; padding-bottom: 5px; padding-left: 5px; font-size: 0.76em; clear: both; text-align: right; height: 15px; "><a href="http://www.ibm.com/developerworks/cn/web/1105_libo_iejsdebug/index.html?ca=drs-#ibm-pcon" style="color: #4c6e94; display: inline; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 18px; text-decoration: none; background-image: url(http://www.ibm.com/i/v16/icons/u_bold.gif); background-attachment: initial; background-origin: initial; background-clip: initial; background-color: initial; font-weight: bold; background-position: 0px -1px; background-repeat: no-repeat no-repeat; ">回页首</a></p><p style="font-family: arial, nsimsun, sans-serif; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0.3em; padding-right: 5px; padding-bottom: 0.7em; padding-left: 5px; font-size: 0.76em; "><a name="major5"><span style="font-size: 1.5em; font-weight: bold; ">在 IE8 中进行调试</span></a></p><p style="font-family: arial, nsimsun, sans-serif; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0.3em; padding-right: 5px; padding-bottom: 0.7em; padding-left: 5px; font-size: 0.76em; ">随着在 Web 开发中 JavaScript 重要性的日益增加，微软在 IE8 中直接内置了&#8220;开发人员工具&#8221;(Developer Tools)。 我们可以把它看作是 IE Developer Toolbar 的加强版，除了我们上面介绍到的 IE Developer Toolbar 的功能， 它还内置了脚本调试和探查器 (Profiler，性能监控器 ) 的功能。所以如果你的产品只需要在 IE8 上进行调试， 那么就不需要在额外安装其他插件和工具了。下面我们就简单介绍一下调试过程。</p><p style="font-family: arial, nsimsun, sans-serif; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0.3em; padding-right: 5px; padding-bottom: 0.7em; padding-left: 5px; font-size: 0.76em; "><a name="minor5.1"><span style="font-size: 1.2em; font-weight: bold; ">定位目标函数</span></a></p><p style="font-family: arial, nsimsun, sans-serif; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0.3em; padding-right: 5px; padding-bottom: 0.7em; padding-left: 5px; font-size: 0.76em; ">在用 IE8 打开 main.htm 页面后，选择&#8220;工具&#8221;菜单中的&#8220;开发人员工具&#8221;，或者直接按 F12 键，将弹出&#8220;开发人员工具&#8221;的窗口。 为了方便选取页面上的元素，可以点击窗口右上角的&#8220;固定&#8221;图标，来让 &#8220;开发人员工具&#8221;嵌入到页面的下部。然后点击 左上角的&#8220;单击选择元素&#8221;图标，接着点击年龄输入框，同使用 IE Developer Toolbar 一样，在&#8220;开发人员工具&#8221;的属性面板， 就可以看到 onblur 对应的函数了，如下图所示。</p><br /><a name="fig9"><strong style="padding-top: 0.3em; padding-right: 5px; padding-bottom: 0.7em; padding-left: 5px; font-size: 0.76em; font-family: arial, sans-serif; ">图 9. 在 IE8 中定位目标函数</strong></a><br /><img alt="在 IE8 中定位目标函数" height="310" src="http://www.ibm.com/developerworks/cn/web/1105_libo_iejsdebug/figure09.gif" width="570" style="border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; padding-top: 0.3em; padding-right: 5px; padding-bottom: 0.7em; padding-left: 5px; " />&nbsp;<br /><p style="font-family: arial, nsimsun, sans-serif; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0.3em; padding-right: 5px; padding-bottom: 0.7em; padding-left: 5px; font-size: 0.76em; "><a name="minor5.2"><span style="font-size: 1.2em; font-weight: bold; ">调试代码</span></a></p><p style="font-family: arial, nsimsun, sans-serif; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0.3em; padding-right: 5px; padding-bottom: 0.7em; padding-left: 5px; font-size: 0.76em; ">与使用&#8220;Microsoft Script Editor&#8221;一样，我们找到 fieldBlur 函数，在这个函数的第一行，加入 debugger; 语句。然后点击 &#8220;开发人员工具&#8221;窗口的&#8220;脚本&#8221;标签，切换到调试面板，点击&#8220;启动调试&#8221;按钮，在弹出的对话框选择 &#8220;确定&#8221;后，&#8220;开发人员工具&#8221; 窗口会自动弹出，变成独立的窗口。切换到 main.htm 页面，在年龄输入框输入 025，然后用鼠标点击输入框以外的页面， &#8220;开发人员工具&#8221;窗口会自动跳出，我们同样可以监视 element.value 和 parseInt(element.value) 的值，以及手动把 parseInt(element.value,10) 加入监视列表，如下图所示。</p><br /><a name="fig10"><strong style="padding-top: 0.3em; padding-right: 5px; padding-bottom: 0.7em; padding-left: 5px; font-size: 0.76em; font-family: arial, sans-serif; ">图 10. 在 IE8 中使用 debugger 语句调试</strong></a><br /><img alt="在 IE8 中使用 debugger 语句调试" height="340" src="http://www.ibm.com/developerworks/cn/web/1105_libo_iejsdebug/figure10.gif" width="550" style="border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; padding-top: 0.3em; padding-right: 5px; padding-bottom: 0.7em; padding-left: 5px; " />&nbsp;<br /><p style="font-family: arial, nsimsun, sans-serif; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0.3em; padding-right: 5px; padding-bottom: 0.7em; padding-left: 5px; font-size: 0.76em; ">另外我们可以通过设置断点，而不加入 debugger; 语句来进行调试。在&#8220;脚本&#8221;面板上&#8220;开始调试&#8221;按钮右边的文件下拉框， 选择&#8220;main.js"，然后第 83 行代码前面单击鼠标，就在 fieldBlur 函数的第一行设置了断点，然后点击&#8220;开始调试&#8221;按钮， 如下图所示。当我们把鼠标移出年龄输入框后， JavaScript 代码会自动在我们设置的断点处停止执行。</p><br /><a name="fig11"><strong style="padding-top: 0.3em; padding-right: 5px; padding-bottom: 0.7em; padding-left: 5px; font-size: 0.76em; font-family: arial, sans-serif; ">图 11. 在 IE8 中使用断点调试</strong></a><br /><img alt="在 IE8 中使用断点调试" height="206" src="http://www.ibm.com/developerworks/cn/web/1105_libo_iejsdebug/figure11.gif" width="504" style="border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; padding-top: 0.3em; padding-right: 5px; padding-bottom: 0.7em; padding-left: 5px; " />&nbsp;<br /><div style="clear: both; background-image: url(http://www.ibm.com/i/solid.gif); background-attachment: initial; background-origin: initial; background-clip: initial; background-color: #ffffff; height: 1px; background-position: initial initial; background-repeat: repeat no-repeat; "></div><p ibm-back-to-top"="" style="font-family: arial, nsimsun, sans-serif; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 5px; padding-right: 5px; padding-bottom: 5px; padding-left: 5px; font-size: 0.76em; clear: both; text-align: right; height: 15px; "><a href="http://www.ibm.com/developerworks/cn/web/1105_libo_iejsdebug/index.html?ca=drs-#ibm-pcon" style="color: #4c6e94; display: inline; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 18px; text-decoration: none; background-image: url(http://www.ibm.com/i/v16/icons/u_bold.gif); background-attachment: initial; background-origin: initial; background-clip: initial; background-color: initial; font-weight: bold; background-position: 0px -1px; background-repeat: no-repeat no-repeat; ">回页首</a></p><p style="font-family: arial, nsimsun, sans-serif; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0.3em; padding-right: 5px; padding-bottom: 0.7em; padding-left: 5px; font-size: 0.76em; "><a name="major6"><span style="font-size: 1.5em; font-weight: bold; ">总结</span></a></p><p style="font-family: arial, nsimsun, sans-serif; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0.3em; padding-right: 5px; padding-bottom: 0.7em; padding-left: 5px; font-size: 0.76em; ">本文以 IE6 为主，介绍了 IE 浏览器上调试 JavaScript 所用到的工具以及调试方法，并在最后介绍了 IE8 在调试脚本方面的改进。 通过阅读本文，读者可以掌握在 IE 上调试 JavaScript 的方法和技巧，提高他们在 IE 上开发 Web 应用的效率。</p></span></div><img src ="http://www.blogjava.net/xiaomage234/aggbug/351606.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/xiaomage234/" target="_blank">小马歌</a> 2011-06-02 15:49 <a href="http://www.blogjava.net/xiaomage234/archive/2011/06/02/351606.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>(十年积累)div+css 完全兼容ie6 ie7 IE8 IE9 和firefox方法</title><link>http://www.blogjava.net/xiaomage234/archive/2011/06/02/351604.html</link><dc:creator>小马歌</dc:creator><author>小马歌</author><pubDate>Thu, 02 Jun 2011 07:23:00 GMT</pubDate><guid>http://www.blogjava.net/xiaomage234/archive/2011/06/02/351604.html</guid><wfw:comment>http://www.blogjava.net/xiaomage234/comments/351604.html</wfw:comment><comments>http://www.blogjava.net/xiaomage234/archive/2011/06/02/351604.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/xiaomage234/comments/commentRss/351604.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/xiaomage234/services/trackbacks/351604.html</trackback:ping><description><![CDATA[&nbsp;&nbsp;&nbsp;&nbsp; 摘要: (十年积累)div+css 完全兼容ie6 ie7 IE8 IE9 和firefox方法  简单方法：  IE6,IE7,IE8,FF的兼容方法(2)  浏览器兼容代码： 浏览器 符号 IE6 IE7 IE8 FF * !important _ \9 *html *+html 说明：代表能识别； 代表不识别 1、 案例一（常用） 如果各个浏览器的高度都不相同，代码如下： .warp{ Height...&nbsp;&nbsp;<a href='http://www.blogjava.net/xiaomage234/archive/2011/06/02/351604.html'>阅读全文</a><img src ="http://www.blogjava.net/xiaomage234/aggbug/351604.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/xiaomage234/" target="_blank">小马歌</a> 2011-06-02 15:23 <a href="http://www.blogjava.net/xiaomage234/archive/2011/06/02/351604.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>解决修复：IE 7.0访问HTTPS网页显示-此网站出具的安全证书已过期或还未生效</title><link>http://www.blogjava.net/xiaomage234/archive/2011/05/24/350941.html</link><dc:creator>小马歌</dc:creator><author>小马歌</author><pubDate>Tue, 24 May 2011 09:04:00 GMT</pubDate><guid>http://www.blogjava.net/xiaomage234/archive/2011/05/24/350941.html</guid><wfw:comment>http://www.blogjava.net/xiaomage234/comments/350941.html</wfw:comment><comments>http://www.blogjava.net/xiaomage234/archive/2011/05/24/350941.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/xiaomage234/comments/commentRss/350941.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/xiaomage234/services/trackbacks/350941.html</trackback:ping><description><![CDATA[<font size="2">这个问题一般是出现在<font color="#ff0000">Internetr Explorer 7.0</font>上面，<font color="#000000">这个是IE7阅览器提示，IE7浏</font>览器是伴随着Vista操作系统而诞生的，不过微软也发布了针对XP系统的IE7浏览器版本。不过不管是Vista系统还是XP系统下<font color="#000000">的IE7，由于它</font>的安全防范意识有很大提高，对于非法站点和安全加密站点的过滤都比较苛刻，所以在IE7下访问https这种通过SSL协议加密的网站都会出现故障。尤其为人熟知的在打开<font color="#0000ff">淘宝</font>、<font color="#0000ff">支付宝</font>网页的时候经常会出现，Https密码页面也会有这个提示。</font> 
<p><font size="2">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 最容易被一些人搞错地方，就是时间设置问题，所以碰到这种情况，请首先检查你的电脑<font color="#3366ff">时间设置</font>是否正确，如果不正确将导致助理从你的电脑上取到的时候，已经不在服务器发送给助理的有效时间范围内，请你核对你的时间设置是否正确。将&#8220;<font color="#0000ff">自动与internet时间服务器同步</font>&#8221;取消后问题消失。如果还是不行，请看下面。</font></p>
<p><font color="#ffffff" size="2">========================================================================</font></p>
<p>&nbsp;</p>
<p><font color="#ff0000" size="4"><strong>一、XP系统下IE7.0 访问https站点故障排除：</strong></font></p>
<p><font size="2">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 默认情况，XP系统下通过XP版本的IE 7 浏览器，访问https加密的站点都会出现这个提示，这个是IE7阅览器的提示，必须再次点&#8220;<font color="#3366ff">继续浏览此网站（不推荐）</font>&#8221;才能查看页面信息。</font><font size="2">每次访问Https站<font color="#000000">点都需要重复点击，</font>在操作上带来很大的麻烦。下面我们就通过安装证书步骤来解决此问题。 <br /><br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 第一步：当我们用IE7浏览Https站点后会在地址栏右边出现一个红色的&#8220;证书错误&#8221;的提示，我们点该红色按钮，然后选择&#8220;查看证书&#8221;。 </font></p>
<div forimg="1"><font size="2"><img class="blogimg" src="http://hiphotos.baidu.com/masoso/pic/item/a163e2d747c87bc7a044df07.jpg" border="0" small="0"  alt="" /></font></div>
<p><font size="2">第二步：在打开的&#8220;<font color="#3366ff">查看证书</font>&#8221;窗口中的&#8220;<font color="#3366ff">常规</font>&#8221;标签中点右下角的&#8220;<font color="#3366ff">安装证书</font>&#8221;按钮。 </font></p>
<div forimg="1"><font size="2"><img class="blogimg" src="http://hiphotos.baidu.com/masoso/pic/item/8b993b6276c009c7e6113a09.jpg" border="0" small="0"  alt="" /></font></div>
<p><font size="2">第三步：出现&#8220;<font color="#3366ff">证书导入向导</font>&#8221;后点&#8220;<font color="#3366ff">下一步</font>&#8221;按钮继续。</font></p>
<p><font size="2">第四步：选择证书存储的系统区域，通过&#8220;<font color="#3366ff">浏览</font>&#8221;按钮设置将证书保存为&#8220;<font color="#3366ff">受信任的根证书颁发机构</font>&#8221;。 </font></p>
<div forimg="1"><font size="2"><img class="blogimg" src="http://hiphotos.baidu.com/masoso/pic/item/d463bd43340b5e0b9213c615.jpg" border="0" small="0"  alt="" /></font></div>
<p><font size="2">第五步：之后在安全警告窗口中选择&#8220;<font color="#3366ff">是</font>&#8221;按钮来安装该证书。</font></p>
<p><font size="2">第六步：设置完毕后我们再次访问该https站点就不会出现任何问题，也不会再出现这个错误提示了。</font></p>
<p><font color="#ffffff" size="2">========================================================================</font></p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p><font color="#ff0000" size="4"><strong>　 二、Vista系统下IE7.0 访问https站点故障排除：</strong></font></p><font color="#ff0000">
<p><font color="#000000" size="2">　　在Vista系统下使用IE7浏览器访问https站点也会出现这个错误提示，但是他的解决步骤却和XP下IE7有很大区别。这是因为在Vista系统中IE7访问<a name="baidusnap0"></a><strong style="color: black; background-color: #ffff66">https证书</strong>查看里没有安装的提示，错误信息提示&#8220;由于CA根证书不在受信任的根证书颁发机构存储区中，所以他不受信任。</font></p>
<p><font color="#000000" size="2">　　那么该如何解决呢？我是至今还没有发现可以通过调整IE7浏览器的设置来解决此问题，不过可以通过证书导入来解决。</font></p>
<p><font color="#000000" size="2">　　第一步：首先打开IE7浏览器，然后通过&#8220;工具-&gt;internet选项&#8221;打开属性设置窗口，并选择&#8220;内容&#8221;标签，直接点&#8220;<font color="#3366ff">证书</font>&#8221;标签。</font></p>
<p><font color="#000000"><font size="2">　　第二步：选择要安装的证书类型时点&#8220;<font color="#3366ff">受信任的根证书颁发机构</font>&#8221;，接下来点左下角的&#8220;<font color="#3366ff">导入</font>&#8221;按钮。 </font></font></p>
<div forimg="1">
<p><font size="2"><img class="blogimg" src="http://hiphotos.baidu.com/masoso/pic/item/78655f3529e06f91a61e12f5.jpg" border="0" small="0"  alt="" /></font></p>
<p><font size="2"><font color="#000000">　　第三步：这时就需要我们在&#8220;<font color="#3366ff">要导入的文件</font>&#8221;设置窗口中找到该网站的证书文件。至于这个证书文件如何获得，笔者的方法是通过在别的浏览器（例如IE 6或XP系统IE 7）中将该网站对应的证书以文件的形式导出即可，接下来回到Vista系统中导入此文件即可。</font> </font></p>
<div forimg="1">
<p><font size="2"><img class="blogimg" src="http://hiphotos.baidu.com/masoso/pic/item/f7a16c8bba0045c9fd1f10f1.jpg" border="0" small="0"  alt="" /></font></p>
<p><font color="#000000" size="2">　　第四步：在证书存储设置处和上面介绍的方法一样，选择将所有的证书放入下列存储&#8212;&#8212;受信任的根证书颁发机构。</font></p>
<p><font color="#000000" size="2">　　第五步：在安装该证书的窗口中点&#8220;<font color="#3366ff">是</font>&#8221;按钮即可。</font></p>
<p><font color="#000000" size="2">　　第六步：所有工作完成后会出现导入成功的提示，以后我们再访问https加密的站点就不会出现上面的错误提示了。</font></p></div></div></font><img src ="http://www.blogjava.net/xiaomage234/aggbug/350941.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/xiaomage234/" target="_blank">小马歌</a> 2011-05-24 17:04 <a href="http://www.blogjava.net/xiaomage234/archive/2011/05/24/350941.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>https下弹出“本页不但包含安全的内容，也包含不安全的内容”的解决方法</title><link>http://www.blogjava.net/xiaomage234/archive/2011/05/14/350240.html</link><dc:creator>小马歌</dc:creator><author>小马歌</author><pubDate>Sat, 14 May 2011 08:02:00 GMT</pubDate><guid>http://www.blogjava.net/xiaomage234/archive/2011/05/14/350240.html</guid><wfw:comment>http://www.blogjava.net/xiaomage234/comments/350240.html</wfw:comment><comments>http://www.blogjava.net/xiaomage234/archive/2011/05/14/350240.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/xiaomage234/comments/commentRss/350240.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/xiaomage234/services/trackbacks/350240.html</trackback:ping><description><![CDATA[<p>通过HTTPS访问我们做的网站时，总会弹出&#8220;本页不但包含安全的内容，也包含不安全的内容&#8221;的对话框。 <br />
&nbsp;&nbsp;&nbsp; 这是由于网页中含有&lt;iframe&gt;，但iframe的src属性没有设置造成的。 <br />
&nbsp;&nbsp;&nbsp; 解决该问题可用如下方法：&nbsp;<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;客户端：设置IE的属性。例：在IE6上，工具-〉Internet选项-〉安全选项卡-〉自定义级别-〉将&#8220;显示混合内容&#8221;设置为启用 即可解决该问题。这个讨厌的对话框就不会总出现了，嘿嘿。<wbr></p>
<img src ="http://www.blogjava.net/xiaomage234/aggbug/350240.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/xiaomage234/" target="_blank">小马歌</a> 2011-05-14 16:02 <a href="http://www.blogjava.net/xiaomage234/archive/2011/05/14/350240.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>IE对CSS的缓存和GZip似乎有点冲突[转]</title><link>http://www.blogjava.net/xiaomage234/archive/2011/03/08/345930.html</link><dc:creator>小马歌</dc:creator><author>小马歌</author><pubDate>Tue, 08 Mar 2011 05:19:00 GMT</pubDate><guid>http://www.blogjava.net/xiaomage234/archive/2011/03/08/345930.html</guid><wfw:comment>http://www.blogjava.net/xiaomage234/comments/345930.html</wfw:comment><comments>http://www.blogjava.net/xiaomage234/archive/2011/03/08/345930.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/xiaomage234/comments/commentRss/345930.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/xiaomage234/services/trackbacks/345930.html</trackback:ping><description><![CDATA[<div class="cnt" id="blog_text">
<h2>It seems something is wrong with IE's cache and GZip</h2>
<p>好多Linux + Apache的服务器都会对CSS、JS和图片这些静态的内容设置缓存，到了IE这里又会在本地做一个缓存。所以当我们更新了CSS文件之后，常常会出现客户端没有更新，导致显示出现问题。之前我一直使用时间戳参数的方法来解决：</p>
<pre>&lt;link rel="stylesheet" type="text/css" <br />
href="common.css?time=20060408" /&gt;</pre>
<p>每次更改了css文件就把参数time的值设为更改当日的日期，这样本地IE就会把它当作一个新的文件更新一次。</p>
<p>但是在最近做的项目中发现一个比较奇怪的问题，服务器端做了gzip压缩，到客户端第一次解压的时候没问题，第二次访问的时候ie从cache里读文件就出问题了，只能读出前面大约一两千个字节。在两台win2000+ie6的机子上重现了这个问题，XP的还没有发现。</p>
<p>最终的解决方案是在时间戳参数后面再加上一个.css结尾，也就是这么写：</p>
<pre>&lt;link rel="stylesheet" type="text/css" <br />
href="common.css?time=20060408.css" /&gt;</pre>
<p>然后就一切正常了...</p>
<p>大概IE在从缓存里读文件的时候还得对文件扩展名做一个判断，所以这么加一下它就认了。我自己对这个解释不甚满意，所以如果你有标准答案麻烦留个言</p>
<p>BTW，这个现象在.js文件上同样重现了。</p>
</div>
<br />
<img src ="http://www.blogjava.net/xiaomage234/aggbug/345930.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/xiaomage234/" target="_blank">小马歌</a> 2011-03-08 13:19 <a href="http://www.blogjava.net/xiaomage234/archive/2011/03/08/345930.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>基于jQuery的AJAX跨域问题完美解决方案[转]</title><link>http://www.blogjava.net/xiaomage234/archive/2010/11/25/339048.html</link><dc:creator>小马歌</dc:creator><author>小马歌</author><pubDate>Thu, 25 Nov 2010 09:45:00 GMT</pubDate><guid>http://www.blogjava.net/xiaomage234/archive/2010/11/25/339048.html</guid><wfw:comment>http://www.blogjava.net/xiaomage234/comments/339048.html</wfw:comment><comments>http://www.blogjava.net/xiaomage234/archive/2010/11/25/339048.html#Feedback</comments><slash:comments>7</slash:comments><wfw:commentRss>http://www.blogjava.net/xiaomage234/comments/commentRss/339048.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/xiaomage234/services/trackbacks/339048.html</trackback:ping><description><![CDATA[from : http://www.myquickphp.com/archives/147<br />
<br />
<div id="_mcePaste"><strong>(请求的跨域服务器不支持常规&#8221;?&#8221;查询请求时的解决方案)</strong></div>
<div><strong><br />
</strong></div>
<div>昨天第一次做VIP需求时，发现一个超奇怪的问题，我有以下URL地址:</div>
<p>&nbsp;</p>
<div id="_mcePaste">http://dynamic.vip.xxxxxx.com/active/&lt;controllers&gt;/&lt;active&gt;/&lt;id&gt;</div>
<p>&nbsp;</p>
<div id="_mcePaste">放在浏览器地址栏中访问可以得到正确的输出,但我一放到 AJAX 中去异步请求后用 FireBug 调试时确怎么都不出结果，和水龙兄一起调试了很久都没有发现是什么问题，由于这个URL对方的程序是用XX框架写的，我是第一次使用这个XX框架进行开发，对它不是很熟(有时间要研究一下它的内核源码)，总以为是它什么地方有设置影响了的；就在我快要吐血时，乐锋(对这块比较了解的哥们)终于上线了，我把问题向他说下后,他第一反应就是:&#8221;你是不是跨域访问了。。&#8221;</div>
<div>OH FUCK<img alt="" src="http://www.myquickphp.com/wp-content/uploads/2010/08/e.gif" />，我和水龙一直研究程序逻辑，竟然忽视了自己的当前域名,因为我当前执行请求的域名是:</div>
<p>&nbsp;</p>
<div id="_mcePaste">http://vip.xxxxxx.com/active1/index.html</div>
<p>&nbsp;</p>
<div id="_mcePaste">问了一下乐锋,现系统中已提供的几个方案(函数)都不太令人满意或太烦琐了，和乐锋讨论了几种方案后，一时没有找到最好解决方案，一看时间,22:00了，天色已晚，不打扰他晚上陪老婆了！回到家里本想通过利用 iframe 来加载跨域的 url 来得到 dom 数据，研究后发现的想法太天真了，JS的安全策略跟本不允许我这样做；想通过 proxy 代理的方案，但想了一下，那比现在系统中所使用的方案更麻烦，详细研究了一下jQuery最新版关于跨域的解决方案后，终于让我研究出了一种非常方便的解决方案:</div>
<div id="_mcePaste">如下是代码示例:</div>
<div id="_mcePaste">—————— http://a.com/index.html ——————-</div>
<div id="_mcePaste">
<div style="border-right: #cc6633 0.1em solid; padding-right: 2px; border-top: #cc6633 0.1em solid; padding-left: 2px; padding-bottom: 2px; border-left: #cc6633 0.1em solid; padding-top: 2px; border-bottom: #cc6633 0.1em solid"><code><span style="color: #000000"><br />
<span style="color: #007700">&lt;</span><span style="color: #0000bb">script&nbsp;type</span><span style="color: #007700">=</span><span style="color: #dd0000">"text/javascript" </span><span style="color: #0000bb">src</span><span style="color: #007700">=</span><span style="color: #dd0000">"jquery-1.4.2.js"</span><span style="color: #007700">&gt;</span><span style="color: #0000bb">&lt;/script&gt;<br />
</span>&lt;script&nbsp;type="text/javascript"&gt;<br />
/*<br />
AJAX跨域问题完美解决方案<br />
研究:袁维<br />
启示:乐锋<br />
*/<br />
function&nbsp;jsonCallBack(url,callback)<br />
{<br />
$.getScript(url,function(){<br />
callback(json);<br />
});<br />
}<br />
function&nbsp;fun1()<br />
{<br />
jsonCallBack('http://b.com/b.php',function(json){<br />
alert(json.message);<br />
})<br />
}<br />
&lt;/&nbsp;script&gt;<br />
&lt;button&nbsp;type="button"&nbsp;onclick="fun1()"&gt;跨域访问&lt;/button&gt;</span><br />
</code></div>
</div>
<div id="_mcePaste">—————— http://b.com/b.php ——————-</div>
<div id="_mcePaste">
<div style="border-right: #cc6633 0.1em solid; padding-right: 2px; border-top: #cc6633 0.1em solid; padding-left: 2px; padding-bottom: 2px; border-left: #cc6633 0.1em solid; padding-top: 2px; border-bottom: #cc6633 0.1em solid"><code><span style="color: #000000"><br />
<span style="color: #0000bb">&lt;?php<br />
$ary </span><span style="color: #007700">=&nbsp;array(</span><span style="color: #dd0000">'result'</span><span style="color: #007700">=&gt;</span><span style="color: #0000bb">0</span><span style="color: #007700">,</span><span style="color: #dd0000">'message'</span><span style="color: #007700">=&gt;</span><span style="color: #dd0000">'跨域成功'</span><span style="color: #007700">);<br />
</span><span style="color: #0000bb">$json </span><span style="color: #007700">= </span><span style="color: #0000bb">json_encode</span><span style="color: #007700">(</span><span style="color: #0000bb">$ary</span><span style="color: #007700">);<br />
</span><span style="color: #ff8000">//一定要这样定义输出最后的JSON数据,这是利用JS的闭包特性<br />
</span><span style="color: #007700">echo </span><span style="color: #dd0000">"var&nbsp;json=$json;"</span><span style="color: #007700">;<br />
</span><span style="color: #0000bb">?&gt;</span><br />
</span><br />
</code></div>
</div>
<p>&nbsp;</p>
<div><strong>该方案注意事项:</strong></div>
<div>1:jQuery的版本必需大于 1.2版，否则不支持跨域处理</div>
<div id="_mcePaste">2:只支持 GET 方式的请求</div>
<div id="_mcePaste">2:请求的 URL 必需按如下例子中那样返回数据.</div>
<div id="_mcePaste"><strong>该方案注意利弊:</strong></div>
<div id="_mcePaste">
<div id="_mcePaste">优点:</div>
<div id="_mcePaste">1:比用 iframe 加输出 parent.XXX() 的方案简单高效明了，前端处理更方便</div>
<div id="_mcePaste">2:相当 proxy 方式在编程上也简单多了</div>
<div id="_mcePaste">缺点：</div>
<div id="_mcePaste">1:必需使用jQuery，</div>
<div id="_mcePaste">2:返回的数据格式必需按示例样，当然不限于JSON，但它是处理最方便的.</div>
<div><strong>(跨域服务器支持常规&#8221;?&#8221;查询请求的解决方案，利用JQuery的</strong><a class="external text" title="http://bob.pythonmac.org/archives/2005/12/05/remote-json-jsonp/" href="http://bob.pythonmac.org/archives/2005/12/05/remote-json-jsonp/">JSONP</a><strong>)</strong></div>
<div><strong>———————&nbsp;http://b.com/index ———————-</strong></div>
<div style="border-right: #cc6633 0.1em solid; padding-right: 2px; border-top: #cc6633 0.1em solid; padding-left: 2px; padding-bottom: 2px; border-left: #cc6633 0.1em solid; padding-top: 2px; border-bottom: #cc6633 0.1em solid"><code><span style="color: #000000"><br />
<span style="color: #007700">&lt;</span><span style="color: #0000bb">script&nbsp;src</span><span style="color: #007700">=</span><span style="color: #dd0000">"jquery-1.4.2.js" </span><span style="color: #0000bb">type</span><span style="color: #007700">=</span><span style="color: #dd0000">"text/javascript"</span><span style="color: #007700">&gt;</span><span style="color: #0000bb">&lt;/script&gt;<br />
</span>&lt;script&nbsp;type="text/javascript"&gt;<br />
function&nbsp;fun1()<br />
{<br />
$.getJSON("http://a.com/c.php?no=10&amp;msg=ok&amp;format=json&amp;jsoncallback=?",<br />
function(data){<br />
alert(data.msg);<br />
});<br />
}<br />
&lt;/script&gt;<br />
&lt;button&nbsp;type="button"&nbsp;onclick="fun1()"&gt;跨域处理&lt;/button&gt;<br />
</span><br />
</code></div>
<div><strong><br />
</strong></div>
</div>
<div>——————&#8211; http://a.com/c.php ———————-</div>
<div>
<div style="border-right: #cc6633 0.1em solid; padding-right: 2px; border-top: #cc6633 0.1em solid; padding-left: 2px; padding-bottom: 2px; border-left: #cc6633 0.1em solid; padding-top: 2px; border-bottom: #cc6633 0.1em solid"><code><span style="color: #000000"><br />
<span style="color: #0000bb">&lt;?php<br />
$no </span><span style="color: #007700">= </span><span style="color: #0000bb">$_GET</span><span style="color: #007700">[</span><span style="color: #dd0000">'no'</span><span style="color: #007700">];<br />
</span><span style="color: #0000bb">$msg </span><span style="color: #007700">= </span><span style="color: #0000bb">$_GET</span><span style="color: #007700">[</span><span style="color: #dd0000">'msg'</span><span style="color: #007700">];<br />
</span><span style="color: #0000bb">$json </span><span style="color: #007700">= </span><span style="color: #0000bb">json_encode</span><span style="color: #007700">(array(</span><span style="color: #dd0000">'no'</span><span style="color: #007700">=&gt;</span><span style="color: #0000bb">$no</span><span style="color: #007700">,</span><span style="color: #dd0000">'msg'</span><span style="color: #007700">=&gt;</span><span style="color: #0000bb">$msg</span><span style="color: #007700">));<br />
</span><span style="color: #ff8000">//必需以下这样输出<br />
</span><span style="color: #007700">echo </span><span style="color: #0000bb">$_GET</span><span style="color: #007700">[</span><span style="color: #dd0000">'jsoncallback'</span><span style="color: #007700">].</span><span style="color: #dd0000">'('</span><span style="color: #007700">.</span><span style="color: #0000bb">$json</span><span style="color: #007700">.</span><span style="color: #dd0000">')'</span><span style="color: #007700">;<br />
</span><br />
</span><br />
</code></div>
</div>
<p>&nbsp;</p>
<div>不知大哥你是否有更好的解决方案？有请分享一下！<a href="http://www.myquickphp.com/wp-content/uploads/2010/08/g.gif"><img class="alignnone size-full wp-image-84" title="g" height="35" alt="" src="http://www.myquickphp.com/wp-content/uploads/2010/08/g.gif" width="24" /></a></div>
<img src ="http://www.blogjava.net/xiaomage234/aggbug/339048.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/xiaomage234/" target="_blank">小马歌</a> 2010-11-25 17:45 <a href="http://www.blogjava.net/xiaomage234/archive/2010/11/25/339048.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>如何快速的增加外链？</title><link>http://www.blogjava.net/xiaomage234/archive/2010/11/02/336838.html</link><dc:creator>小马歌</dc:creator><author>小马歌</author><pubDate>Tue, 02 Nov 2010 11:35:00 GMT</pubDate><guid>http://www.blogjava.net/xiaomage234/archive/2010/11/02/336838.html</guid><wfw:comment>http://www.blogjava.net/xiaomage234/comments/336838.html</wfw:comment><comments>http://www.blogjava.net/xiaomage234/archive/2010/11/02/336838.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/xiaomage234/comments/commentRss/336838.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/xiaomage234/services/trackbacks/336838.html</trackback:ping><description><![CDATA[增加外链的方法:　<br />
1.找您朋友的网站帮您加您网站的链接.单向链接对您网站效果最好.<br />
2.在Google和Baidu查询您网站的主题.看看排名第一页的网站的反向链接.查询一个网站的反向链接查询方式：link:网站网址. 然后联系这些网站跟您交换链接.或出钱跟他们做单向链接.<br />
3.查询已经被搜索收录的blog大站,每星期去开个blog并把您网站的的内容复制一条到blog里.复制内容到网站时一定要复制内容里有您网站主题关键字的内容.<br />
4.如果您很能写.专门为一些大型网站供稿.让他们加上您网站的链接.一天两天.您在Google和Baidu搜索框输入您发表的标题.就可看到有N多网站转载您网站的内容.也就是所谓的写软文,这招最猛了.<br />
5.去一些大型blog已经被搜索引擎收录的个人blog内容下面给他们评论.加上您网站链接.<br />
6.如果您有不错的技术,且您网站全部是原创的话.把您的网站内容输出成RSS.提交他Google和Baidu新闻中心.会有上W IP引来您网站.也会被N多网站引用.<br />
7.如果您也能写.另一个站长也能写.那您俩可以合作.他写的软文发表加您的链接.您写的软文也加他的链接.然后同时发表.不同内容都有你俩的链接.这可是一个双赢的好办法.<br />
8.把网站提交给开放目录DMOZ(dmoz.org),DMOZ收录网站的时间较长,可能需要1个月甚至1年时间.但收录后效果非常明显.<br />
9.现在好多大型站点都有网上收藏夹.比如Yahoo收藏夹.QQ书签，在Google和Baidu搜索网上收藏夹有N多.<br />
10.现在流行ask爱问.Baidu知道等问答系统.在这些站点搜索您网站的关键字.回答相关的问题关留下您网站网址.<br _extended="true" />
<img src ="http://www.blogjava.net/xiaomage234/aggbug/336838.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/xiaomage234/" target="_blank">小马歌</a> 2010-11-02 19:35 <a href="http://www.blogjava.net/xiaomage234/archive/2010/11/02/336838.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>IE7报错，找不到元素--装过IE8之后又卸载回IE7的朋友们可能碰到</title><link>http://www.blogjava.net/xiaomage234/archive/2009/05/07/269450.html</link><dc:creator>小马歌</dc:creator><author>小马歌</author><pubDate>Thu, 07 May 2009 09:24:00 GMT</pubDate><guid>http://www.blogjava.net/xiaomage234/archive/2009/05/07/269450.html</guid><wfw:comment>http://www.blogjava.net/xiaomage234/comments/269450.html</wfw:comment><comments>http://www.blogjava.net/xiaomage234/archive/2009/05/07/269450.html#Feedback</comments><slash:comments>2</slash:comments><wfw:commentRss>http://www.blogjava.net/xiaomage234/comments/commentRss/269450.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/xiaomage234/services/trackbacks/269450.html</trackback:ping><description><![CDATA[最近在做项目的时候，实现一个很简单的加入收藏夹的功能，网上代码多的是，如下就是我整理的一个版本
<p style="text-align: center">&nbsp;</p>
<p style="text-align: left"><span style="font-family: '-webkit-monospace'"><span><textarea class="java" name="code" rows="15" cols="50">&lt;!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"&gt;
&lt;html&gt;
&lt;head&gt;
&lt;title&gt;addFavorite.html&lt;/title&gt;
&lt;meta http-equiv="keywords" content="keyword1,keyword2,keyword3"&gt;
&lt;meta http-equiv="description" content="this is my page"&gt;
&lt;meta http-equiv="content-type" content="text/html; charset=UTF-8"&gt;
&lt;!--&lt;link rel="stylesheet" type="text/css" href="./styles.css" mce_href="styles.css"&gt;--&gt;
&lt;script type="text/javascript"&gt;
function doFavorite(favName) {
window.external.addFavorite(getRootPath(), favName);
}
function getRootPath() {
var location = document.location;
if ("file:" == location.protocol) {
var str = location.toString();
return str.replace(str.split("/").reverse()[0], "");
}
var pathName = location.pathname.split("/");
return location.protocol + "//" + location.host + "/" + pathName[1] + "/";
}
&lt;/script&gt;
&lt;/head&gt;
&lt;body&gt;
&lt;span  onclick="doFavorite('TMS收藏')" style="cursor:pointer;text-decoration:underline;"&gt;添加收藏&lt;/span&gt;
&lt;/body&gt;
&lt;/html&gt;  </textarea>&nbsp;</span></span></p>
<p style="text-align: left">&nbsp;</p>
<p style="text-align: left">&nbsp;&nbsp; &nbsp; &nbsp;注：如果该页面没有放在服务器（如tomcat）上 ，而是放在普通文件夹中（如桌面），则浏览器状态栏会报没有权限的错误，具体原因有待研究，不属于本次讨论的范围。</p>
<p style="text-align: left">&nbsp;&nbsp; &nbsp; &nbsp;我将以上代码放到服务器中并执行时，IE7浏览器状态栏报错，&#8220;找不到元素&#8221;，但同事的浏览器可以正常访问，也能添加到收藏夹。故确定是我的浏览器的问题。</p>
<blockquote>
<p style="text-align: left">Google搜到国外一个帖子，如下：</p>
<p style="text-align: left">GWT not working on Internet explorer 7 (IE7) giving "Element not found" javascript error</p>
<p style="text-align: left">&nbsp;</p>
<p style="text-align: left">GWT web application started to give "Element not found" javascript error message on Internet Explorer 7 (IE7)? This application worked fine on Internet Explorer 6 and Firefox 2. Now your best guess would be; GWT not working on IE 7 properly. Wasn't it?&nbsp;</p>
<p style="text-align: left">&nbsp;</p>
<p style="text-align: left">But the scenario became confusing and unbelievable because your application worked fine on IE7 in some machines while not on some others. Have you faced this issue? Then the below solution is for you.</p>
<p style="text-align: left">&nbsp;</p>
<p style="text-align: left">This issue can be fixed by a making a change on windows registry.&nbsp;</p>
<p style="text-align: left">&nbsp;</p>
<p style="text-align: left">Steps to follow are;</p>
<p style="text-align: left">1. Open up the Registry editor - type regedit on command prompt.</p>
<p style="text-align: left">&nbsp;</p>
<p style="text-align: left">2. Look for the key shown below</p>
<p style="text-align: left">HKEY_CLASSES_ROOT\TypeLib\{EAB22AC0-30C1-11CF-A7EB-0000C05BAE0B}\1.1\0\win32</p>
<p style="text-align: left">&nbsp;</p>
<p style="text-align: left">3. Click on the "Default" row and see the value there. If it's value is "C:\WINDOWS\system32\shdocvw.dll", then that is what causes the above mentioned issue. If you have installed Windows in a different drive; C:\ must be replaced with the that letter.</p>
<p style="text-align: left">&nbsp;</p>
<p style="text-align: left">4. Replace that value with "C:\WINDOWS\system32\ieframe.dll".</p>
</blockquote>
<p style="text-align: left">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;5. Now restart IE7, and load your GWT application.</p>
<p style="text-align: left">&nbsp;</p>
<p style="text-align: left">&nbsp;&nbsp; &nbsp; </p>
<p style="text-align: left">&nbsp;&nbsp; &nbsp; 于是猛然想起，我之前也装过IE8的测试版，但是后来又被我卸载了，原因就在于此，按照上述方法，更改了注册表，重启IE7，运行没有问题。</p>
<p style="text-align: left">&nbsp;</p>
<p style="text-align: left">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;另外也顺便收藏了IE和FF都适用的方法：</p>
<p style="text-align: left"><textarea class="javascript" name="code" rows="15" cols="50">function addBookmark(title,url) {
if (window.sidebar) {
window.sidebar.addPanel(title, url,"");
} else if( document.all ) {
window.external.AddFavorite( url, title);
} else if( window.opera &amp;&amp; window.print ) {
return true;
}
}</textarea>&nbsp;</p>
<p style="text-align: center">&nbsp;</p>
<p style="text-align: left">写完手工。</p>
<img src ="http://www.blogjava.net/xiaomage234/aggbug/269450.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/xiaomage234/" target="_blank">小马歌</a> 2009-05-07 17:24 <a href="http://www.blogjava.net/xiaomage234/archive/2009/05/07/269450.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>用tabindex属性强化用户体验</title><link>http://www.blogjava.net/xiaomage234/archive/2009/03/04/257752.html</link><dc:creator>小马歌</dc:creator><author>小马歌</author><pubDate>Wed, 04 Mar 2009 04:02:00 GMT</pubDate><guid>http://www.blogjava.net/xiaomage234/archive/2009/03/04/257752.html</guid><wfw:comment>http://www.blogjava.net/xiaomage234/comments/257752.html</wfw:comment><comments>http://www.blogjava.net/xiaomage234/archive/2009/03/04/257752.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/xiaomage234/comments/commentRss/257752.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/xiaomage234/services/trackbacks/257752.html</trackback:ping><description><![CDATA[<div class="date">2008-08-27 10:00</div>
<table style="table-layout: fixed">
    <tbody>
        <tr>
            <td>
            <div class="cnt" id="blog_text">
            <p>这里我们先来区分两种填写表单的方法：<br />
            第一种，<strong>用鼠标在表单项中切换</strong>。这是我们经常用的，他们会先找到需要填写的第一项，用鼠标点上去，然后右手移到键盘上（我们暂且不管你的左手放在什么地方），填写信息，接着右手移到鼠标上，点选第二项，再把右手移到键盘上，填写信息&#8230;&#8230;不断重复，直到表单填写完，最后用鼠标点击&#8220;提交表单&#8221;按钮。这样做起来非常不方便，尤其是用户体验上。<br />
            第二种，<strong>用Tab键切换</strong>。在填写表单时只在填第一项时用鼠标点选，该项填写完成后用Tab键切换至下一项，最后用回车键送出表单。整个填写过程中，双手只停留在键盘上，不用摸鼠标。<br />
            哪种方法的效率高？大家一定都有相同的答案。<br />
            有没有办法修正这一点呢？答案就是使用tabindex属性。</p>
            <p><br />
            tabindex属性设置按下tab键时的响应顺序。它的值是一个数字，越小的数字响应顺序越靠前，最小为1。在未设置tabindex属性时，tab键将从页面的第一个链接或者表单项开始切换（这里要说明一个情况，IE浏览器中第一次按下tab键时，选中的是地址栏）。<br />
            利用tabindex的这一特性，我们就可以给表单里的各项添加相应的属性。比如一个登录表单，第一个表单项是&#8220;用户名&#8221;，我们就可以在这一项上添加tabindex=&#8221;1&#8221;,并依次为后面的项赋值。这样，在访问这个页面时，按下tab键后光标就停在&#8220;用户名&#8221;的文本输入框上，从而完全实现了无鼠标参与的表单填写。<br />
            此外，在某些网站的注册页面，部分表单项后面会跟着一个链接或者按钮，用来对当前项的需要输入的内容进行解释或验证。在未添加tabindex属性的页面，tab键会经过这些链接或按钮。熟练的tab键用户往往会在这上面犯错误——他们以为光标已经进入下一个文本框了，可实际却停在一个链接上。最糟的情况时，他们就完全找不到光标了，从而需要重新拿起鼠标来点选下一项。使用tabindex属性就可以很好的避免这一点。为每个表单项都添加tabindex，tab键就不会进入非填写区域了。<br />
            不过我很遗憾的发现，在我访问过的网站中，没有一家使用tabindex属性。</p>
            <p>最后，我提供一段代码供您测试tabindex属性的作用。</p>
            <p>&lt;form id=&#8221;form&#8221; name=&#8221;form&#8221; method=&#8221;post&#8221; action=&#8221;"&gt;<br />
            &lt;p&gt;&lt;a href=&#8221;www.trade.cn&#8221;&gt; 贸易视点网&lt;/a&gt;&lt;/p&gt;<br />
            &lt;p&gt;第二项：<br />
            &lt;label&gt;<br />
            &lt;input type=&#8221;text&#8221; <strong><font color="#ff0000">tabindex=&#8221;2&#8243;</font></strong> name=&#8221;textfield&#8221; /&gt;<br />
            &lt;/label&gt;<br />
            &lt;/p&gt;<br />
            &lt;p&gt;第一项：<br />
            &lt;label&gt;<br />
            &lt;input type=&#8221;text&#8221;<strong> <font color="#ff0000">tabindex=&#8221;1&#8243;</font></strong> name=&#8221;textfield2&#8243; /&gt;<br />
            &lt;/label&gt;<br />
            &lt;/p&gt;<br />
            &lt;p&gt;第三项：<br />
            &lt;label&gt;<br />
            &lt;input type=&#8221;text&#8221; <font color="#ff0000"><strong>tabindex=&#8221;3&#8243; </strong></font>name=&#8221;textfield3&#8243; /&gt;<br />
            &lt;/label&gt;<br />
            &lt;/p&gt;<br />
            &lt;/form&gt;</p>
            </div>
            </td>
        </tr>
    </tbody>
</table>
<img src ="http://www.blogjava.net/xiaomage234/aggbug/257752.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/xiaomage234/" target="_blank">小马歌</a> 2009-03-04 12:02 <a href="http://www.blogjava.net/xiaomage234/archive/2009/03/04/257752.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>Blackbird漂亮的开源JS版Log记录工具</title><link>http://www.blogjava.net/xiaomage234/archive/2009/02/06/253496.html</link><dc:creator>小马歌</dc:creator><author>小马歌</author><pubDate>Fri, 06 Feb 2009 02:14:00 GMT</pubDate><guid>http://www.blogjava.net/xiaomage234/archive/2009/02/06/253496.html</guid><wfw:comment>http://www.blogjava.net/xiaomage234/comments/253496.html</wfw:comment><comments>http://www.blogjava.net/xiaomage234/archive/2009/02/06/253496.html#Feedback</comments><slash:comments>1</slash:comments><wfw:commentRss>http://www.blogjava.net/xiaomage234/comments/commentRss/253496.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/xiaomage234/services/trackbacks/253496.html</trackback:ping><description><![CDATA[<strong>描述：</strong>Blackbird是一个用于记录log信息的工具，有了它，你可以抛弃alert提示，你能方便的将它插入页面中，支持多浏览器。<br />
<strong>地址：</strong><span title="http://www.gscottolson.com/blackbirdjs/">http://www.gscottolson.com/blackbirdjs/</span><br />
<br />
<a class="thickbox" title="Blackbird漂亮的开源JS版Log记录工具" href="http://www.webappers.com/img/2008/10/blackbird.png" jquery1233886294421="10"><img style="overflow: hidden" src="http://www.webappers.com/img/2008/10/blackbird.png"  alt="" /></a><br />
<br />
下载包:<a href="/Files/xiaomage234/blackbirdjs.rar">/Files/xiaomage234/blackbirdjs.rar</a>
<img src ="http://www.blogjava.net/xiaomage234/aggbug/253496.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/xiaomage234/" target="_blank">小马歌</a> 2009-02-06 10:14 <a href="http://www.blogjava.net/xiaomage234/archive/2009/02/06/253496.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>解决IE6、IE7、IE8样式不兼容问题</title><link>http://www.blogjava.net/xiaomage234/archive/2008/11/29/243386.html</link><dc:creator>小马歌</dc:creator><author>小马歌</author><pubDate>Sat, 29 Nov 2008 02:38:00 GMT</pubDate><guid>http://www.blogjava.net/xiaomage234/archive/2008/11/29/243386.html</guid><wfw:comment>http://www.blogjava.net/xiaomage234/comments/243386.html</wfw:comment><comments>http://www.blogjava.net/xiaomage234/archive/2008/11/29/243386.html#Feedback</comments><slash:comments>5</slash:comments><wfw:commentRss>http://www.blogjava.net/xiaomage234/comments/commentRss/243386.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/xiaomage234/services/trackbacks/243386.html</trackback:ping><description><![CDATA[<p>如果你的页面对IE7兼容没有问题，又不想大量修改现有代码，同时又能在IE8中正常使用，微软声称，开发商仅需要在目前兼容IE7的网站上添加一行代码即可解决问题，此代码如下： <br />
CODE:<br />
&lt;meta http-equiv="x-ua-compatible" content="ie=7" /&gt;<br />
以上代码我已用过。很好用，大家如有遇到类似问题。不防试试。<br />
<br />
本文来自: http://hi.baidu.com/huo1608</p>
<img src ="http://www.blogjava.net/xiaomage234/aggbug/243386.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/xiaomage234/" target="_blank">小马歌</a> 2008-11-29 10:38 <a href="http://www.blogjava.net/xiaomage234/archive/2008/11/29/243386.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>我所接触的IE6,IE7差别</title><link>http://www.blogjava.net/xiaomage234/archive/2008/11/24/242244.html</link><dc:creator>小马歌</dc:creator><author>小马歌</author><pubDate>Mon, 24 Nov 2008 04:33:00 GMT</pubDate><guid>http://www.blogjava.net/xiaomage234/archive/2008/11/24/242244.html</guid><wfw:comment>http://www.blogjava.net/xiaomage234/comments/242244.html</wfw:comment><comments>http://www.blogjava.net/xiaomage234/archive/2008/11/24/242244.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/xiaomage234/comments/commentRss/242244.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/xiaomage234/services/trackbacks/242244.html</trackback:ping><description><![CDATA[<p>总体的感觉是IE7比 IE6 兼容性更好，更健壮。<br />
几个细节对比：<br />
1，如果页面无编码描述定义，比如: &lt;meta http-equiv="Content-Type" content="text/html; charset=gb2312" /&gt;<br />
在IE6里可能显示乱码，但IE7不写也可以显示出来。<br />
<br />
2，&lt;a href 标签去请求js事件，该事件请求图片的过程中，如果这么写: &lt;a hef="javascript:viod(0)" onclick="call()"，图片可能会遇到 "Aborted"的错误，即图片加载过程中被其他事件打扰，造成下载失败。但在 IE7就没事。<br />
<br />
写法可以改成:<br />
&lt;a hef="#" onclick="call()"，[这种写法会跳到页头的锚点]<br />
<br />
或者 &lt;a hef="javascript:call()"&nbsp; [推荐这种写法]<br />
<br />
3,还有一个&lt;button标签的提交方法 &lt;form的onsubmit方法执行完js方法后，必须 return false。[这个跟ie版本无关]</p>
<img src ="http://www.blogjava.net/xiaomage234/aggbug/242244.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/xiaomage234/" target="_blank">小马歌</a> 2008-11-24 12:33 <a href="http://www.blogjava.net/xiaomage234/archive/2008/11/24/242244.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>Js小技巧汇总</title><link>http://www.blogjava.net/xiaomage234/archive/2008/11/13/240351.html</link><dc:creator>小马歌</dc:creator><author>小马歌</author><pubDate>Thu, 13 Nov 2008 09:13:00 GMT</pubDate><guid>http://www.blogjava.net/xiaomage234/archive/2008/11/13/240351.html</guid><wfw:comment>http://www.blogjava.net/xiaomage234/comments/240351.html</wfw:comment><comments>http://www.blogjava.net/xiaomage234/archive/2008/11/13/240351.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/xiaomage234/comments/commentRss/240351.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/xiaomage234/services/trackbacks/240351.html</trackback:ping><description><![CDATA[1,查找地址栏特定参数值:<br />
&lt;script&gt;<br />
function getmyvalue(param){<br />
&nbsp;var x = window.location.href.match(new RegExp('[?&amp;]' + param + '=([^&amp;]+)(&amp;|$)'));<br />
&nbsp;return x ? x[1] : '';<br />
}<br />
&lt;/script&gt;<br />
<br />
2,js的escape，可以返回中文unicode编码串[将"%"替换成"\"即可用于js，避免编码中文导致的js错误]<br />
网页源代码:test.html<br />
<p>&lt;html&gt;</p>
<p>&lt;head&gt;<br />
&lt;meta http-equiv="Content-Type" content="text/html; charset=gb2312"&gt;<br />
&lt;title&gt;新建网页 1&lt;/title&gt;<br />
&lt;script type=text/javascript&gt;<br />
function test()<br />
{<br />
//alert(document.getElementById("tt").value);<br />
//alert(encodeURI(document.getElementById("tt").value));<br />
document.getElementById("t2").value=escape(document.getElementById("tt").value);<br />
}<br />
function test2()<br />
{<br />
//alert(document.getElementById("tt").value);<br />
//alert(encodeURI(document.getElementById("tt").value));<br />
document.getElementById("t3").value=unescape(document.getElementById("t2").value);<br />
}</p>
<p>&lt;/script&gt;<br />
&lt;/head&gt;</p>
<p>&lt;body&gt;<br />
&lt;input type=text id=tt name=tt /&gt;<br />
&lt;input type=button value=ch onclick="test()"/&gt;<br />
&lt;input type=text id =t2 name=t2/&gt;<br />
&lt;input type=button value=ch2 onclick="test2()"/&gt;<br />
&lt;input type=text id =t3 name=t3/&gt;<br />
&lt;/body&gt;</p>
<p>&lt;/html&gt;<br />
</p>
<br />
3,window.onload事件<br />
<p>可能你也碰到过这种情况,就是在js的代码中用了window.onload后,可能会影响到body中的onload事件。你可以全写在body中，也可以全放到window.onload中，但是这样并不是很方便，有时我们需要两个同时用到。这时就要用window.attachEvent和window.addEventListener来解决一下。</p>
<p>下面是一个解决方法。至于attachEvent和addEventListener的用法，可以自己Google或百度一下。</p>
<p>if (document.all){<br />
window.attachEvent('onload',函数名)//IE中<br />
}else{<br />
window.addEventListener('load',函数名,false);//firefox<br />
}<br />
在近来的工作中，用到了attachEvent方法，该方法可以为某一事件附加其它的处理事件，有时候可能比较有用，这里将其基本用法总结一下。</p>
<p>其语法可以查看《DHTML手册》，里面有详细的说明，这里贴一个例子，该例子来自互联网：</p>
<p>document.getElementById("btn").onclick = method1; <br />
document.getElementById("btn").onclick = method2; <br />
document.getElementById("btn").onclick = method3;<br />
如果这样写,那么将会只有medhot3被执行</p>
<p>写成这样：<br />
var btn1Obj = document.getElementById("btn1"); <br />
//object.attachEvent(event,function); <br />
btn1Obj.attachEvent("onclick",method1); <br />
btn1Obj.attachEvent("onclick",method2); <br />
btn1Obj.attachEvent("onclick",method3);<br />
执行顺序为method3-&gt;method2-&gt;method1</p>
<p><br />
如果是Mozilla系列，并不支持该方法，需要用到addEventListener<br />
var btn1Obj = document.getElementById("btn1"); <br />
//element.addEventListener(type,listener,useCapture); <br />
btn1Obj.addEventListener("click",method1,false); <br />
btn1Obj.addEventListener("click",method2,false); <br />
btn1Obj.addEventListener("click",method3,false);<br />
执行顺序为method1-&gt;method2-&gt;method3<br />
<br />
<br />
</p>
<img src ="http://www.blogjava.net/xiaomage234/aggbug/240351.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/xiaomage234/" target="_blank">小马歌</a> 2008-11-13 17:13 <a href="http://www.blogjava.net/xiaomage234/archive/2008/11/13/240351.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>大黄蜂的俄罗斯方块[网页版]，留着参考~</title><link>http://www.blogjava.net/xiaomage234/archive/2008/11/01/238011.html</link><dc:creator>小马歌</dc:creator><author>小马歌</author><pubDate>Sat, 01 Nov 2008 04:04:00 GMT</pubDate><guid>http://www.blogjava.net/xiaomage234/archive/2008/11/01/238011.html</guid><wfw:comment>http://www.blogjava.net/xiaomage234/comments/238011.html</wfw:comment><comments>http://www.blogjava.net/xiaomage234/archive/2008/11/01/238011.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/xiaomage234/comments/commentRss/238011.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/xiaomage234/services/trackbacks/238011.html</trackback:ping><description><![CDATA[<a href="/Files/xiaomage234/fangkuai.rar">/Files/xiaomage234/fangkuai.rar</a>
 <img src ="http://www.blogjava.net/xiaomage234/aggbug/238011.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/xiaomage234/" target="_blank">小马歌</a> 2008-11-01 12:04 <a href="http://www.blogjava.net/xiaomage234/archive/2008/11/01/238011.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>JavaScript 中 void(0) 的含义 [转]</title><link>http://www.blogjava.net/xiaomage234/archive/2008/10/30/237690.html</link><dc:creator>小马歌</dc:creator><author>小马歌</author><pubDate>Thu, 30 Oct 2008 12:48:00 GMT</pubDate><guid>http://www.blogjava.net/xiaomage234/archive/2008/10/30/237690.html</guid><wfw:comment>http://www.blogjava.net/xiaomage234/comments/237690.html</wfw:comment><comments>http://www.blogjava.net/xiaomage234/archive/2008/10/30/237690.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/xiaomage234/comments/commentRss/237690.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/xiaomage234/services/trackbacks/237690.html</trackback:ping><description><![CDATA[<p>我想使用过ajax的都常见这样的代码：<br />
&lt;a href="javascript:doTest2();void(0);"&gt;here&lt;/a&gt;<br />
但这儿的void(0)究竟是何含义呢？<br />
<br />
JavaScript中void是一个操作符，该操作符指定要计算一个表达式但是不返回值。<br />
<br />
void 操作符用法格式如下： <br />
1. javascript:void (expression)<br />
2. javascript:void expression <br />
<br />
expression 是一个要计算的 JavaScript 标准的表达式。表达式外侧的圆括号是可选的，但是写上去是一个好习惯。 (<em>实现版本&nbsp;&nbsp; Navigator 3.0</em>&nbsp;&nbsp; )<br />
<br />
你可以使用 void 操作符指定超级链接。表达式会被计算但是不会在当前文档处装入任何内容。</p>
<p>下面的代码创建了一个超级链接，当用户点击以后不会发生任何事。当用户点击链接时，void(0) 计算为 0，但在 JavaScript 上没有任何效果。</p>
<p>&lt;A HREF="javascript:void(0)"&gt;单击此处什么也不会发生&lt;/A&gt;</p>
<p>下面的代码创建了一个超级链接，用户单击时会提交表单。</p>
<p>&lt;A HREF="javascript:void(document.form.submit())"&gt;单击此处提交表单&lt;/A&gt;</p>
<p>&nbsp;</p>
<p>那什么情况下用void(0)比较多呢，无刷新，当然是Ajax了，看一下Ajax的web页面的话，一般都会看到有很多的void(0)，所以在使用void(0)之前，最好先想一想这个页面是否需要整体刷新。</p>
<p>----------------------------------------------------------------------------</p>
<p>使用javascript的时候，通常我们会通过类似：&lt;a href="#" onclick="javascript:方法"&gt;提交&lt;/a&gt; 的方式，通过一个伪链接来调用javascript方法。这种方法有一个问题是：虽然点击该链接的时候不会跳转页面，但是滚动条会往上滚，解决的办法是返回一个false。<br />
如下所示：<br />
&lt;a href="#" onclick="javascript:方法;return false;"&gt;提交&lt;/a&gt;</p>
<p>&lt;a href="javascript:void(0)" onclick="javascript:方法;return false;"&gt;提交&lt;/a&gt;</p>
<p>还有一个方法是 #this <br />
a href="#this" onclick="javascript:方法"</p>
<p>----------------------------------------------------------------------------</p>
<p><br />
＃包含了一个位置信息</p>
<p>默认的锚点是＃top 也就是网页的上端</p>
<p>而javascript:void(0)&nbsp;&nbsp; 仅仅表示一个死链接</p>
<p>这就是为什么有的时候页面很长浏览链接明明是＃可是跳动到了页首</p>
<p>而javascript:void(0) 则不是如此</p>
<p>所以调用脚本的时候最好用void(0) 或者&lt;input onclick&gt; &lt;div onclick&gt;等<br />
<br />
打开新窗口链接的几种办法<br />
<br />
1.window.open('url')<br />
<br />
2.用自定义函数</p>
<div style="border-right: rgb(204,204,204) 1px solid; padding-right: 5px; border-top: rgb(204,204,204) 1px solid; padding-left: 4px; font-size: 13px; padding-bottom: 4px; border-left: rgb(204,204,204) 1px solid; width: 98%; padding-top: 4px; border-bottom: rgb(204,204,204) 1px solid; background-color: rgb(238,238,238)" twffan="done"><img src="http://www.cnblogs.com/Images/OutliningIndicators/None.gif" align="top" twffan="done"  alt="" /><span style="color: rgb(0,0,0)" twffan="done">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: rgb(0,0,0)" twffan="done">&lt;</span><span style="color: rgb(0,0,0)" twffan="done">script</span><span style="color: rgb(0,0,0)" twffan="done">&gt;</span><span style="color: rgb(0,0,0)" twffan="done"><br />
<img src="http://www.cnblogs.com/Images/OutliningIndicators/None.gif" align="top" twffan="done"  alt="" />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: rgb(0,0,255)" twffan="done">function</span><span style="color: rgb(0,0,0)" twffan="done"> openWin(tag,obj)<br />
<img src="http://www.cnblogs.com/Images/OutliningIndicators/ExpandedBlockStart.gif" align="top" twffan="done"  alt="" /><img style="display: none" src="http://www.cnblogs.com/Images/OutliningIndicators/ContractedBlock.gif" align="top" twffan="done"  alt="" />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="border-right: rgb(128,128,128) 1px solid; border-top: rgb(128,128,128) 1px solid; display: none; border-left: rgb(128,128,128) 1px solid; border-bottom: rgb(128,128,128) 1px solid; background-color: rgb(255,255,255)" twffan="done"><img src="http://www.cnblogs.com/Images/dot.gif" twffan="done"  alt="" /></span><span twffan="done"><span style="color: rgb(0,0,0)" twffan="done">{<br />
<img src="http://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif" align="top" twffan="done"  alt="" />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; obj.target</span><span style="color: rgb(0,0,0)" twffan="done">=</span><span style="color: rgb(0,0,0)" twffan="done">"</span><span style="color: rgb(0,0,0)" twffan="done">_blank</span><span style="color: rgb(0,0,0)" twffan="done">"</span><span style="color: rgb(0,0,0)" twffan="done">;<br />
<img src="http://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif" align="top" twffan="done"  alt="" />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; obj.href </span><span style="color: rgb(0,0,0)" twffan="done">=</span><span style="color: rgb(0,0,0)" twffan="done"> </span><span style="color: rgb(0,0,0)" twffan="done">"</span><span style="color: rgb(0,0,0)" twffan="done">Web/Substation/Substation.aspx?stationno=</span><span style="color: rgb(0,0,0)" twffan="done">"</span><span style="color: rgb(0,0,0)" twffan="done">+</span><span style="color: rgb(0,0,0)" twffan="done">tag;<br />
<img src="http://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif" align="top" twffan="done"  alt="" />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; obj.click();<br />
<img src="http://www.cnblogs.com/Images/OutliningIndicators/ExpandedBlockEnd.gif" align="top" twffan="done"  alt="" />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }</span></span><span style="color: rgb(0,0,0)" twffan="done"><br />
<img src="http://www.cnblogs.com/Images/OutliningIndicators/None.gif" align="top" twffan="done"  alt="" />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: rgb(0,0,0)" twffan="done">&lt;/</span><span style="color: rgb(0,0,0)" twffan="done">script</span><span style="color: rgb(0,0,0)" twffan="done">&gt;</span></div>
<p>&nbsp;</p>
<div style="border-right: rgb(204,204,204) 1px solid; padding-right: 5px; border-top: rgb(204,204,204) 1px solid; padding-left: 4px; font-size: 13px; padding-bottom: 4px; border-left: rgb(204,204,204) 1px solid; width: 98%; padding-top: 4px; border-bottom: rgb(204,204,204) 1px solid; background-color: rgb(238,238,238)" twffan="done"><img src="http://www.cnblogs.com/Images/OutliningIndicators/None.gif" align="top" twffan="done"  alt="" /><span style="color: rgb(0,0,255)" twffan="done">&lt;</span><span style="color: rgb(128,0,0)" twffan="done">a </span><span style="color: rgb(255,0,0)" twffan="done">href</span><span style="color: rgb(0,0,255)" twffan="done">="javascript:void(0)"</span><span style="color: rgb(255,0,0)" twffan="done"> onclick</span><span style="color: rgb(0,0,255)" twffan="done">="openWin(3,this)"</span><span style="color: rgb(0,0,255)" twffan="done">&gt;</span><span style="color: rgb(0,0,0)" twffan="done">株洲</span><span style="color: rgb(0,0,255)" twffan="done">&lt;/</span><span style="color: rgb(128,0,0)" twffan="done">a</span><span style="color: rgb(0,0,255)" twffan="done">&gt;</span></div>
<p>3.window.location.href=""</p>
<div class="comment_content"><font style="background-color: #ffff80">总结：</font></div>
<div class="comment_content"><font style="background-color: #ffff80">1）链接（href）直接使用javascript:void(0)在IE中可能会引起一些问题，比如：造成gif动画停止播放 等，所以，最安全的办法还是使用&#8220;#&#8221;。为防止点击链接后跳转到页首，onclick事件return false即可。</font></div>
<div></div>
<div><font style="background-color: #ffff80">2）在使用void(0)之前,最好先想一想，这个页面是否需要整体刷新，不需要整体刷新时可以用void(0)。</font></div>
 <img src ="http://www.blogjava.net/xiaomage234/aggbug/237690.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/xiaomage234/" target="_blank">小马歌</a> 2008-10-30 20:48 <a href="http://www.blogjava.net/xiaomage234/archive/2008/10/30/237690.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item></channel></rss>