怎么“动态”改变iframe的高度?

qnzu 2003-10-15 09:29:30
iframe外面有个table。
table的高度是100%。

是否有事件能够在table改变大小的时候触发,然后在里面添加语句,改变iframe的大小?

触发事件怎么写?怎么重新改变iframe的高度?

...全文
427 12 打赏 收藏 转发到动态 举报
写回复
用AI写文章
12 条回复
切换为时间正序
请发表友善的回复…
发表回复
qnzu 2003-10-17
  • 打赏
  • 举报
回复
up

up
aRayn 2003-10-17
  • 打赏
  • 举报
回复
bflovesnow(北风) 的方法:
<iframe name=ifm onload="this.height=ifm.document.body.scrollHeight+10">

看起来是合理地,只是不知道阁下是否有运行过呀?我在我的环境:Win2000 Adv Server, IE 6.0.2800 下试过是不行的,会报错!!!
BainStudio 2003-10-17
  • 打赏
  • 举报
回复
我不知道理解的是否正确.如果你是在A页面中加了B,B是iframe.
B是被加在A中的TABLE中间的.你想在A页面的大小进行改动的时候.iframe的宽度也进行相应改动.这里有两个方法.

第一,因为你的table的width是:100%,那么如果你想要让里面的iframe也进行自动伸缩.把width的值也设置为100%就好了.如果有问题.你可以看你的iframe所调用的页面中的代码写发.如果在B页面中的BODY设置为:10.那么即使你的iframe设置为:100%.里面所看见的也只有10.虽然你的框架是:100%.

第二,你可以通过onResize时间来更改你的iframe框架.
先给iframe给一个标识.然后根据时间的出发更改他的width的值.
黑马 2003-10-17
  • 打赏
  • 举报
回复
能不能根据iframe的高度调整包含iframe部分的高度,可能是table或tr或td?
qnzu 2003-10-16
  • 打赏
  • 举报
回复
没有人理我:(

ding阿
qnzu 2003-10-16
  • 打赏
  • 举报
回复
楼上说的方法怎么不行啊?
得到的高度总是只有200象素左右。

能不能让iframe的高度总是比在它外面的table小20象素(iframe随着table变化),而table为100% ?
bflovesnow 2003-10-16
  • 打赏
  • 举报
回复
<iframe name=ifm onload="this.height=ifm.document.body.scrollHeight+10">
longshenwang 2003-10-16
  • 打赏
  • 举报
回复
帮你顶....
  • 打赏
  • 举报
回复
<iframe src='http://www.e-picc.com.cn/ebiz/servlet/com.general.ebiz.ms.info.tradetrends.TradeTrendsServlet?saction=15&category=4'
NAME='PICC_CoverInfo'
ID='PICC_CoverInfo'
FRAMEBORDER=0
marginWidth="0"
marginHeight="0"
scrolling=no
width="100%"
onload='var f=document.all["PICC_CoverInfo"]; var b=f.Document.body; f.height=b.scrollHeight'>
</iframe>
qnzu 2003-10-15
  • 打赏
  • 举报
回复
iframe 的 height 为 100% 后,那它里面的网页(src="1.htm")就没有滚动条了:(

楼上好厉害啊,可是我的英语好差的:(
孟子E章 2003-10-15
  • 打赏
  • 举报
回复
<table><tr><td><iframe style="height:100%">
zhfkiller 2003-10-15
  • 打赏
  • 举报
回复
onresize Event Internet Development Index

--------------------------------------------------------------------------------

Fires when the size of the object is about to change.

Syntax

Inline HTML <ELEMENT onresize = "handler" ... > All platforms
Event property object.onresize = handler JScript only
object.onresize = GetRef("handler") Visual Basic Scripting Edition (VBScript) 5.0 or later only
Named script <SCRIPT FOR = object EVENT = onresize> Internet Explorer only

Event Information

Bubbles No
Cancels No
To invoke Change the height or width of the object.
Default action No default action.

Event Object Properties

Although event handlers in the DHTML Object Model do not receive parameters directly, a handler can query an event object for data.

Show Available Properties

altKey Sets or retrieves a value that indicates the state of the ALT key.
altLeft Sets or retrieves a value that indicates the state of the left ALT key.
clientX Sets or retrieves the x-coordinate of the mouse pointer's position relative to the client area of the window, excluding window decorations and scroll bars.
clientY Sets or retrieves the y-coordinate of the mouse pointer's position relative to the client area of the window, excluding window decorations and scroll bars.
ctrlKey Sets or retrieves the state of the CTRL key.
ctrlLeft Sets or retrieves the state of the left CTRL key.
offsetX Sets or retrieves the x-coordinate of the mouse pointer's position relative to the object firing the event.
offsetY Sets or retrieves the y-coordinate of the mouse pointer's position relative to the object firing the event.
returnValue Sets or retrieves the return value from the event.
screenX Retrieves the x-coordinate of the mouse pointer's position relative to the user's screen.
screenY Sets or retrieves the y-coordinate of the mouse pointer's position relative to the user's screen.
shiftKey Sets or retrieves the state of the SHIFT key.
shiftLeft Retrieves the state of the left SHIFT key.
srcElement Sets or retrieves the object that fired the event.
type Sets or retrieves the event name from the event object.
x Sets or retrieves the x-coordinate, in pixels, of the mouse pointer's position relative to a relatively positioned parent element.
y Sets or retrieves the y-coordinate, in pixels, of the mouse pointer's position relative to a relatively positioned parent element.

Remarks

The onresize event fires for block and inline objects with layout, even if document or CSS (cascading style sheets) property values are changed. Objects have layout when measurements such as the height and width attributes are set, or when the position of the object is set. Intrinsic objects, such as button, and windowed objects, such as window and iframe, fire as expected. This event does not fire for files with embedded controls.

Resizing HTML applications also fires the onresize event.

87,902

社区成员

发帖
与我相关
我的任务
社区描述
Web 开发 JavaScript
社区管理员
  • JavaScript
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

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