[Home]  [Edit this page]  [Recent Changes]  [Special Pages]  [Help
How_To_Javascript_Set_Iframe_Width_Height_Onload

How to set an iframe's width and height properties?

The example shows how to reference an element which is contained in a child of the window object. Place this in the head of your HTML document.

<script type="text/javascript"> 
function setSize() 
var iframeElement = parent.document.getElementById('iframeName'); 
iframeElement.style.height = 100; //100px or 100% 
iframeElement.style.width = 100; //100px or 100% 
</script>


Place this in the body of your HTML document.

<iframe name="iframeName" id="iframeName" onload="setSize()"></iframe>


This sets the iframe's properties with JavaScript in the onload of the iframe tag which will execute only when the iframe has fully loaded.

Related threads:
getting size of iframe contents onload()

JavaScript FAQ

last edited (April 19, 2004) by leeos, Number of views: 2333, Current Rev: 2 (Diff)

[Edit this page]  [Page history]  [What links here]  [Discuss this topic]  [Printer Friendly]  

Members

Username:

Password:


Register
Forgot Password?




Programmers Heaven - for .NET, Java, C/C++ and WEB Developers!
© 1996-2008 Community Networks Ltd. All rights reserved. Reproduction in whole or in part, in any form or medium without express written permission is prohibited. Violators of this policy may be subject to legal action. Please read Terms Of Use and Privacy Statement for more information. Development by Tore Nestenius at .NET Consultant - Synchron Data.