日期:2014-05-17  浏览次数:20772 次

如何让框架去适应图片大小的变化
如题~~
谢谢

------解决方案--------------------
width=100%用这种表示宽度...
------解决方案--------------------
b.htm

<body topmargin= "0 " leftmargin= "0 " rightmargin= "0 " bottommargin= "0 ">
<img src= "http://www.baidu.com/img/logo-yy.gif " name= "pic " id= "pic " border=0 />
</body>

a.htm

<iframe name= "bf " id= "bf " src= "b.htm " width=0 height=0 frameBorder=0 marginWidth=0> </iframe>

<script language=javascript>
<!--
document.frames[ "bf "].onload = function() {
document.all( "bf ").width = document.frames[ "bf "].document.getElementById( "pic ").width + 4;
document.all( "bf ").height = document.frames[ "bf "].document.getElementById( "pic ").height + 4;
}
-->
</script>

------解决方案--------------------
b.htm
=============
<body topmargin= "0 " leftmargin= "0 " rightmargin= "0 " bottommargin= "0 ">
<img src= "http://www.baidu.com/img/logo-yy.gif " name= "pic " id= "pic " border=0 />

<script language=javascript>
function pic.onload() {
parent.document.all(window.name).width = document.getElementById( "pic ").width + 4;
parent.document.all(window.name).height = document.getElementById( "pic ").height + 4;
}
</script>
</body> --------------------------------------------------
a.htm
=========
<iframe name= "bf " id= "bf " src= "b.htm " width=0 height=0 frameBorder=0 marginWidth=0> </iframe>

这样好像更符合要求