Posts Tagged ‘iframe’

用于解决iframe自适应高度

Posted in 默认分类 on 六月 18th, 2009 by admin – 评论关闭
function reinitIframe(){
	var iframe = document.getElementById("frame_content");
	try{
		var bHeight = iframe.contentWindow.document.body.scrollHeight;
		var dHeight = iframe.contentWindow.document.documentElement.scrollHeight;
		var height = Math.max(bHeight, dHeight);
		iframe.height =  height;
	}catch (ex){}
}
window.setInterval("reinitIframe()", 1000);

在新浪站上看到的不错,收藏下.

动态给ifram添加内容,兼容ie和FF

Posted in 前端技术 on 十二月 12th, 2008 by admin – 评论关闭

第一次知道,还可以这样写

<iframe width=’100%’ height=’100%’ name=’boot’ id=’boot’ src=” frameborder=’0′ scrolling=’no’></iframe>
<SCRIPT   LANGUAGE=”JavaScript”>  
<!–  
var iframe = window.frames['boot'];
iframe.document.open();
iframe.document.write(‘<!DOCTYPE html PUBLIC “-//W3C//DTD XHTML 1.0 Transitional//EN” “http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd”>\n’);
iframe.document.write(‘<html xmlns=”http://www.w3.org/1999/xhtml”>\n’);
iframe.document.write(‘<head>\n’);
iframe.document.write(‘<meta http-equiv=”Content-Type” content=”text/html; charset=gb2312″ />\n’);
iframe.document.write(‘</head>\n’);
iframe.document.write(‘<body>\n’);
iframe.document.write(‘请等待…’);
iframe.document.write(‘</body>\n’);
iframe.document.write(‘</html>\n’);
iframe.document.close();
//–>  
</SCRIPT>