<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	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/"
		>
<channel>
	<title>评论：使用 window.name 解决跨域问题</title>
	<atom:link href="http://www.planabc.net/2008/09/01/window_name_transport/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.planabc.net/2008/09/01/window_name_transport/</link>
	<description>落草为根—专注前端技术&#38;&#38;关注用户体验</description>
	<lastBuildDate>Tue, 09 Mar 2010 07:28:24 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
		<item>
		<title>来自：forbe</title>
		<link>http://www.planabc.net/2008/09/01/window_name_transport/comment-page-1/#comment-6684</link>
		<dc:creator>forbe</dc:creator>
		<pubDate>Fri, 05 Mar 2010 05:24:26 +0000</pubDate>
		<guid isPermaLink="false">http://www.planabc.net/?p=90#comment-6684</guid>
		<description>同时: 这不是一种完美的方式，
１.要求服务端返回一段html代码。同时必须有js代码指定window.name=&quot;返回的值&quot;; 可悲的是这值必须是text.
２.加上我所说的FF的IFRAME的缓存问题。
３.同时，在IE下会有滴滴声。用户体验不好.
所以这个方案是失败的. 还是用script注入方式好一点.</description>
		<content:encoded><![CDATA[<p>同时: 这不是一种完美的方式，<br />
１.要求服务端返回一段html代码。同时必须有js代码指定window.name=&#8221;返回的值&#8221;; 可悲的是这值必须是text.<br />
２.加上我所说的FF的IFRAME的缓存问题。<br />
３.同时，在IE下会有滴滴声。用户体验不好.<br />
所以这个方案是失败的. 还是用script注入方式好一点.</p>
]]></content:encoded>
	</item>
	<item>
		<title>来自：forbe</title>
		<link>http://www.planabc.net/2008/09/01/window_name_transport/comment-page-1/#comment-6683</link>
		<dc:creator>forbe</dc:creator>
		<pubDate>Fri, 05 Mar 2010 05:20:56 +0000</pubDate>
		<guid isPermaLink="false">http://www.planabc.net/?p=90#comment-6683</guid>
		<description>这个的确是个方案。但是问题在于FF对IFRAME的缓存导致F5之后。是不会请求到数据的。除非CTRL+F5
所以这个显得鸡肋了..
上代码如下

/* -&gt; 此实现在FF下按F5有代码不可控制的 IFRAME缓存问题, 废除.*/
	 function XHR(sUrl, fnCallBack) {
		fnCallBack = fnCallBack &#124;&#124; new Function();
		sUrl += (sUrl.indexOf(&#039;?&#039;) &gt; 0 ? &#039;&amp;&#039;: &#039;?&#039;) + &#039;WINDOWNAME=true&#039;;
		var frame = document.createElement(&#039;iframe&#039;),
		state = 0;
		document.body.appendChild(frame).style.display = &#039;none&#039;;
		frame.readyState ? frame.attachEvent(&quot;onload&quot;, done) : frame.onload = done;
		frame.src = sUrl;
		function getData() {
			try {
				fnCallBack(frame.contentWindow.name);
				frame.contentWindow.document.write(&#039;&#039;);
				frame.contentWindow.close();
				document.body.removeChild(frame);

			} catch(e) {
				fnCallBack(&#039;{code:999}&#039;)

			}

		}
		function done() {
			state == 1 ? getData() : (state = 1, frame.contentWindow.location = &quot;about:blank&quot;)
		}

	}</description>
		<content:encoded><![CDATA[<p>这个的确是个方案。但是问题在于FF对IFRAME的缓存导致F5之后。是不会请求到数据的。除非CTRL+F5<br />
所以这个显得鸡肋了..<br />
上代码如下</p>
<p>/* -&gt; 此实现在FF下按F5有代码不可控制的 IFRAME缓存问题, 废除.*/<br />
	 function XHR(sUrl, fnCallBack) {<br />
		fnCallBack = fnCallBack || new Function();<br />
		sUrl += (sUrl.indexOf(&#8216;?&#8217;) &gt; 0 ? &#8216;&amp;&#8217;: &#8216;?&#8217;) + &#8216;WINDOWNAME=true&#8217;;<br />
		var frame = document.createElement(&#8216;iframe&#8217;),<br />
		state = 0;<br />
		document.body.appendChild(frame).style.display = &#8216;none&#8217;;<br />
		frame.readyState ? frame.attachEvent(&#8220;onload&#8221;, done) : frame.onload = done;<br />
		frame.src = sUrl;<br />
		function getData() {<br />
			try {<br />
				fnCallBack(frame.contentWindow.name);<br />
				frame.contentWindow.document.write(&#8221;);<br />
				frame.contentWindow.close();<br />
				document.body.removeChild(frame);</p>
<p>			} catch(e) {<br />
				fnCallBack(&#8216;{code:999}&#8217;)</p>
<p>			}</p>
<p>		}<br />
		function done() {<br />
			state == 1 ? getData() : (state = 1, frame.contentWindow.location = &#8220;about:blank&#8221;)<br />
		}</p>
<p>	}</p>
]]></content:encoded>
	</item>
	<item>
		<title>来自：kim wang</title>
		<link>http://www.planabc.net/2008/09/01/window_name_transport/comment-page-1/#comment-5882</link>
		<dc:creator>kim wang</dc:creator>
		<pubDate>Thu, 07 Jan 2010 07:14:27 +0000</pubDate>
		<guid isPermaLink="false">http://www.planabc.net/?p=90#comment-5882</guid>
		<description>这种方案在ie和ff下都会显示请求进度……</description>
		<content:encoded><![CDATA[<p>这种方案在ie和ff下都会显示请求进度……</p>
]]></content:encoded>
	</item>
	<item>
		<title>来自：nttdocomo</title>
		<link>http://www.planabc.net/2008/09/01/window_name_transport/comment-page-1/#comment-5542</link>
		<dc:creator>nttdocomo</dc:creator>
		<pubDate>Sun, 13 Dec 2009 02:42:08 +0000</pubDate>
		<guid isPermaLink="false">http://www.planabc.net/?p=90#comment-5542</guid>
		<description>这跟用script标签来实现跨域数据传输有什么不一样啊？</description>
		<content:encoded><![CDATA[<p>这跟用script标签来实现跨域数据传输有什么不一样啊？</p>
]]></content:encoded>
	</item>
	<item>
		<title>来自：天堂左我往右</title>
		<link>http://www.planabc.net/2008/09/01/window_name_transport/comment-page-1/#comment-3435</link>
		<dc:creator>天堂左我往右</dc:creator>
		<pubDate>Sat, 23 May 2009 07:57:45 +0000</pubDate>
		<guid isPermaLink="false">http://www.planabc.net/?p=90#comment-3435</guid>
		<description>怿飞改天写篇FIM 和 Subspace 的文章吧...</description>
		<content:encoded><![CDATA[<p>怿飞改天写篇FIM 和 Subspace 的文章吧&#8230;</p>
]]></content:encoded>
	</item>
	<item>
		<title>来自：阿里巴巴（软件）开发者博客 &#187; Blog Archive &#187; 实战window.name解决跨域问题</title>
		<link>http://www.planabc.net/2008/09/01/window_name_transport/comment-page-1/#comment-2343</link>
		<dc:creator>阿里巴巴（软件）开发者博客 &#187; Blog Archive &#187; 实战window.name解决跨域问题</dc:creator>
		<pubDate>Mon, 22 Dec 2008 08:12:15 +0000</pubDate>
		<guid isPermaLink="false">http://www.planabc.net/?p=90#comment-2343</guid>
		<description>[...] 之前在怿飞的博客上看到一篇关于window.name解决跨域问题的文章，给web前端的跨域问题提供了另外一种选择，但是里面的例子写得不是很简洁，这里从一个简单的例子，来说明该机制的应用。具体的机制说明可以参考http://www.planabc.net/2008/09/01/window_name_transport/ [...]</description>
		<content:encoded><![CDATA[<p>[...] 之前在怿飞的博客上看到一篇关于window.name解决跨域问题的文章，给web前端的跨域问题提供了另外一种选择，但是里面的例子写得不是很简洁，这里从一个简单的例子，来说明该机制的应用。具体的机制说明可以参考http://www.planabc.net/2008/09/01/window_name_transport/ [...]</p>
]]></content:encoded>
	</item>
	<item>
		<title>来自：脚本爱好者</title>
		<link>http://www.planabc.net/2008/09/01/window_name_transport/comment-page-1/#comment-2306</link>
		<dc:creator>脚本爱好者</dc:creator>
		<pubDate>Mon, 15 Dec 2008 03:23:56 +0000</pubDate>
		<guid isPermaLink="false">http://www.planabc.net/?p=90#comment-2306</guid>
		<description>使用window.name还是需要不同域的 service去配合，既然这样，用script方式加载，然后直接返回json数据不是更好？</description>
		<content:encoded><![CDATA[<p>使用window.name还是需要不同域的 service去配合，既然这样，用script方式加载，然后直接返回json数据不是更好？</p>
]]></content:encoded>
	</item>
	<item>
		<title>来自：jay</title>
		<link>http://www.planabc.net/2008/09/01/window_name_transport/comment-page-1/#comment-2259</link>
		<dc:creator>jay</dc:creator>
		<pubDate>Sat, 06 Dec 2008 19:31:12 +0000</pubDate>
		<guid isPermaLink="false">http://www.planabc.net/?p=90#comment-2259</guid>
		<description>safari下用js改变location.hash的时候页面会刷新，请教大虾有什么绝招不</description>
		<content:encoded><![CDATA[<p>safari下用js改变location.hash的时候页面会刷新，请教大虾有什么绝招不</p>
]]></content:encoded>
	</item>
	<item>
		<title>来自：lenel</title>
		<link>http://www.planabc.net/2008/09/01/window_name_transport/comment-page-1/#comment-2023</link>
		<dc:creator>lenel</dc:creator>
		<pubDate>Thu, 13 Nov 2008 08:06:32 +0000</pubDate>
		<guid isPermaLink="false">http://www.planabc.net/?p=90#comment-2023</guid>
		<description>果然够巧,只是有个问题在FireFox会增加history的记录.
如果只有data域在控制下,提供给多个request页面服务对request域不够友好.
之前通过互传Hash值的简单跨域通信方式也会遇到扰乱FireFox浏览器history的问题.
不知道文中提到的FIM或者Subspace是否可以避免?
如果data域在控制下,并对外提供服务,是否可以通过参数接收request域的proxy页面地址,在data域页面执行后自行导入proxy页.这是不是18楼那张图表达的意思?
能不能也比较一下这种实现方式和on-demand script方案的各自特点和适合的应用场景?</description>
		<content:encoded><![CDATA[<p>果然够巧,只是有个问题在FireFox会增加history的记录.<br />
如果只有data域在控制下,提供给多个request页面服务对request域不够友好.<br />
之前通过互传Hash值的简单跨域通信方式也会遇到扰乱FireFox浏览器history的问题.<br />
不知道文中提到的FIM或者Subspace是否可以避免?<br />
如果data域在控制下,并对外提供服务,是否可以通过参数接收request域的proxy页面地址,在data域页面执行后自行导入proxy页.这是不是18楼那张图表达的意思?<br />
能不能也比较一下这种实现方式和on-demand script方案的各自特点和适合的应用场景?</p>
]]></content:encoded>
	</item>
	<item>
		<title>来自：tencent coolery</title>
		<link>http://www.planabc.net/2008/09/01/window_name_transport/comment-page-1/#comment-1974</link>
		<dc:creator>tencent coolery</dc:creator>
		<pubDate>Tue, 11 Nov 2008 06:11:51 +0000</pubDate>
		<guid isPermaLink="false">http://www.planabc.net/?p=90#comment-1974</guid>
		<description>这里利用了url来实现数据的转移 蛮有意思</description>
		<content:encoded><![CDATA[<p>这里利用了url来实现数据的转移 蛮有意思</p>
]]></content:encoded>
	</item>
	<item>
		<title>来自：我爱看电影网</title>
		<link>http://www.planabc.net/2008/09/01/window_name_transport/comment-page-1/#comment-1864</link>
		<dc:creator>我爱看电影网</dc:creator>
		<pubDate>Sat, 01 Nov 2008 16:10:40 +0000</pubDate>
		<guid isPermaLink="false">http://www.planabc.net/?p=90#comment-1864</guid>
		<description>貌似可以实现对多站用户的整合。。。</description>
		<content:encoded><![CDATA[<p>貌似可以实现对多站用户的整合。。。</p>
]]></content:encoded>
	</item>
	<item>
		<title>来自：陈成的博客 &#8212; iframe全跨域高度自适应解决方案</title>
		<link>http://www.planabc.net/2008/09/01/window_name_transport/comment-page-1/#comment-1814</link>
		<dc:creator>陈成的博客 &#8212; iframe全跨域高度自适应解决方案</dc:creator>
		<pubDate>Tue, 28 Oct 2008 07:03:26 +0000</pubDate>
		<guid isPermaLink="false">http://www.planabc.net/?p=90#comment-1814</guid>
		<description>[...] 使用window.name解决跨域问题 [...]</description>
		<content:encoded><![CDATA[<p>[...] 使用window.name解决跨域问题 [...]</p>
]]></content:encoded>
	</item>
	<item>
		<title>来自：welefen</title>
		<link>http://www.planabc.net/2008/09/01/window_name_transport/comment-page-1/#comment-1713</link>
		<dc:creator>welefen</dc:creator>
		<pubDate>Fri, 10 Oct 2008 06:32:45 +0000</pubDate>
		<guid isPermaLink="false">http://www.planabc.net/?p=90#comment-1713</guid>
		<description>window.name还可以用来缓存JS、CSS等静态文件</description>
		<content:encoded><![CDATA[<p>window.name还可以用来缓存JS、CSS等静态文件</p>
]]></content:encoded>
	</item>
	<item>
		<title>来自：he</title>
		<link>http://www.planabc.net/2008/09/01/window_name_transport/comment-page-1/#comment-1697</link>
		<dc:creator>he</dc:creator>
		<pubDate>Tue, 07 Oct 2008 09:02:41 +0000</pubDate>
		<guid isPermaLink="false">http://www.planabc.net/?p=90#comment-1697</guid>
		<description>@战栗 frame.onload 在ie下好像有问题, 但是有替代的解决办法:
http://blog.guitarbean.com/2008/08/iframe-onload-event-monitoring.html</description>
		<content:encoded><![CDATA[<p>@战栗 frame.onload 在ie下好像有问题, 但是有替代的解决办法:<br />
<a href="http://blog.guitarbean.com/2008/08/iframe-onload-event-monitoring.html" rel="nofollow">http://blog.guitarbean.com/2008/08/iframe-onload-event-monitoring.html</a></p>
]]></content:encoded>
	</item>
	<item>
		<title>来自：怿飞</title>
		<link>http://www.planabc.net/2008/09/01/window_name_transport/comment-page-1/#comment-1621</link>
		<dc:creator>怿飞</dc:creator>
		<pubDate>Sat, 27 Sep 2008 14:56:02 +0000</pubDate>
		<guid isPermaLink="false">http://www.planabc.net/?p=90#comment-1621</guid>
		<description>@战栗 对于跨域数据之间完全互通，我还是推荐你使用 Julien Lecomte 提出的跨域方式。

&lt;img src=&quot;http://www.julienlecomte.net/blogfiles/cross-frame/diagram.png&quot; alt=&quot;跨域&quot; /&gt;</description>
		<content:encoded><![CDATA[<p>@战栗 对于跨域数据之间完全互通，我还是推荐你使用 Julien Lecomte 提出的跨域方式。</p>
<p><img src="http://www.julienlecomte.net/blogfiles/cross-frame/diagram.png" alt="跨域" /></p>
]]></content:encoded>
	</item>
	<item>
		<title>来自：怿飞</title>
		<link>http://www.planabc.net/2008/09/01/window_name_transport/comment-page-1/#comment-1620</link>
		<dc:creator>怿飞</dc:creator>
		<pubDate>Sat, 27 Sep 2008 14:50:39 +0000</pubDate>
		<guid isPermaLink="false">http://www.planabc.net/?p=90#comment-1620</guid>
		<description>@战栗 所有的A级浏览器均测试过，都可以的</description>
		<content:encoded><![CDATA[<p>@战栗 所有的A级浏览器均测试过，都可以的</p>
]]></content:encoded>
	</item>
	<item>
		<title>来自：战栗</title>
		<link>http://www.planabc.net/2008/09/01/window_name_transport/comment-page-1/#comment-1618</link>
		<dc:creator>战栗</dc:creator>
		<pubDate>Sat, 27 Sep 2008 14:07:15 +0000</pubDate>
		<guid isPermaLink="false">http://www.planabc.net/?p=90#comment-1618</guid>
		<description>firefox下面可以，ie下面不行
    dataRequest = {
        _doc: document,
        cfg: {
            proxyUrl: &#039;http://localhost:8080/jsp-examples/proxy.html&#039;
        }
    };

    dataRequest.send = function(sUrl, fnCallBack){
		//alert(&quot;send&quot;);
        if(!sUrl &#124;&#124; typeof sUrl !== &#039;string&#039;){
            return;
        }

        sUrl += (sUrl.indexOf(&#039;?&#039;) &gt; 0 ? &#039;&amp;&#039; : &#039;?&#039;) + &#039;windowname=true&#039;;

        var frame = this._doc.createElement(&#039;iframe&#039;), state = 0, self = this;
        this._doc.body.appendChild(frame);
        frame.style.display = &#039;none&#039;;

        var clear = function(){
            try{
                frame.contentWindow.document.write(&#039;&#039;);
                frame.contentWindow.close();
                self._doc.body.removeChild(frame);
            }catch(e){}
        };

        var getData = function(){
            try{
                var da = frame.contentWindow.name;
            }catch(e){}
            clear();
            if(fnCallBack &amp;&amp; typeof fnCallBack === &#039;function&#039;){
                fnCallBack(da);
            }
        };


        function frameLoad(){
			//alert(&quot;onLoad&quot;);
            if(state === 1){
                alert(&quot;state == 1&quot;);
                getData();
            } else if(state === 0){
                state = 1;
				//alert(&quot;state == 0&quot;);
                frame.contentWindow.location = &quot;http://localhost:8080/jsp-examples/proxy.html&quot;;
            }
        };
        frame.onload  = frameLoad;

        frame.src = sUrl;
    };


dataRequest.send(&#039;http://localhost:9080/domain/test.html&#039;,function(data){
 alert(data);
});</description>
		<content:encoded><![CDATA[<p>firefox下面可以，ie下面不行<br />
    dataRequest = {<br />
        _doc: document,<br />
        cfg: {<br />
            proxyUrl: &#8216;http://localhost:8080/jsp-examples/proxy.html&#8217;<br />
        }<br />
    };</p>
<p>    dataRequest.send = function(sUrl, fnCallBack){<br />
		//alert(&#8220;send&#8221;);<br />
        if(!sUrl || typeof sUrl !== &#8217;string&#8217;){<br />
            return;<br />
        }</p>
<p>        sUrl += (sUrl.indexOf(&#8216;?&#8217;) &gt; 0 ? &#8216;&amp;&#8217; : &#8216;?&#8217;) + &#8216;windowname=true&#8217;;</p>
<p>        var frame = this._doc.createElement(&#8216;iframe&#8217;), state = 0, self = this;<br />
        this._doc.body.appendChild(frame);<br />
        frame.style.display = &#8216;none&#8217;;</p>
<p>        var clear = function(){<br />
            try{<br />
                frame.contentWindow.document.write(&#8221;);<br />
                frame.contentWindow.close();<br />
                self._doc.body.removeChild(frame);<br />
            }catch(e){}<br />
        };</p>
<p>        var getData = function(){<br />
            try{<br />
                var da = frame.contentWindow.name;<br />
            }catch(e){}<br />
            clear();<br />
            if(fnCallBack &amp;&amp; typeof fnCallBack === &#8216;function&#8217;){<br />
                fnCallBack(da);<br />
            }<br />
        };</p>
<p>        function frameLoad(){<br />
			//alert(&#8220;onLoad&#8221;);<br />
            if(state === 1){<br />
                alert(&#8220;state == 1&#8243;);<br />
                getData();<br />
            } else if(state === 0){<br />
                state = 1;<br />
				//alert(&#8220;state == 0&#8243;);<br />
                frame.contentWindow.location = &#8220;http://localhost:8080/jsp-examples/proxy.html&#8221;;<br />
            }<br />
        };<br />
        frame.onload  = frameLoad;</p>
<p>        frame.src = sUrl;<br />
    };</p>
<p>dataRequest.send(&#8216;http://localhost:9080/domain/test.html&#8217;,function(data){<br />
 alert(data);<br />
});</p>
]]></content:encoded>
	</item>
	<item>
		<title>来自：战栗</title>
		<link>http://www.planabc.net/2008/09/01/window_name_transport/comment-page-1/#comment-1616</link>
		<dc:creator>战栗</dc:creator>
		<pubDate>Sat, 27 Sep 2008 13:17:45 +0000</pubDate>
		<guid isPermaLink="false">http://www.planabc.net/?p=90#comment-1616</guid>
		<description>没有看出这种方式与动态脚本相比有什么好处。
这种方式也是只能解决get方式的请求，post请求并没有解决啊！</description>
		<content:encoded><![CDATA[<p>没有看出这种方式与动态脚本相比有什么好处。<br />
这种方式也是只能解决get方式的请求，post请求并没有解决啊！</p>
]]></content:encoded>
	</item>
	<item>
		<title>来自：qq空间</title>
		<link>http://www.planabc.net/2008/09/01/window_name_transport/comment-page-1/#comment-1540</link>
		<dc:creator>qq空间</dc:creator>
		<pubDate>Mon, 15 Sep 2008 04:09:57 +0000</pubDate>
		<guid isPermaLink="false">http://www.planabc.net/?p=90#comment-1540</guid>
		<description>没有服务，不用YUI</description>
		<content:encoded><![CDATA[<p>没有服务，不用YUI</p>
]]></content:encoded>
	</item>
	<item>
		<title>来自：哉崽</title>
		<link>http://www.planabc.net/2008/09/01/window_name_transport/comment-page-1/#comment-1446</link>
		<dc:creator>哉崽</dc:creator>
		<pubDate>Thu, 04 Sep 2008 07:16:26 +0000</pubDate>
		<guid isPermaLink="false">http://www.planabc.net/?p=90#comment-1446</guid>
		<description>问题解决啦，
我犯了个低级错误，把proxyUrl指到数据源的域下了，晕啊

另外，如果不在web服务环境下，直接本地建个目录测试，确实会发生一些有趣的问题，就像我第一个回帖描述的</description>
		<content:encoded><![CDATA[<p>问题解决啦，<br />
我犯了个低级错误，把proxyUrl指到数据源的域下了，晕啊</p>
<p>另外，如果不在web服务环境下，直接本地建个目录测试，确实会发生一些有趣的问题，就像我第一个回帖描述的</p>
]]></content:encoded>
	</item>
</channel>
</rss>
