接下来,我们将编写JavaScript代码来计算iframe的高度。以下是script.js的代码: functionadjustIframeHeight(){variframe=document.getElementById('myIframe');// 获取iframe元素iframe.onload=function(){// 监听iframe加载完成事件variframeBody=ifr
Html<iframename="container_ifranme"id="iframeId"scrolling="no"frameborder="no"border="0"src="home.html"onLoad="iFrameHeight()"></iframe>JsfunctioniFrameHeight(){varifm=document.getElementById("iframeId");varsubWeb=document.frames?document.frames["iframeId"].document:ifm.contentDocument;if(ifm!
调用方式如下 <iframe id="ifm" name="ifm" onload="SetIFrameHeight('ifm')" src="http://www.qq.com" /> function SetIFrameHeight(down) { var Sys = {}; var...
pTar=document.getElementById(iframename); 11 } 12 else 13 { 14 eval('pTar ='+iframename+';'); 15 } 16 if(pTar&&!window.opera) 17 { 18 //begin resizing iframe 19 pTar.style.display="block" 20 if(pTar.contentDocument&&pTar.contentDocument.body.offsetHeight) 21 { 22 //ns6 sy...
mFrame.height = hTable; if(window.mainFrame.moduleRight != null){ //表示该内嵌页,包含内嵌的页面,页iframe的id固定为moduleRight。 initFrameHeight(mFrame,hTable); } } /** * 获取当前页面的高度 */ function getBodyHeight(doc){ if(doc.all) return doc.body.offsetHeight; ...
if (document.getElementById) { //自动调整iframe高度 dyniframe[dyniframe.length] = document.getElementById(iframeids[i]); if (dyniframe[i] && !window.opera) { dyniframe[i].style.display = "block"; if (dyniframe[i].contentDocument && dyniframe[i].contentDocument.body.offsetHeight) //如...
你试试,我这本地测试可以 <script> function setIframeHeight(iframe) { if(iframe) { var iframeWin = iframe.contentWindow || iframe.contentDocument.parentWindow; if(iframeWin.document.body) { iframe.height = iframeWin.document.documentElement.scrollHeight || iframeWin.document.body.scrollHeight; } ...
在iframe完全加载后即onload,调用setIframeHeight(),iframe内容加载完成后,可获取iframe的高度值,然后重新设置iframe的高度,以下是整理好的代码: function setIframeHeight(id) { var ifrm = document.getElementById(id); var doc = ifrm.contentDocument? ifrm.contentDocument: ifrm.contentWindow.document; ifrm.sty...
代码如下: $('#objId', parent.document); // 搞定... 在父页面 获取iframe子页面的元素 代码如下: $("#objid",document.frames('iframename').document) $(document.getElementById('iframeId').contentWindow.document.body).html() 显示iframe中body元素的内容。 $("#testId", document.frames("iframena...
简介:调用方式如下 function SetIFrameHeight(down) { var Sys = {}; var ua = navigator. 调用方式如下 <iframe id="ifm"name="ifm"onload="SetIFrameHeight('ifm')"src="http://www.qq.com"/> functionSetIFrameHeight(down) {varSys = {};varua = navigator.userAgent.toLowerCase();vars; ...