多层嵌套iframe 问题

sunli_py 2011-04-28 03:33:35
多层嵌套iframe 问题

我有一网页main.html 内有
<iframe src="product.html" name="main" marginheight="0" scrolling="no" frameborder="0" width="100%" height="300" onload="javascript:dyniframesize('main');"></iframe>

product.html中有一FLASH按钮和一框架
<iframe src="1.html" name="main_product" width="100%" height="250" marginheight="0" scrolling="No" frameborder="0" id="main" onload="javascript:dyniframesize('main_product')"></iframe>

我通过点击FLASH各按钮调用不同网页(如1.html\2.html到main_product中显示),如1.html高度为50PX,2.html高度为100PX,我默认第一次打开main.html时网页高度都显示正常,当我点击FLASH按钮调用2.HTML时网页高度还是显示的1.HTML的高度50PX,只有当把整个网页刷新一下才会显示正常的100px,请问这个情况如何解决??
dyniframesize函数为ifram框架自适应高度调整函数

--------------函数如下


<script language="javascript" type="text/javascript">
<!--ifram框架自适应高度调整函数 -->
function dyniframesize(down) {
var pTar = null;
if (document.getElementById){
pTar = document.getElementById(down);
}
else{
eval('pTar = ' + down + ';');
}
if (pTar && !window.opera){
//begin resizing iframe
pTar.style.display="block"
if (pTar.contentDocument && pTar.contentDocument.body.offsetHeight){
//ns6 syntax
pTar.height = pTar.contentDocument.body.offsetHeight +20;
pTar.width = pTar.contentDocument.body.scrollWidth+20;
}
else if (pTar.Document && pTar.Document.body.scrollHeight){
//ie5+ syntax
pTar.height = pTar.Document.body.scrollHeight;
pTar.width = pTar.Document.body.scrollWidth;
}
}
}
</script>


...全文
464 7 打赏 收藏 转发到动态 举报
写回复
用AI写文章
7 条回复
切换为时间正序
请发表友善的回复…
发表回复
toury 2011-04-28
  • 打赏
  • 举报
回复
[Quote=引用 5 楼 sunli_py 的回复:]

可以在FLASH如何写 onload="javascript:dyniframesize('main_product') 函数调用啊?
我的flash按钮调用网页代码是:
getURL(links[this.i], target="main_product");
,如果用纯粹的刷新操作,这样也会使flash按钮状态还原的
[/Quote]
这里URL可以加参数吗?最终形成:"1.html?a=resize" ??

sunli_py 2011-04-28
  • 打赏
  • 举报
回复
可以在FLASH如何写 onload="javascript:dyniframesize('main_product') 函数调用啊?
我的flash按钮调用网页代码是:
getURL(links[this.i], target="main_product");
,如果用纯粹的刷新操作,这样也会使flash按钮状态还原的
toury 2011-04-28
  • 打赏
  • 举报
回复
[Quote=引用 3 楼 sunli_py 的回复:]

现在的问题是,好像点击product.html中FLASH按钮时没有执行onload="javascript:dyniframesize('main_product')这句话
所以造成不能刷新,页面高度还是原来的
[/Quote]
是啊,我忽略了你这句话:只有当把整个网页刷新一下才会显示正常的100px!!汗~~
dyniframesize()要在点flash按钮时执行才对,当然,onload也保留
sunli_py 2011-04-28
  • 打赏
  • 举报
回复
现在的问题是,好像点击product.html中FLASH按钮时没有执行onload="javascript:dyniframesize('main_product')这句话
所以造成不能刷新,页面高度还是原来的
toury 2011-04-28
  • 打赏
  • 举报
回复

<script language="javascript" type="text/javascript">
<!--ifram框架自适应高度调整函数 -->
function dyniframesize(o) {
if(!o) o=document.getElementById(o);
if(!o){alert('神马状况,怎么都不对?'); return;}

//begin resizing iframe
o.style.display="block" ;
doc=o.contentDocument||o.contentWindow.document
if (o.contentDocument && o.contentDocument.body.offsetHeight){
o.style.height = o.contentDocument.body.offsetHeight +20;
o.style.width = o.contentDocument.body.scrollWidth+20;
}
else if (o.Document && o.Document.body.scrollHeight){
//ie5+ syntax
o.style.height = o.Document.body.scrollHeight;
o.style.width = o.Document.body.scrollWidth;
}
}
</script>
<iframe src="1.html" name="main_product" width="100%" height="250" marginheight="0" scrolling="No" frameborder="0" id="main" onload="javascript:dyniframesize(this)"></iframe>
sunli_py 2011-04-28
  • 打赏
  • 举报
回复
没人回答啊?顶一下

61,115

社区成员

发帖
与我相关
我的任务
社区描述
层叠样式表(英文全称:Cascading Style Sheets)是一种用来表现HTML(标准通用标记语言的一个应用)或XML(标准通用标记语言的一个子集)等文件样式的计算机语言。
社区管理员
  • HTML(CSS)社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧