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?

10 of 13 people (77%) answered Yes
Recently 5 of 8 people (63%) answered Yes

Entry

How can I get/set line-height (aka. leading) values in NN4, NN6 and IE4+?

Jan 14th, 2001 03:01
Ian Grant, Guest,


You can set the line-height in CSS, but you cannot adjust it directly 
using JavaScript in NN4.  (NN4 only allows CSS-P, or positioning values 
to be modified.)  Fortunately, NN6 and IE4+ allow for modification of 
practically any page element, attribute or CSS property.
Here's a brief list of what each browser is capable of with their 
respective DOMs:
Ability                                           Browser
-------                                           -------
Change CSS properties of an element on screen     IE4+, NN6
Change the z-index of elements                    IE4+, NN4+, NN6
Hide or show elements                             IE4+, NN4+, NN6
Add/remove elements to/from the document flow     IE4+, NN6
Add elements to a page                            IE4+, NN4+, NN6
Position elements relative to visitor's setup     IE4+, NN4+, NN6
Move elements on screen                           IE4+, NN4+, NN6
Reclip the visible area of an element             NN4+
Resize an element                                 IE4+, NN6
To access CSS properties with IE4+ and NN6, you must use the 'style' 
object, but IE4 and NN6 have different DOMs.  In IE, use:
    document.all['divID'].style.lineHeight = "24pt";
or
    divID.style.lineHeight = "24pt";
And in NN6, use:
    document.getElementById('divID').style.lineHeight = "24pt";
Keep in mind that you should use 'parseInt' when retrieving values from 
NN6 because the suffix "pt" ("px", etc.) is almost always included.
Just remember: naming conventions in JavaScript are different than in 
CSS (i.e. hyphens "-" cannot be used).  Therefore CSS properties that 
use multiple words, have their first letter capitalized starting with 
the second word.  For example:
In CSS:
    layer-background-color: #ffffff;
In JavaScript:
    obj.style.layerBackgroundColor = "#ffffff";
Assuming that obj is either document.all.obj in IE (or simply obj) or 
document.getElementById.obj in NN6.
I hope this helps you.
Ian Grant
[email protected]