【问题标题】:Resizing div after iframe change srciframe 更改 src 后调整 div 的大小
【发布时间】:2009-10-30 19:55:58
【问题描述】:

所以我会根据内容高度自动调整 iframe 的大小,如下所示:

<iframe name="main" id="main" src="main.php" frameborder=0 scrolling="no" onload="this.style.height = main.document.body.scrollHeight + 5; this.style.width = main.document.body.scrollWidth">

但是,我也使用一个链接来更改 src(如果有人想知道,可以使用目标),但是我的 iframe 的高度变化很大,在改回较短的 iframe 后,我调整 div/document 正文大小的方法没有没用……

例如

<a href="mail.php" onclick="document.getElementById("content").style.height = main.document.body.scrollHeight" target="main">

有什么建议吗?

【问题讨论】:

  • 尝试 onclick="document.getElementById(\"content\").style...
  • 或 document.getElementById('content')

标签: php html iframe resize onclick


【解决方案1】:

只要我修复了双引号,Div 调整大小就可以正常工作...问题是 iframe 在更改源后没有调整大小,但现在可以正常工作...谢谢

【讨论】:

  • 为了将来参考,最好准确地发布你是如何工作的..
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2011-11-08
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多