[Javascript] Apply padding via javascript
Scott Reynen
scott at randomchaos.com
Sat Aug 19 17:12:34 CDT 2006
On Aug 19, 2006, at 1:29 AM, Abyss - Information wrote:
> Hi all
>
> If I wanted to add padding to a div tag after I found the screen
> resolution via Javascript
>
> what would be the best out of the following 2 options?
>
> document.all.MyBlock.style
> or
> document.layers['MyBlock'].style
As I understand it, both document.all and document.layers are browser-
specific, with document.all working in IE4 and document.layers
working in Netscape 4. So which is "best" depends on which of those
obsolete browsers you're looking to support. But unless you have
some special circumstances, the best would probably be to use the
standard supported by "every Javascript supporting browser released
since 1998" [1]:
document.getElementById( 'MyBlock' ).style
[1] http://simon.incutio.com/archive/2003/08/11/documentAll
Peace,
Scott
More information about the Javascript
mailing list