faqts : Computers : Programming : Languages : JavaScript : DHTML

+ Search
Add Entry AlertManage Folder Edit Entry Add page to http://del.icio.us/
Did You Find This Entry Useful?

29 of 37 people (78%) answered Yes
Recently 7 of 10 people (70%) answered Yes

Entry

How do I change the width/height of a page element (IE4 /NN6)/ a positioned element/layer(NN4)

Mar 13th, 2000 04:17
Martin Honnen,


IE4+ and NN6 allow you to dynamically change the inline style of any 
element by using
  elementReference.style.width = '200px';
  elementReference.style.width = '200px';
so suppose you have an element 
  <DIV ID="aDiv">
you would script
  var l = document.all ? document.all['aDiv'] :
            document.getElementById('aDiv');
  l.style.width = '200px';
  l.style.height = '200px';
with IE4+ and NN6.

NN4 only allows scripting of positioned elements so you need a 
positioned DIV. Then it doesn't allow to dynamically change the 
width/height of the positioned element but only allows to change the 
clipping of the element though in many cases this has the same effect.
  elementReference.clip.width = 200;
  elementReference.clip.height = 200;

Here is a complete example which dynamically increases the width and 
height of a positioned element with NN4+ and IE4+.