iframe 高度调整,正确立即结贴

xiaohu8855 2013-03-05 03:43:23
问题描述:
主页面有几个a标签,
<a href="#" onclick="todo(this,'act')">asdf</a>
<a href="#" onclick="todo(this,'actdd')">asdfddd</a>

主页面内嵌套了iframe.如下:
<iframe name="content_up" id="content_down" marginheight=0 marginwidth=0 border=0
topmargin=0 leftmargin=0 frameborder=0 scrolling="auto"
width="780" height="400"
src="#" onload="this.height="(this.contentDocument||this.contentWindow.document).body.offsetHeight+30">
</iframe>

主页面js
function todo(obj,act){
document.getElementById("content_up").src="aaa.jsp?act="+act;
obj.href="/bbb.do?act="+act;
}

现在每点击一下a标签,iframe 会自动增高,火狐是正常的。但是IE 有问题。。

请教各位解决方案 。。 急用
...全文
129 5 打赏 收藏 转发到动态 举报
写回复
用AI写文章
5 条回复
切换为时间正序
请发表友善的回复…
发表回复
吕大豹 2013-03-28
  • 打赏
  • 举报
回复
onload="this.height="(this.contentDocument||this.contentWindow.document).body.offsetHeight+30" 看一下你这里的分号有问题,ie解析错误了。请把分号匹配好
jswatcher 2013-03-05
  • 打赏
  • 举报
回复
不用 offsetHeight, 用 clientHeight 试试
still_melody 2013-03-05
  • 打赏
  • 举报
回复
onload="this.height="(this.contentDocument||this.contentWindow.document).body.offsetHeight+30" 应该是这个地方,这个地方是干嘛用的
xiaohu8855 2013-03-05
  • 打赏
  • 举报
回复
这样也是不行的。。。
未知数 2013-03-05
  • 打赏
  • 举报
回复
<a href="javascript:;" onclick="todo(this,'act')">asdf</a> <a href="javascript:;" onclick="todo(this,'actdd')">asdfddd</a> 如果还不行,把函数也改一改: function todo(obj,act){ setTimeout(function(){ document.getElementById("content_up").src="aaa.jsp?act="+act; obj.href="/bbb.do?act="+act; },1); }

61,112

社区成员

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

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