日期:2014-05-16  浏览次数:20470 次

如何得到iframe实际显示在浏览器中的区域的大小?
如何得到iframe实际显示在浏览器中的区域的大小?

------解决方案--------------------
http://community.csdn.net/Expert/TopicView3.asp?id=5564637
------解决方案--------------------
document.getElementById( "frame_id ").clientWidth;
document.getElementById( "frame_id ").clientHeight;
------解决方案--------------------
adsf
<iframe width= "360 " height= "158 " id= "a "> </iframe>
<input type= "button " value= "test " onclick= "test(); ">
<script>
function test(){
alert(document.getElementById( "a ").offsetWidth);
alert(document.getElementById( "a ").offsetHeight);
}
</script>
------解决方案--------------------
内部也可以得到的

window.frameElement.offsetHeight
------解决方案--------------------
另一种更准确的方法是

var rect=window.frameElement.getBoundingClientRect()
alert(rect.right-rect.left)
alert(rect.bottom-rect.top)