<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>飞鱼 ^_^ 浆抱罗斯‘s blog &#187; 慢性创可贴</title>
	<atom:link href="http://www.qilei.org/category/tip/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.qilei.org</link>
	<description>这里是一个非专业交互设计师-飞鱼-的博客。飞鱼的生活就像吃一盘螺丝, 你得努力吸才能品尝到快乐^_^</description>
	<lastBuildDate>Sun, 25 Jul 2010 00:40:24 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0</generator>
		<item>
		<title>table &lt;col&gt; 标签的妙用</title>
		<link>http://www.qilei.org/201007/very-useful-of-table-col-tag/</link>
		<comments>http://www.qilei.org/201007/very-useful-of-table-col-tag/#comments</comments>
		<pubDate>Thu, 15 Jul 2010 13:11:49 +0000</pubDate>
		<dc:creator>飞鱼</dc:creator>
				<category><![CDATA[慢性创可贴]]></category>
		<category><![CDATA[html]]></category>

		<guid isPermaLink="false">http://www.qilei.org/?p=870</guid>
		<description><![CDATA[在写表单数据的时候，要给列元素定宽度，同事告诉的有个col 标签，可以控制table 的列元素的标签， 还有colgroup 可以支持style，class 等属性。 不过有点要注意的是，只支持宽度等基本style属性。 具体请查阅文档 注意 ：html5 不再支持大多数属性，不过基本功能还是能用的。 您可能还对这些日志感兴趣 - 随意从一个专题入手(一)-产品设计师发现 图片上的map的链接 不能是target=&#8221;_blank&#8221; A Kingdom老婆生病了 &#8211; 又神奇的好了马扁子]]></description>
			<content:encoded><![CDATA[<p>在写表单数据的时候，要给列元素定宽度，同事告诉的有个col 标签，可以控制table 的列元素的标签，<br />
还有colgroup 可以支持style，class 等属性。<br />
不过有点要注意的是，只支持宽度等基本style属性。<br />
具体请<a href="http://goo.gl/6FO6">查阅文档</a><br />
<em>注意 ：html5 不再支持大多数属性，不过基本功能还是能用的。</em></p>
<h2  class="related_post_title">您可能还对这些日志感兴趣 - 随意</h2><ul class="related_post"><li><a href="http://www.qilei.org/201003/using-trigger-bind-function-in-jquery-2/" title="隔山打牛 &#8211; jQuery中 trigger() &#038; bind() 使用心得 (二)">隔山打牛 &#8211; jQuery中 trigger() &#038; bind() 使用心得 (二)</a></li><li><a href="http://www.qilei.org/200901/the-search-snapshot-break-my-web/" title="再次被破 &#8211; 都是网页快照惹得祸">再次被破 &#8211; 都是网页快照惹得祸</a></li><li><a href="http://www.qilei.org/200902/gray-view-in-different-computer-lcd/" title="小灰狼都被扼杀了&#8211;灰度在不同质量LCD的呈现问题">小灰狼都被扼杀了&#8211;灰度在不同质量LCD的呈现问题</a></li><li><a href="http://www.qilei.org/200903/not-your-mothers-javascript/" title="一些疯狂的JSer &#8211; Chrome Experiments">一些疯狂的JSer &#8211; Chrome Experiments</a></li><li><a href="http://www.qilei.org/200811/firebug-lite-in-ie/" title="IE上的轻量级调试工具-firebug Lite">IE上的轻量级调试工具-firebug Lite</a></li></ul>]]></content:encoded>
			<wfw:commentRss>http://www.qilei.org/201007/very-useful-of-table-col-tag/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>inline-block 的 text-indent会产生联动 效应</title>
		<link>http://www.qilei.org/200911/inline-block-relative-text-indent-trouble/</link>
		<comments>http://www.qilei.org/200911/inline-block-relative-text-indent-trouble/#comments</comments>
		<pubDate>Fri, 27 Nov 2009 16:38:00 +0000</pubDate>
		<dc:creator>飞鱼</dc:creator>
				<category><![CDATA[慢性创可贴]]></category>

		<guid isPermaLink="false">http://www.qilei.org/?p=669</guid>
		<description><![CDATA[给一个inline 属性的文字 加一个ico，如&#60;span&#62;星&#60;/span&#62;通行证(星星在句首)。 然后想把星星两个字隐藏掉，自然的用到了 text-indent:-999em 和 overflow 两个属性，然后发现产生了联动效应 后面的字也跟着 缩进了，很神奇。 解决方案： 直接给通行证加&#60;span&#62;如：&#60;span&#62;通行证&#60;/span&#62; 然后写样式，星星的文案省略。不用隐藏。 您可能还对这些日志感兴趣 - 随意一知半解 &#8211; 分析淘宝商城首页的 lazy load 功能M8 到手 内牛满面 Dreamweaver CS4 试用笔记探索 firefox 的放大原理 (二)table &#60;col&#62; 标签的妙用]]></description>
			<content:encoded><![CDATA[<p>给一个inline 属性的文字 加一个ico，如&lt;span&gt;星&lt;/span&gt;通行证(星星在句首)。 然后想把星星两个字隐藏掉，自然的用到了 text-indent:-999em 和 overflow 两个属性，然后发现产生了联动效应 后面的字也跟着 缩进了，很神奇。<br />
<strong>解决方案：</strong> 直接给通行证加&lt;span&gt;如：&lt;span&gt;通行证&lt;/span&gt; 然后写样式，星星的文案省略。不用隐藏。</p>
<h2  class="related_post_title">您可能还对这些日志感兴趣 - 随意</h2><ul class="related_post"><li><a href="http://www.qilei.org/200909/jquery-fade-picture/" title="乱翻乱教 &#8211; jQuery图片轮播插件 &#8211; 菜鸟版">乱翻乱教 &#8211; jQuery图片轮播插件 &#8211; 菜鸟版</a></li><li><a href="http://www.qilei.org/200812/the-2008-merry-christmas/" title="圣诞节 &#8211; 杭州一点都不冷">圣诞节 &#8211; 杭州一点都不冷</a></li><li><a href="http://www.qilei.org/200901/the-search-snapshot-break-my-web/" title="再次被破 &#8211; 都是网页快照惹得祸">再次被破 &#8211; 都是网页快照惹得祸</a></li><li><a href="http://www.qilei.org/200805/merry-in-the-day-of-512/" title="结婚？ 很矛盾">结婚？ 很矛盾</a></li><li><a href="http://www.qilei.org/201002/tryout-m8-system-969/" title="整得连妈都不认识了 &#8211; M8 新固件9.6.X 试用体验">整得连妈都不认识了 &#8211; M8 新固件9.6.X 试用体验</a></li></ul>]]></content:encoded>
			<wfw:commentRss>http://www.qilei.org/200911/inline-block-relative-text-indent-trouble/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>发现 图片上的map的链接 不能是target=&#8221;_blank&#8221;</title>
		<link>http://www.qilei.org/200911/map-on-img-can-not-target-_blank/</link>
		<comments>http://www.qilei.org/200911/map-on-img-can-not-target-_blank/#comments</comments>
		<pubDate>Fri, 27 Nov 2009 16:36:46 +0000</pubDate>
		<dc:creator>飞鱼</dc:creator>
				<category><![CDATA[慢性创可贴]]></category>
		<category><![CDATA[css]]></category>

		<guid isPermaLink="false">http://www.qilei.org/?p=667</guid>
		<description><![CDATA[记得是做一个特辑的时候 需要在图片上加三个热点(map)，然后很神奇的发现，map上不能加target=“_blank” 不知道是偶然的还是 必然的。 解决方案： 用a 绝对定位解决了。 ==========补充============ 是偶然，不过要注意的是 图片上一旦加了map后，加在图片外的链接a 就失效。 您可能还对这些日志感兴趣伸缩自如 &#8211; 绝对定位的自适应能力DivCSS经验：三种实用CSS清除浮动的方法异变: input的背景background怨念体 &#8211; 不同的字体有不同的line-height此学校在退化]]></description>
			<content:encoded><![CDATA[<p>记得是做一个特辑的时候 需要在图片上加三个热点(map)，然后很神奇的发现，map上不能加target=“_blank”<br />
不知道是偶然的还是 必然的。<br />
<strong>解决方案：</strong> 用a 绝对定位解决了。</p>
<p>==========补充============</p>
<p>是偶然，不过要注意的是 图片上一旦加了map后，加在图片外的链接a 就失效。 </p>
<h2  class="related_post_title">您可能还对这些日志感兴趣</h2><ul class="related_post"><li><a href="http://www.qilei.org/201005/css-about-absolute-layout-fix/" title="伸缩自如 &#8211; 绝对定位的自适应能力">伸缩自如 &#8211; 绝对定位的自适应能力</a></li><li><a href="http://www.qilei.org/200910/clear-float/" title="DivCSS经验：三种实用CSS清除浮动的方法">DivCSS经验：三种实用CSS清除浮动的方法</a></li><li><a href="http://www.qilei.org/200906/input-background-of-css/" title="异变: input的背景background">异变: input的背景background</a></li><li><a href="http://www.qilei.org/200903/line-height-in-def-browser-of-def-font/" title="怨念体 &#8211; 不同的字体有不同的line-height">怨念体 &#8211; 不同的字体有不同的line-height</a></li><li><a href="http://www.qilei.org/200902/suspire-of-the-notice/" title="此学校在退化">此学校在退化</a></li></ul>]]></content:encoded>
			<wfw:commentRss>http://www.qilei.org/200911/map-on-img-can-not-target-_blank/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>DivCSS经验：三种实用CSS清除浮动的方法</title>
		<link>http://www.qilei.org/200910/clear-float/</link>
		<comments>http://www.qilei.org/200910/clear-float/#comments</comments>
		<pubDate>Wed, 14 Oct 2009 09:20:02 +0000</pubDate>
		<dc:creator>飞鱼</dc:creator>
				<category><![CDATA[慢性创可贴]]></category>
		<category><![CDATA[css]]></category>

		<guid isPermaLink="false">http://www.qilei.org/?p=580</guid>
		<description><![CDATA[转自：http://www.bobd.cn/design/web/htmlcss/200906/32713.html 应用DivCSS网页布局，经常性地会使用到float，很多邪门的事儿都有可能是浮动在作怪，关于清除浮动，在52CSS.com上有过很多介绍。清除浮动是必须要做的，而且随时性地对父级元素清除浮动的做法也被认为是书写CSS的良好习惯之一。 未清除浮动源代码 &#60;style type=”text/css”&#62; &#60;!– *{margin:0;padding:0;} body{font:36px bold; color:#F00; text-align:center;} #layout{background:#FF9;} #left{float:left;width:20%;height:200px;background:#DDD;line-height:200px;} #right{float:right;width:30%;height:80px;background:#DDD;line-height:80px;} –&#62; &#60;/style&#62; &#60;div id=”layout”&#62; &#60;div id=”left”&#62;Left&#60;/div&#62; &#60;div id=”right”&#62;Right&#60;/div&#62; &#60;/div&#62; 一、使用空标签清除浮动 我用了很久的一种方法，空标签可以是div标签，也可以是P标签。我习惯用 ，够简短，也有很多人用&#60;hr /&#62;，只是需要另外为其清除边框，但理论上可以是任何标签。这种方式是在需要清除浮动的父级元素内部的所有浮动元素后添加这样一个标签清楚浮动，并为其定义CSS代码：clear:both。此方法的弊端在于增加了无意义的结构元素。 &#60;style type=”text/css”&#62; &#60;!– *{margin:0;padding:0;} body{font:36px bold; color:#F00; text-align:center;} #layout{background:#FF9;} #left{float:left;width:20%;height:200px;background:#DDD;line-height:200px;} #right{float:right;width:30%;height:80px;background:#DDD;line-height:80px;} .clr{clear:both;} –&#62; &#60;/style&#62; &#60;div id=”layout”&#62; &#60;div id=”left”&#62;Left&#60;/div&#62; &#60;div id=”right”&#62;Right&#60;/div&#62; &#60;p class=”clr”&#62; &#60;/div&#62; 二、使用overflow属性 此方法有效地解决了通过空标签元素清除浮动而不得不增加无意代码的弊端。使用该方法是只需在需要清除浮动的元素中定义CSS属性：overflow:auto，即可！”zoom:1″用于兼容IE6。 &#60;style type=”text/css”&#62; &#60;!– *{margin:0;padding:0;} body{font:36px bold; color:#F00; text-align:center;} #layout{background:#FF9;overflow:auto;zoom:1;} #left{float:left;width:20%;height:200px;background:#DDD;line-height:200px;} #right{float:right;width:30%;height:80px;background:#DDD;line-height:80px;} –&#62; &#60;/style&#62; &#60;div id=”layout”&#62; &#60;div id=”left”&#62;Left&#60;/div&#62; [...]]]></description>
			<content:encoded><![CDATA[<p>转自：http://www.bobd.cn/design/web/htmlcss/200906/32713.html</p>
<p>应用DivCSS网页布局，经常性地会使用到float，很多邪门的事儿都有可能是浮动在作怪，关于清除浮动，在52CSS.com上有过很多介绍。清除浮动是必须要做的，而且随时性地对父级元素清除浮动的做法也被认为是书写CSS的良好习惯之一。<br />
<span id="more-580"></span></p>
<h3>未清除浮动源代码</h3>
<pre><code>&lt;style type=”text/css”&gt;
&lt;!–
    *{margin:0;padding:0;}
    body{font:36px bold; color:#F00; text-align:center;}
    #layout{background:#FF9;}
    #left{float:left;width:20%;height:200px;background:#DDD;line-height:200px;}
    #right{float:right;width:30%;height:80px;background:#DDD;line-height:80px;}
–&gt;
&lt;/style&gt;
&lt;div id=”layout”&gt;
    &lt;div id=”left”&gt;Left&lt;/div&gt;
    &lt;div id=”right”&gt;Right&lt;/div&gt;
&lt;/div&gt;</code></pre>
<h3>一、使用空标签清除浮动</h3>
<p>我用了很久的一种方法，空标签可以是div标签，也可以是P标签。我习惯用</p>
<p>，够简短，也有很多人用<code>&lt;hr /&gt;</code>，只是需要另外为其清除边框，但理论上可以是任何标签。这种方式是在需要清除浮动的父级元素内部的所有浮动元素后添加这样一个标签清楚浮动，并为其定义CSS代码：<code>clear:both</code>。此方法的弊端在于增加了无意义的结构元素。</p>
<pre><code>
&lt;style type=”text/css”&gt;
&lt;!–
 *{margin:0;padding:0;}
 body{font:36px bold; color:#F00; text-align:center;}
 #layout{background:#FF9;}
 #left{float:left;width:20%;height:200px;background:#DDD;line-height:200px;}
 #right{float:right;width:30%;height:80px;background:#DDD;line-height:80px;}
 .clr{clear:both;}
–&gt;
&lt;/style&gt;
&lt;div id=”layout”&gt;
 &lt;div id=”left”&gt;Left&lt;/div&gt;
 &lt;div id=”right”&gt;Right&lt;/div&gt;
 &lt;p class=”clr”&gt;
&lt;/div&gt;</code></pre>
<h3>二、使用overflow属性</h3>
<p>此方法有效地解决了通过空标签元素清除浮动而不得不增加无意代码的弊端。使用该方法是只需在需要清除浮动的元素中定义CSS属性：overflow:auto，即可！”zoom:1″用于兼容IE6。</p>
<pre><span style="font-family: monospace;">&lt;style type=”text/css”&gt;
&lt;!–
 *{margin:0;padding:0;}
 body{font:36px bold; color:#F00; text-align:center;}
 #layout{background:#FF9;overflow:auto;zoom:1;}
 #left{float:left;width:20%;height:200px;background:#DDD;line-height:200px;}
 #right{float:right;width:30%;height:80px;background:#DDD;line-height:80px;}
–&gt;
&lt;/style&gt;
&lt;div id=”layout”&gt;
 &lt;div id=”left”&gt;Left&lt;/div&gt;
 &lt;div id=”right”&gt;Right&lt;/div&gt;
&lt;/div&gt;</span></pre>
<h3>三、使用after伪对象清楚浮动</h3>
<p>该方法只适用于非IE浏览器。具体写法可参照以下示例。<br />
使用中需注意以下几点。<br />
一、该方法中必须为需要清除浮动元素的伪对象中设置height:0，否则该元素会比实际高出若干像素；<br />
二、content属性是必须的，但其值可以为空，蓝色理想讨论该方法的时候content属性的值设为”.”，但我发现为空亦是可以的。</p>
<pre><span style="font-family: monospace;">&lt;style type=”text/css”&gt; 
&lt;!– 
 *{margin:0;padding:0;} 
 body{font:36px bold; color:#F00; text-align:center;} 
 #layout{background:#FF9;} 
 #layout:after{display:block;clear:both;content:”";visibility:hidden;height:0;} 
 #left{float:left;width:20%;height:200px;background:#DDD;line-height:200px;} 
 #right{float:right;width:30%;height:80px;background:#DDD;line-height:80px;} 
–&gt; 
&lt;/style&gt; 
&lt;div id=”layout”&gt; 
 &lt;div id=”left”&gt;Left&lt;/div&gt; 
 &lt;div id=”right”&gt;Right&lt;/div&gt; 
&lt;/div&gt;</span></pre>
<h2  class="related_post_title">您可能还对这些日志感兴趣</h2><ul class="related_post"><li><a href="http://www.qilei.org/201005/css-about-absolute-layout-fix/" title="伸缩自如 &#8211; 绝对定位的自适应能力">伸缩自如 &#8211; 绝对定位的自适应能力</a></li><li><a href="http://www.qilei.org/200911/map-on-img-can-not-target-_blank/" title="发现 图片上的map的链接 不能是target=&#8221;_blank&#8221; ">发现 图片上的map的链接 不能是target=&#8221;_blank&#8221; </a></li><li><a href="http://www.qilei.org/200906/input-background-of-css/" title="异变: input的背景background">异变: input的背景background</a></li><li><a href="http://www.qilei.org/200903/line-height-in-def-browser-of-def-font/" title="怨念体 &#8211; 不同的字体有不同的line-height">怨念体 &#8211; 不同的字体有不同的line-height</a></li><li><a href="http://www.qilei.org/200902/suspire-of-the-notice/" title="此学校在退化">此学校在退化</a></li></ul>]]></content:encoded>
			<wfw:commentRss>http://www.qilei.org/200910/clear-float/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>js跨域问题</title>
		<link>http://www.qilei.org/200910/cross-scripting/</link>
		<comments>http://www.qilei.org/200910/cross-scripting/#comments</comments>
		<pubDate>Wed, 14 Oct 2009 08:21:45 +0000</pubDate>
		<dc:creator>飞鱼</dc:creator>
				<category><![CDATA[慢性创可贴]]></category>
		<category><![CDATA[javascript]]></category>

		<guid isPermaLink="false">http://www.qilei.org/?p=575</guid>
		<description><![CDATA[转自：http://f2e.me/200904/cross-scripting/ javascript出于安全方面的考虑，是不允许跨域调用其他页面的对象的。但在安全限制的同时也给注入iframe或是ajax应用上带来了不少麻烦。没有记错的话前三届D2论坛上每次都有人提这个东西，这里把涉及到跨域的一些问题简单地整理一下： 首先什么是跨域，简单地理解就是因为javascript同源策略的限制，a.com 域名下的js无法操作b.com或是c.a.com域名下的对象。更详细的说明可以看下表： URL 说明 是否允许通信 URL 说明 是否允许通信 http://www.f2e.me/lab/a.js http://www.f2e.me/script/b.js 同一域名下不同文件夹 允许 http://www.f2e.me/a.js http://www.f2e.me/b.js 同一域名下 允许 http://www.f2e.me:8000/a.js http://www.f2e.me/b.js 同一域名，不同端口 不允许 http://www.f2e.me/a.js https://www.f2e.me/b.js 同一域名，不同协议 不允许 http://www.f2e.me/a.js http://70.32.92.74/b.js 域名和域名对应ip 不允许 http://www.f2e.me/a.js http://script.f2e.me/b.js 主域相同，子域不同 不允许 http://www.space007.com/a.js http://www.f2e.me/b.js 不同域名 不允许 特别注意两点： 第一，如果是协议和端口造成的跨域问题“前台”是无能为力的， 第二：在跨域问题上，域仅仅是通过URL的首部来识别而不会去尝试判断相同的ip地址对应着两个域或两个域是否在同一个ip上。 接下来简单地总结一下在“前台”一般处理跨域的办法，后台proxy这种方案牵涉到后台的配置，这里就不阐述了,有兴趣的可以看看YAHOO的这篇文章： ﻿ JavaScript: Use a Web Proxy for Cross-Domain XMLHttpRequest Calls。 1、document.domain+iframe的设置 对于主域相同而子域不同的例子，可以通过设置document.domain的办法来解决。具体的做法是可以在http://www.f2e.me/a.html和http://script.f2e.me/b.html两个文件中分别加上document.domain = [...]]]></description>
			<content:encoded><![CDATA[<p>转自：http://f2e.me/200904/cross-scripting/<br />
javascript出于安全方面的考虑，是不允许跨域调用其他页面的对象的。但在安全限制的同时也给注入iframe或是ajax应用上带来了不少麻烦。没有记错的话前三届D2论坛上每次都有人提这个东西，这里把涉及到跨域的一些问题简单地整理一下：<br />
<span id="more-575"></span><br />
首先什么是跨域，简单地理解就是因为javascript同源策略的限制，a.com 域名下的js无法操作b.com或是c.a.com域名下的对象。更详细的说明可以看下表：</p>
<p>URL 说明 是否允许通信</p>
<table border="0" width="100%">
<tbody>
<tr>
<td bgcolor="#99ccff">URL</td>
<td bgcolor="#99ccff">说明</td>
<td bgcolor="#99ccff">是否允许通信</td>
</tr>
<tr>
<td>http://www.f2e.me/lab/a.js</p>
<p>http://www.f2e.me/script/b.js</td>
<td>同一域名下不同文件夹</td>
<td>允许</td>
</tr>
<tr>
<td>http://www.f2e.me/a.js</p>
<p>http://www.f2e.me/b.js</td>
<td>同一域名下</td>
<td>允许</td>
</tr>
<tr>
<td>http://www.f2e.me:8000/a.js</p>
<p>http://www.f2e.me/b.js</td>
<td>同一域名，不同端口</td>
<td>不允许</td>
</tr>
<tr>
<td>http://www.f2e.me/a.js</p>
<p>https://www.f2e.me/b.js</td>
<td>同一域名，不同协议</td>
<td>不允许</td>
</tr>
<tr>
<td>http://www.f2e.me/a.js</p>
<p>http://70.32.92.74/b.js</td>
<td>域名和域名对应ip</td>
<td>不允许</td>
</tr>
<tr>
<td>http://www.f2e.me/a.js</p>
<p>http://script.f2e.me/b.js</td>
<td>主域相同，子域不同</td>
<td>不允许</td>
</tr>
<tr>
<td height="42">http://www.space007.com/a.js</p>
<p>http://www.f2e.me/b.js</td>
<td>不同域名</td>
<td>不允许</td>
</tr>
</tbody>
</table>
<p><strong>特别注意两点：</strong></p>
<p>第一，如果是协议和端口造成的跨域问题“前台”是无能为力的，</p>
<p>第二：在跨域问题上，域仅仅是通过URL的首部来识别而不会去尝试判断相同的ip地址对应着两个域或两个域是否在同一个ip上。</p>
<p>接下来简单地总结一下在“前台”一般处理跨域的办法，后台proxy这种方案牵涉到后台的配置，这里就不阐述了,有兴趣的可以看看YAHOO的这篇文章： ﻿</p>
<p><a href="http://developer.yahoo.com/javascript/howto-proxy.html" target="_blank">JavaScript: Use a Web Proxy for Cross-Domain XMLHttpRequest Calls。</a></p>
<h3>1、document.domain+iframe的设置</h3>
<p>对于主域相同而子域不同的例子，可以通过设置document.domain的办法来解决。具体的做法是可以在http://www.f2e.me/a.html和http://script.f2e.me/b.html两个文件中分别加上document.domain = ‘f2e.me’；然后通过a.html文件中创建一个iframe,去控制iframe的contentDocument,这样两个js文件之间就可以“交互”了。当然这种办法只能解决主域相同而二级域名不同的情况，如果你异想天开的把script.f2e.me的domian设为alibaba.com那显然是会报错地！代码如下：</p>
<p><strong>www.f2e.me上的a.html</strong></p>
<pre><code>document.domain = 'f2e.me';
var ifr = document.createElement('iframe');
ifr.src = 'http://script.f2e.me/b.html';
ifr.style.display = 'none';
document.body.appendChild(ifr);
ifr.onload = function(){
  var x = ifr.contentDocument;
  alert(x.getElementsByTagName("h1")[0].childNodes[0].nodeValue);
} </code></pre>
<p><strong>script.f2e.me上的b.html</strong></p>
<pre><code>document.domain = 'f2e.me';</code></pre>
<h3>2、动态创建script</h3>
<p>虽然浏览器默认禁止了跨域访问，但并不禁止在页面中引用其他域的JS文件，并可以自由执行引入的JS文件中的function，根据这一点，可以方便地通过创建script节点的方法来实现完全跨域的通信。具体的做法可以参考yui的 <a href="http://developer.yahoo.com/yui/get/" target="_blank">Get Utility</a></p>
<p>这里判断script节点加载完毕还是蛮有意思的：ie只能通过script的readystatechange属性,Safari 3.x以上支持的是script的load事件，而firefox和oprea则要通过onload来解决。另外这种办法只能传递js类型的数据，不是很方便。以下是部分判断script加载完毕的方法。</p>
<pre><code>
……
// ie支持script的readystatechange属性
// IE supports the readystatechange event for script and css nodes
if (ua.ie) {
  n.onreadystatechange = function() {
  var rs = this.readyState;
  if ("loaded" === rs || "complete" === rs) {
    n.onreadystatechange = null;
    f(id, url);
  }
};

……

// // Safari 3.x supports the load event for script nodes (DOM2)

……

n.addEventListener("load", function() {
  f(id, url);
});

……

// FireFox and Opera support onload (but not DOM2 in FF) handlers for
// script nodes.  Opera, but not FF, supports the onload event for link
// nodes.

} else {
  n.onload = function() {
    f(id, url);
  };
}</code></pre>
<h3>3、利用iframe和location.hash</h3>
<p>这个办法比较绕，但是可以解决完全跨域情况下的脚步置换问题。原理是利用location.hash来进行传值。在url： http://f2e.me#helloword中的‘#helloworld’就是location.hash,改变hash并不会导致页面刷新，所以可以利用hash值来进行数据传递，当然数据容量是有限的。假设域名f2e.me下的文件cs1.html要和space007.com域名下的cs2.html传递信息，cs1.html首先创建自动创建一个隐藏的iframe，iframe的src指向space007.com域名下的cs2.html页面，这时的hash值可以做参数传递用。cs2.html响应请求后再将通过修改cs1.html的hash值来传递数据。（因为ie不允许修改parent.location.hash的值，所以要借助于f2e.me域名下的一个代理iframe）。同时在cs1.html上加一个定时器，隔一段时间来判断location.hash的值有没有变化，一点有变化则获取获取hash值。代码如下：</p>
<p><strong>先是f2e.me下的文件cs1.html文件：</strong></p>
<pre><code>
function startRequest(){
  var ifr = document.createElement('iframe');
  ifr.style.display = 'none';
  ifr.src = 'http://www.space007.com/lab/cscript/cs2.html#paramdo';
  document.body.appendChild(ifr);
}

function checkHash() {
  try {
    var data = location.hash ? location.hash.substring(1):'';
    if(console.log){
      console.log('Now the data is '+data);
    }
  }catch(e){};
}
setInterval(checkHash, 2000);</code></pre>
<p><strong>space007.com域名下的cs2.html:</strong></p>
<pre><code>
(function(){
//模拟一个简单的参数处理操作
switch(location.hash){
  case '#paramdo':
  callBack();
  break;
  case '#paramset':
  //do something……
  break;
}

function callBack(){
  try {
  parent.location.hash = 'somedata';
  } catch (e) {
  //ie的安全机制无法修改parent.location.hash,所以要利用一个中间在space007域下的代理iframe
  var ifrproxy = document.createElement('iframe');
  ifrproxy.style.display = 'none';
  ifrproxy.src = 'http://f2e.me/test/cscript/cs3.html#somedata';
  document.body.appendChild(ifrproxy);
  }
}
})();</code></pre>
<p><strong>f2e.me下的域名cs3.html</strong></p>
<pre><code>//因为parent.parent和自身属于同一个域，所以ie下可以改变其location.hash的值
parent.parent.location.hash = self.location.hash.substring(1);</code></pre>
<p><code> </code></p>
<p>实例请点击  <a href="http://f2e.me/test/cscript/cs1.html" target="_blank">hash实现完全跨域</a><br />
当然这样做也存在很多缺点，诸如数据直接暴露在了url中，数据容量和类型都有限等……</p>
<p><strong>4、利用flash</strong><br />
这是从YUI3的IO组件中看到的办法,具体可见：http://developer.yahoo.com/yui/3/io/<br />
flash这个方案不是很明白，各位自己慢慢琢磨了，呵呵。你可以看在Adobe Developer Connection看到更多的跨域代理文件规范：<br />
<a href="http://www.adobe.com/devnet/articles/crossdomain_policy_file_spec.html" target="_blank">ross-Domain Policy File Specifications.</a><br />
<a href="http://www.adobe.com/devnet/articles/crossdomain_policy_file_spec.html" target="_blank">HTTP Headers Blacklist.</a></p>
<h2  class="related_post_title">您可能还对这些日志感兴趣</h2><ul class="related_post"><li><a href="http://www.qilei.org/201006/lazy-load-about-mall-of-taobao-index-page/" title="一知半解 &#8211; 分析淘宝商城首页的 lazy load 功能">一知半解 &#8211; 分析淘宝商城首页的 lazy load 功能</a></li><li><a href="http://www.qilei.org/200910/javascript-judge-if-chinese/" title="判断输入的字符是否为中文">判断输入的字符是否为中文</a></li><li><a href="http://www.qilei.org/200907/jquery-navbar/" title="乱翻乱教- jQuery 制作N级导航菜单">乱翻乱教- jQuery 制作N级导航菜单</a></li><li><a href="http://www.qilei.org/200906/fastest-way-to-build-an-html-string/" title="乱翻乱教-使用JS输出HTML串最快的方法">乱翻乱教-使用JS输出HTML串最快的方法</a></li><li><a href="http://www.qilei.org/200903/jquery-for-tab-change-effect/" title="菜鸟级: 标签切换效果 &#8211; JQuery实现">菜鸟级: 标签切换效果 &#8211; JQuery实现</a></li></ul>]]></content:encoded>
			<wfw:commentRss>http://www.qilei.org/200910/cross-scripting/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>判断输入的字符是否为中文</title>
		<link>http://www.qilei.org/200910/javascript-judge-if-chinese/</link>
		<comments>http://www.qilei.org/200910/javascript-judge-if-chinese/#comments</comments>
		<pubDate>Wed, 14 Oct 2009 06:27:01 +0000</pubDate>
		<dc:creator>飞鱼</dc:creator>
				<category><![CDATA[慢性创可贴]]></category>
		<category><![CDATA[javascript]]></category>

		<guid isPermaLink="false">http://www.qilei.org/?p=570</guid>
		<description><![CDATA[//判断输入的字符是否为中文 function IsChinese(string) { var str = string; if(str.length!=0){ reg=/^[\u0391-\uFFE5]+$/; if(!reg.test(str)){ alert("对不起，您输入的字符串类型格式不正确!"); //请将“字符串类型”要换成你要验证的那个属性名称！ } } } 您可能还对这些日志感兴趣一知半解 &#8211; 分析淘宝商城首页的 lazy load 功能js跨域问题乱翻乱教- jQuery 制作N级导航菜单乱翻乱教-使用JS输出HTML串最快的方法菜鸟级: 标签切换效果 &#8211; JQuery实现]]></description>
			<content:encoded><![CDATA[<pre><code>//判断输入的字符是否为中文
function IsChinese(string)
{
  var str = string;
  if(str.length!=0){
    reg=/^[\u0391-\uFFE5]+$/;
    if(!reg.test(str)){
        alert("对不起，您输入的字符串类型格式不正确!");
        //请将“字符串类型”要换成你要验证的那个属性名称！
    }
  }
}
</code></pre>
<h2  class="related_post_title">您可能还对这些日志感兴趣</h2><ul class="related_post"><li><a href="http://www.qilei.org/201006/lazy-load-about-mall-of-taobao-index-page/" title="一知半解 &#8211; 分析淘宝商城首页的 lazy load 功能">一知半解 &#8211; 分析淘宝商城首页的 lazy load 功能</a></li><li><a href="http://www.qilei.org/200910/cross-scripting/" title="js跨域问题">js跨域问题</a></li><li><a href="http://www.qilei.org/200907/jquery-navbar/" title="乱翻乱教- jQuery 制作N级导航菜单">乱翻乱教- jQuery 制作N级导航菜单</a></li><li><a href="http://www.qilei.org/200906/fastest-way-to-build-an-html-string/" title="乱翻乱教-使用JS输出HTML串最快的方法">乱翻乱教-使用JS输出HTML串最快的方法</a></li><li><a href="http://www.qilei.org/200903/jquery-for-tab-change-effect/" title="菜鸟级: 标签切换效果 &#8211; JQuery实现">菜鸟级: 标签切换效果 &#8211; JQuery实现</a></li></ul>]]></content:encoded>
			<wfw:commentRss>http://www.qilei.org/200910/javascript-judge-if-chinese/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
