Forums Archive Index > Cool free scripts > hi !! i'm a new member.. just few doubts in DHTML

Author: venkatesh

Date: 13 Mar 2005 2:40 am

can I change the size a frame dynamically.


Author: smartmenus

Date: 14 Mar 2005 4:03 am

If you want to change the size of a frame with the help of JavaScript, the answer is no. You can, however, change the size of IFRAMEs in some browsers like IE/Win.


Author: venkatesh
Subject: thanx 4 the reply!

Date: 16 Mar 2005 8:53 am

thanx for the reply ... so the iframe's size can be changed dynamically..plz can u show me a sample of how to do it......


Author: smartmenus

Date: 18 Mar 2005 9:21 am

Here's an example that will probably work in all modern browsers (although I have only tested it in IE6, Opera 7 and Netscape 6):

Code:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<title>SmartMenus example</title>
<meta http-equiv="Content-Type" content="text/html;charset=iso-8859-1" />

<script type="text/javascript">
<!--
function changeIframeSize(){
if(!document.getElementById)
   return;
var iframeObject=document.getElementById('myIframe');
var iframeObjectStyle=iframeObject.style;
iframeObjectStyle.width='300px';
iframeObjectStyle.height='300px';
}
//-->
</script>

</head>

<body onload="changeIframeSize()">

<iframe id="myIframe" src="http://www.yahoo.com/" style="width:200px;height:200px;"></iframe>

</body>
</html>


The iframe's size will be changed onload.


Author: venkatesh
Subject: thanx man!!

Date: 22 Mar 2005 1:44 pm

thanx for the reply.. and the code.. this is goin to help me a lot man.. thanx.catch ya soon.