<?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>最优良人 &#187; iframe</title>
	<atom:link href="http://www.zui88.com/view-tag/iframe/feed" rel="self" type="application/rss+xml" />
	<link>http://www.zui88.com/blog</link>
	<description>中山php&#124;最优网络</description>
	<lastBuildDate>Mon, 13 May 2013 04:56:43 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.1.4</generator>
		<item>
		<title>让框架iframe高度自适应，可自动撑开高度</title>
		<link>http://www.zui88.com/blog/view-236.html</link>
		<comments>http://www.zui88.com/blog/view-236.html#comments</comments>
		<pubDate>Sun, 28 Aug 2011 07:46:30 +0000</pubDate>
		<dc:creator>lin</dc:creator>
				<category><![CDATA[网站前端]]></category>
		<category><![CDATA[iframe]]></category>
		<category><![CDATA[js]]></category>

		<guid isPermaLink="false">http://www.zui88.com/blog/?p=236</guid>
		<description><![CDATA[默认iframe框架是不能撑开高度的，如果需要让框架高度自适应需要用js实现 js代码： var adjustIframe = function (id) { var iframe = document.getElementById(id) var idoc = iframe.contentWindow &#038;&#038; iframe.contentWindow.document &#124;&#124; iframe.contentDocument; var callback = function () { var iheight = Math.max(idoc.body.scrollHeight, idoc.documentElement.scrollHeight); //取得其高 iframe.style.height = iheight + "px"; } if (iframe.attachEvent) { iframe.attachEvent("onload", callback); } else { iframe.onload = callback } } HTML代码如下所示： 使用代码： window.onload = [...]]]></description>
			<content:encoded><![CDATA[<p>默认iframe框架是不能撑开高度的，如果需要让框架高度自适应需要用js实现<br />
js代码：<br />
var adjustIframe = function (id) {<br />
    var iframe = document.getElementById(id)<br />
    var idoc = iframe.contentWindow &#038;&#038; iframe.contentWindow.document || iframe.contentDocument;<br />
    var callback = function () {<br />
        var iheight = Math.max(idoc.body.scrollHeight, idoc.documentElement.scrollHeight); //取得其高<br />
        iframe.style.height = iheight + "px";<br />
    }<br />
    if (iframe.attachEvent) {<br />
        iframe.attachEvent("onload", callback);<br />
    } else {<br />
        iframe.onload = callback<br />
    }<br />
}<br />
HTML代码如下所示：<br />
<iframe id="js_sub_web" width="80%" frameborder="0" scrolling="no" allowTransparency="true" src="http://www.zui88.com/"><br />
</iframe>使用代码：</p>
<p>window.onload = function(){<br />
     adjustIframe("js_sub_web");<br />
}</p>
]]></content:encoded>
			<wfw:commentRss>http://www.zui88.com/blog/view-236.html/feed</wfw:commentRss>
		<slash:comments>215</slash:comments>
		</item>
	</channel>
</rss>
