main.htm<html>
<body>
<div>
<iframe id=frmDetail scrolling=no name=mm src="detail.htm" style="width:expression(this.contentWindow.document.all.tblDetail.width);height:expression(this.contentWindow.document.all.tblDetail.height)"></iframe>
<button onclick="with(document.all.frmDetail.contentWindow.document.all.tblDetail){width=offsetWidth+1}">+</button>
<button onclick="with(document.all.frmDetail.contentWindow.document.all.tblDetail){width=offsetWidth-1}">-</button>
</div>
</body>
</html>detail.htm<html>
<body leftmargin=0 topmargin=0>
<table id=tblDetail width=100 height=100 border=0 bgcolor=red>
<tr><td></td></tr>
</table>
</body>
</html>
<body>
<div>
<iframe id=frmDetail scrolling=no name=mm src="detail.htm" style="width:expression(this.contentWindow.document.all.tblDetail.width);height:expression(this.contentWindow.document.all.tblDetail.height)"></iframe>
<button onclick="with(document.all.frmDetail.contentWindow.document.all.tblDetail){width=offsetWidth+1}">+</button>
<button onclick="with(document.all.frmDetail.contentWindow.document.all.tblDetail){width=offsetWidth-1}">-</button>
</div>
</body>
</html>detail.htm<html>
<body leftmargin=0 topmargin=0>
<table id=tblDetail width=100 height=100 border=0 bgcolor=red>
<tr><td></td></tr>
</table>
</body>
</html>
解决方案 »
- IE10 里面 this._img.filters 是空对象如何解决这个问题?
- 网页上加入PDF格式文件浏览功能,该怎么做
- 如何根据获得的对象取其ID值?
- jquery ajax提交也能跟form提交方式一样做吗?
- 求个Js正则
- 求一个jquery效果类似于http://www.lippincott.com/zh/work
- 救命阿,遇到空前难题!!!
- 在弹出窗口中出现运行期错误,说w为空或者不是对象,怎么解决?
- 为什么不保持当前的页面。
- 我以前使用了一个离线浏览软件,它不是要设置下载页面,而是在你浏览网站时就将页面自动存入硬盘中
- 求助!在jsp里写javaScript的问题
- 菜鸟问一个简单问题:)
你的方法很好,但是我需要的是不用按键,只直你直接给定table的高和宽,iframe的大小跟着变,因为我在table里存放记录集的,table 随着取出来的记录集的大小改变而扩大缩小,所以要iframe都跟着变化。希望你帮下我!!!!
main.htm<html>
<body>
<div>
<iframe id=frmDetail scrolling=no name=mm src="tb.htm" onload="style.width=this.contentWindow.document.all.tblDetail.offsetWidth;style.height=this.contentWindow.document.all.tblDetail.offsetHeight"></iframe>
</div>
</body>
</html>
tb.htm
<html>
<body leftmargin=0 topmargin=0>
<table id=tblDetail width=100 height=100 border=0 bgcolor=red>
<tr><td>
dddddddddddddddddddddddddddddddddddddddddddddddddddddddd
</td></tr>
</table>
</body>
</html>
这样做只能在 div 把表格撑大的时候动态变化. 把 div 里的文字删
了之后, 表格就不会自动跟着缩小了, 请问该如何解决?另外, 你前面用 expression 的方法虽好, 但比较占资源. 一般最好不用.<html>
<body leftmargin=0 topmargin=0>
<table id=tblDetail width=100 height=100 border=0 bgcolor=red >
<tr><td>
dddddddddddddddddddddddddddddddddddddddddddddddddddddddd
<div contentEditable=true onkeydown="top.document.all.frmDetail.style.width=document.all.tblDetail.offsetWidth;">input here:<br>__</div>
</td></tr>
</table>
</body>
</html>
搞不顶的话你先放到表格里试试。
<table id=tblDetail width=100 height=100 border=0 bgcolor=red >==><table id=tblDetail width=0 height=0 border=0 bgcolor=red >
<table id=tblDetail width=1 height=1 border=0 bgcolor=red >
<table id=tblDetail width=1% height=1% border=0 bgcolor=red >
table 被撑大后, 不会复原了. :(
<%
url=Request.QueryString("url")
%>
<body onload="document.all.ifId.style.width=parseInt(ifId.document.getElementsByTagName('table')[0].width)+20">
<iframe name=ifId id=ifId src="<%=url%>"></iframe>
<br>
<a href=2.asp?url=1.asp>1.asp</a>
<br>
<a href=2.asp?url=2.asp>2.asp</a>1.asp
<table width=500>
<tr><td>
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
</table>2.asp
<table width=200>
<tr><td>
aaaaaaaaa
</table>