﻿<?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-A Developer's Notebook-随笔分类-AJAX</title><link>http://www.blogjava.net/jarod/category/13250.html</link><description /><language>zh-cn</language><lastBuildDate>Wed, 26 Dec 2007 00:35:16 GMT</lastBuildDate><pubDate>Wed, 26 Dec 2007 00:35:16 GMT</pubDate><ttl>60</ttl><item><title>攻破iframe围城</title><link>http://www.blogjava.net/jarod/archive/2006/08/25/65850.html</link><dc:creator>Jarod</dc:creator><author>Jarod</author><pubDate>Fri, 25 Aug 2006 12:25:00 GMT</pubDate><guid>http://www.blogjava.net/jarod/archive/2006/08/25/65850.html</guid><wfw:comment>http://www.blogjava.net/jarod/comments/65850.html</wfw:comment><comments>http://www.blogjava.net/jarod/archive/2006/08/25/65850.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/jarod/comments/commentRss/65850.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/jarod/services/trackbacks/65850.html</trackback:ping><description><![CDATA[最近因项目需求，需要在JS代码中实现IFrame内外页面的互访问。经过一番试验终于找到方法，以下是试验时用的代码（在IE，Firefox中可正常运行）：<br /><br />main.html<br /><div style="border: 1px solid rgb(204, 204, 204); padding: 4px 5px 4px 4px; background-color: rgb(238, 238, 238); font-size: 13px; width: 98%;"><!--<br><br>Code highlighting produced by Actipro CodeHighlighter (freeware)<br>http://www.CodeHighlighter.com/<br><br>--><span style="color: rgb(0, 128, 128);"> 1</span> <span style="color: rgb(0, 0, 0);">&lt;</span><span style="color: rgb(0, 0, 0);">html</span><span style="color: rgb(0, 0, 0);">&gt;</span><span style="color: rgb(0, 0, 0);"><br /></span><span style="color: rgb(0, 128, 128);"> 2</span> <span style="color: rgb(0, 0, 0);"></span><span style="color: rgb(0, 0, 0);">&lt;</span><span style="color: rgb(0, 0, 0);">head</span><span style="color: rgb(0, 0, 0);">&gt;</span><span style="color: rgb(0, 0, 0);"><br /></span><span style="color: rgb(0, 128, 128);"> 3</span> <span style="color: rgb(0, 0, 0);">    </span><span style="color: rgb(0, 0, 0);">&lt;</span><span style="color: rgb(0, 0, 0);">title</span><span style="color: rgb(0, 0, 0);">&gt;</span><span style="color: rgb(0, 0, 0);">MAIN</span><span style="color: rgb(0, 0, 0);">&lt;/</span><span style="color: rgb(0, 0, 0);">title</span><span style="color: rgb(0, 0, 0);">&gt;</span><span style="color: rgb(0, 0, 0);"><br /></span><span style="color: rgb(0, 128, 128);"> 4</span> <span style="color: rgb(0, 0, 0);">    </span><span style="color: rgb(0, 0, 0);">&lt;</span><span style="color: rgb(0, 0, 0);">script type</span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">text/javascript</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">&gt;</span><span style="color: rgb(0, 0, 0);"><br /></span><span style="color: rgb(0, 128, 128);"> 5</span> <span style="color: rgb(0, 0, 0);"></span><span style="color: rgb(0, 128, 0);">        //</span><span style="color: rgb(0, 128, 0);"> 主页面访问IFrame页面DOM内容</span><span style="color: rgb(0, 128, 0);"><br /></span><span style="color: rgb(0, 128, 128);"> 6</span> <span style="color: rgb(0, 128, 0);"></span><span style="color: rgb(0, 0, 0);">        </span><span style="color: rgb(0, 0, 255);">function</span><span style="color: rgb(0, 0, 0);"> oinit() {<br /></span><span style="color: rgb(0, 128, 128);"> 7</span> <span style="color: rgb(0, 0, 0);">            alert(getIFrameDoc(</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">iframe1</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">).getElementById(</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">idiv</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">).id);<br /></span><span style="color: rgb(0, 128, 128);"> 8</span> <span style="color: rgb(0, 0, 0);">        }<br /></span><span style="color: rgb(0, 128, 128);"> 9</span> <span style="color: rgb(0, 0, 0);">        </span><span style="color: rgb(0, 0, 255);">function</span><span style="color: rgb(0, 0, 0);"> getIFrameDoc(id) {<br /></span><span style="color: rgb(0, 128, 128);">10</span> <span style="color: rgb(0, 0, 0);">            </span><span style="color: rgb(0, 0, 255);">var</span><span style="color: rgb(0, 0, 0);"> iframe </span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);"> document.getElementById(id);<br /></span><span style="color: rgb(0, 128, 128);">11</span> <span style="color: rgb(0, 0, 0);">            </span><span style="color: rgb(0, 0, 255);">var</span><span style="color: rgb(0, 0, 0);"> doc </span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);"> (iframe.contentWindow </span><span style="color: rgb(0, 0, 0);">||</span><span style="color: rgb(0, 0, 0);"> iframe.contentDocument);<br /></span><span style="color: rgb(0, 128, 128);">12</span> <span style="color: rgb(0, 0, 0);">            </span><span style="color: rgb(0, 0, 255);">if</span><span style="color: rgb(0, 0, 0);"> (doc.document) {<br /></span><span style="color: rgb(0, 128, 128);">13</span> <span style="color: rgb(0, 0, 0);">                doc </span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);"> doc.document;<br /></span><span style="color: rgb(0, 128, 128);">14</span> <span style="color: rgb(0, 0, 0);">            }<br /></span><span style="color: rgb(0, 128, 128);">15</span> <span style="color: rgb(0, 0, 0);">            </span><span style="color: rgb(0, 0, 255);">return</span><span style="color: rgb(0, 0, 0);"> doc;<br /></span><span style="color: rgb(0, 128, 128);">16</span> <span style="color: rgb(0, 0, 0);">        }<br /></span><span style="color: rgb(0, 128, 128);">17</span> <span style="color: rgb(0, 0, 0);">    </span><span style="color: rgb(0, 0, 0);">&lt;/</span><span style="color: rgb(0, 0, 0);">script</span><span style="color: rgb(0, 0, 0);">&gt;</span><span style="color: rgb(0, 0, 0);"><br /></span><span style="color: rgb(0, 128, 128);">18</span> <span style="color: rgb(0, 0, 0);"></span><span style="color: rgb(0, 0, 0);">&lt;/</span><span style="color: rgb(0, 0, 0);">head</span><span style="color: rgb(0, 0, 0);">&gt;</span><span style="color: rgb(0, 0, 0);"><br /></span><span style="color: rgb(0, 128, 128);">19</span> <span style="color: rgb(0, 0, 0);"></span><span style="color: rgb(0, 0, 0);">&lt;</span><span style="color: rgb(0, 0, 0);">body onload</span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">oinit()</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">&gt;</span><span style="color: rgb(0, 0, 0);"><br /></span><span style="color: rgb(0, 128, 128);">20</span> <span style="color: rgb(0, 0, 0);">    </span><span style="color: rgb(0, 0, 0);">&lt;</span><span style="color: rgb(0, 0, 0);">div id</span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">odiv</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">&gt;</span><span style="color: rgb(0, 0, 0);"><br /></span><span style="color: rgb(0, 128, 128);">21</span> <span style="color: rgb(0, 0, 0);">        </span><span style="color: rgb(0, 0, 0);">&lt;</span><span style="color: rgb(0, 0, 0);">iframe id</span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">iframe1</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);"> src</span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">iframe.html</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">&gt;&lt;/</span><span style="color: rgb(0, 0, 0);">iframe</span><span style="color: rgb(0, 0, 0);">&gt;</span><span style="color: rgb(0, 0, 0);"><br /></span><span style="color: rgb(0, 128, 128);">22</span> <span style="color: rgb(0, 0, 0);">    </span><span style="color: rgb(0, 0, 0);">&lt;/</span><span style="color: rgb(0, 0, 0);">div</span><span style="color: rgb(0, 0, 0);">&gt;</span><span style="color: rgb(0, 0, 0);"><br /></span><span style="color: rgb(0, 128, 128);">23</span> <span style="color: rgb(0, 0, 0);"></span><span style="color: rgb(0, 0, 0);">&lt;/</span><span style="color: rgb(0, 0, 0);">body</span><span style="color: rgb(0, 0, 0);">&gt;</span><span style="color: rgb(0, 0, 0);"><br /></span><span style="color: rgb(0, 128, 128);">24</span> <span style="color: rgb(0, 0, 0);"></span><span style="color: rgb(0, 0, 0);">&lt;/</span><span style="color: rgb(0, 0, 0);">html</span><span style="color: rgb(0, 0, 0);">&gt;</span></div><br />iframe.html<br /><div style="border: 1px solid rgb(204, 204, 204); padding: 4px 5px 4px 4px; background-color: rgb(238, 238, 238); font-size: 13px; width: 98%;"><!--<br><br>Code highlighting produced by Actipro CodeHighlighter (freeware)<br>http://www.CodeHighlighter.com/<br><br>--><span style="color: rgb(0, 128, 128);"> 1</span> <span style="color: rgb(0, 0, 0);">&lt;</span><span style="color: rgb(0, 0, 0);">html</span><span style="color: rgb(0, 0, 0);">&gt;</span><span style="color: rgb(0, 0, 0);"><br /></span><span style="color: rgb(0, 128, 128);"> 2</span> <span style="color: rgb(0, 0, 0);"></span><span style="color: rgb(0, 0, 0);">&lt;</span><span style="color: rgb(0, 0, 0);">head</span><span style="color: rgb(0, 0, 0);">&gt;</span><span style="color: rgb(0, 0, 0);"><br /></span><span style="color: rgb(0, 128, 128);"> 3</span> <span style="color: rgb(0, 0, 0);">    </span><span style="color: rgb(0, 0, 0);">&lt;</span><span style="color: rgb(0, 0, 0);">title</span><span style="color: rgb(0, 0, 0);">&gt;</span><span style="color: rgb(0, 0, 0);">IFRAME</span><span style="color: rgb(0, 0, 0);">&lt;/</span><span style="color: rgb(0, 0, 0);">title</span><span style="color: rgb(0, 0, 0);">&gt;</span><span style="color: rgb(0, 0, 0);"><br /></span><span style="color: rgb(0, 128, 128);"> 4</span> <span style="color: rgb(0, 0, 0);">    </span><span style="color: rgb(0, 0, 0);">&lt;</span><span style="color: rgb(0, 0, 0);">script type</span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">text/javascript</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">&gt;</span><span style="color: rgb(0, 0, 0);"><br /></span><span style="color: rgb(0, 128, 128);"> 5</span> <span style="color: rgb(0, 0, 0);">        </span><span style="color: rgb(0, 128, 0);">//</span><span style="color: rgb(0, 128, 0);"> IFrame页面访问外层页面DOM内容</span><span style="color: rgb(0, 128, 0);"><br /></span><span style="color: rgb(0, 128, 128);"> 6</span> <span style="color: rgb(0, 128, 0);"></span><span style="color: rgb(0, 0, 0);">        </span><span style="color: rgb(0, 0, 255);">function</span><span style="color: rgb(0, 0, 0);"> iinit() {<br /></span><span style="color: rgb(0, 128, 128);"> 7</span> <span style="color: rgb(0, 0, 0);">            alert(window.parent.document.getElementById(</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">odiv</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">).id);<br /></span><span style="color: rgb(0, 128, 128);"> 8</span> <span style="color: rgb(0, 0, 0);">        }<br /></span><span style="color: rgb(0, 128, 128);"> 9</span> <span style="color: rgb(0, 0, 0);">    </span><span style="color: rgb(0, 0, 0);">&lt;/</span><span style="color: rgb(0, 0, 0);">script</span><span style="color: rgb(0, 0, 0);">&gt;</span><span style="color: rgb(0, 0, 0);"><br /></span><span style="color: rgb(0, 128, 128);">10</span> <span style="color: rgb(0, 0, 0);"></span><span style="color: rgb(0, 0, 0);">&lt;/</span><span style="color: rgb(0, 0, 0);">head</span><span style="color: rgb(0, 0, 0);">&gt;</span><span style="color: rgb(0, 0, 0);"><br /></span><span style="color: rgb(0, 128, 128);">11</span> <span style="color: rgb(0, 0, 0);"></span><span style="color: rgb(0, 0, 0);">&lt;</span><span style="color: rgb(0, 0, 0);">body onload</span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">iinit()</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">&gt;</span><span style="color: rgb(0, 0, 0);"><br /></span><span style="color: rgb(0, 128, 128);">12</span> <span style="color: rgb(0, 0, 0);">    </span><span style="color: rgb(0, 0, 0);">&lt;</span><span style="color: rgb(0, 0, 0);">div id</span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">idiv</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">&gt;</span><span style="color: rgb(0, 0, 0);"><br /></span><span style="color: rgb(0, 128, 128);">13</span> <span style="color: rgb(0, 0, 0);"></span><span style="color: rgb(0, 0, 0);">&lt;/</span><span style="color: rgb(0, 0, 0);">body</span><span style="color: rgb(0, 0, 0);">&gt;</span><span style="color: rgb(0, 0, 0);"><br /></span><span style="color: rgb(0, 128, 128);">14</span> <span style="color: rgb(0, 0, 0);"></span><span style="color: rgb(0, 0, 0);">&lt;/</span><span style="color: rgb(0, 0, 0);">html</span><span style="color: rgb(0, 0, 0);">&gt;</span></div><br /><br /><br /><img src ="http://www.blogjava.net/jarod/aggbug/65850.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/jarod/" target="_blank">Jarod</a> 2006-08-25 20:25 <a href="http://www.blogjava.net/jarod/archive/2006/08/25/65850.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>JS中的网址转义</title><link>http://www.blogjava.net/jarod/archive/2006/08/02/61392.html</link><dc:creator>Jarod</dc:creator><author>Jarod</author><pubDate>Wed, 02 Aug 2006 13:03:00 GMT</pubDate><guid>http://www.blogjava.net/jarod/archive/2006/08/02/61392.html</guid><wfw:comment>http://www.blogjava.net/jarod/comments/61392.html</wfw:comment><comments>http://www.blogjava.net/jarod/archive/2006/08/02/61392.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/jarod/comments/commentRss/61392.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/jarod/services/trackbacks/61392.html</trackback:ping><description><![CDATA[JS中对网址进行转义有三个方法，分别是escape(), encodeURI(), encodeURIComponent()<br />这三个方法都是把网址中的非ASCII字符转为%XX的形式<br /><br />三个方法的区别是分别有些字符是不做转义的：<br />escape()              - <code class="chars">@*/+<br />encodeURI()           - </code><code class="chars">!@#$&amp;*()=:/;?+'<br />encodeURIComponent()  - </code><code class="chars">!*()'</code><img src ="http://www.blogjava.net/jarod/aggbug/61392.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/jarod/" target="_blank">Jarod</a> 2006-08-02 21:03 <a href="http://www.blogjava.net/jarod/archive/2006/08/02/61392.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>AJAX开发——IE怪异之墙</title><link>http://www.blogjava.net/jarod/archive/2006/07/19/59084.html</link><dc:creator>Jarod</dc:creator><author>Jarod</author><pubDate>Wed, 19 Jul 2006 14:35:00 GMT</pubDate><guid>http://www.blogjava.net/jarod/archive/2006/07/19/59084.html</guid><wfw:comment>http://www.blogjava.net/jarod/comments/59084.html</wfw:comment><comments>http://www.blogjava.net/jarod/archive/2006/07/19/59084.html#Feedback</comments><slash:comments>4</slash:comments><wfw:commentRss>http://www.blogjava.net/jarod/comments/commentRss/59084.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/jarod/services/trackbacks/59084.html</trackback:ping><description><![CDATA[<ul>
    <li>XmlHttpRequest<br />
    <font size="2">描述：当使用get方法获取内容时，IE会直接从缓存取内容，就算服务器有更新也一样<br />
    解决：1)不管3721一率采用post方法；2）在URL加上随机参数值；3）在HTTP头加上If-Modified-Since，设成过去时间值。</font><br />
    <br />
    </li>
    <li>table, tr标签的innerHTML只读<br />
    <font size="2">描述：在FF中可写，但在IE中级table,tr的innerHTML赋值会出未知运行时错误<br />
    解决：1)避而不用，嵌套多一层div；2)听说可以为IE的innerHTML扩展setter;</font><br />
    <br />
    </li>
    <li>JSON构造中的小逗号<br />
    <font size="2">描述：var json = {a:10,b:10,c:10,}在FF中没事，在IE中出错<br />
    解决：。。。</font><br />
    <br />
    </li>
    <li>
    select的option<br />
    <font size="2">描述：firefox中可以通过option的disabled属性使选项无效，可恶的IE竟然无视这个属性。<br />
    解决：无</font><br />
    <br />
    </li>
    <li>
    img的onload（<a href="http://msdn2.microsoft.com/en-us/library/ms536942.aspx">参考</a>）<br />
    在IE要绑定onload到img中，只能在html中做，通过js做绑定是不行的<br />
    只能这样写<br />
    &lt;script&gt; function img_onload() {}&lt;/script&gt;<br />
    &lt;img onload="img_onload"/&gt;<br />
    <br />
    </li>
</ul>
<br />
<br />
<img src ="http://www.blogjava.net/jarod/aggbug/59084.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/jarod/" target="_blank">Jarod</a> 2006-07-19 22:35 <a href="http://www.blogjava.net/jarod/archive/2006/07/19/59084.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item></channel></rss>