<?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>刘钢的博客 - 我是UED &#187; iframe加载</title>
	<atom:link href="http://www.iamued.com/tag/iframe%e5%8a%a0%e8%bd%bd/feed" rel="self" type="application/rss+xml" />
	<link>http://www.iamued.com</link>
	<description>http://www.IamUED.com</description>
	<lastBuildDate>Wed, 18 Jan 2012 02:51:35 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2.1</generator>
		<item>
		<title>判断 iframe 是否加载完成的完美方法</title>
		<link>http://www.iamued.com/qianduan/1486.html</link>
		<comments>http://www.iamued.com/qianduan/1486.html#comments</comments>
		<pubDate>Tue, 22 Jun 2010 02:51:57 +0000</pubDate>
		<dc:creator>RichieLiu</dc:creator>
				<category><![CDATA[JavaScript脚本]]></category>
		<category><![CDATA[前端开发]]></category>
		<category><![CDATA[iframe加载]]></category>
		<category><![CDATA[前端]]></category>

		<guid isPermaLink="false">http://www.iamued.com/?p=1486</guid>
		<description><![CDATA[今天正好需要判断iframe加载完成 正好找到怿飞同学的这篇文章 方法很完美 最近， Nicholas C. Zakas 文章《Iframes, onload, and document.domain》的评论中 Christopher 提供了一个新的判断方法（很完美）： 几点补充说明： IE 支持 iframe 的 onload 事件，不过是隐形的，需要通过 attachEvent 来注册。 第二种方法比第一种方法更完美，因为 readystatechange 事件相对于 load 事件有一些潜在的问题。]]></description>
			<content:encoded><![CDATA[<p>今天正好需要判断iframe加载完成 正好找到<a rel="about" href="http://www.planabc.net/about/">怿飞</a>同学的这篇文章 方法很完美</p>
<pre class="brush: jscript; title: ; notranslate">
var iframe = document.createElement(&quot;iframe&quot;);
iframe.src = &quot;http://www.planabc.net&quot;;

if (!/*@cc_on!@*/0) { //if not IE
    iframe.onload = function(){
        alert(&quot;Local iframe is now loaded.&quot;);
    };
} else {
    iframe.onreadystatechange = function(){
        if (iframe.readyState == &quot;complete&quot;){
            alert(&quot;Local iframe is now loaded.&quot;);
        }
    };
}

document.body.appendChild(iframe);
</pre>
<p>最近， <a title="NCZOnline" href="http://www.nczonline.net/" target="_blank">Nicholas C. Zakas</a> 文章<a title="Iframes, onload, and document.domain" href="http://www.nczonline.net/blog/2009/09/15/iframes-onload-and-documentdomain/" target="_blank">《Iframes, onload, and document.domain》</a>的评论中 Christopher 提供了一个新的判断方法（很完美）：</p>
<pre class="brush: jscript; title: ; notranslate">
var iframe = document.createElement(&quot;iframe&quot;);
iframe.src = &quot;http://www.planabc.net&quot;;

if (iframe.attachEvent){
    iframe.attachEvent(&quot;onload&quot;, function(){
        alert(&quot;Local iframe is now loaded.&quot;);
    });
} else {
    iframe.onload = function(){
        alert(&quot;Local iframe is now loaded.&quot;);
    };
}

document.body.appendChild(iframe);
</pre>
<p>几点补充说明：</p>
<ol>
<li><a title="onload Event (BODY, FRAME, FRAMESET, ...)&lt;br /&gt;" href="http://msdn.microsoft.com/en-us/library/cc197055(VS.85).aspx" target="_blank">IE 支持 iframe 的 onload 事件</a>，不过是隐形的，需要通过 attachEvent 来注册。</li>
<li>第二种方法比第一种方法更完美，因为 readystatechange 事件相对于 load 事件有一些潜在的问题。</li>
</ol>
]]></content:encoded>
			<wfw:commentRss>http://www.iamued.com/qianduan/1486.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

