'px' between JS and CSS

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • maz

    #1

    'px' between JS and CSS

    In IE expressions such like
    | obj.style.top = 100;
    work, but don't in mozilla... where i have to add
    | obj.style.top = 100+'px';

    But the script described here :

    do not add any 'px' to JS style calls... and it works in mozilla :S

    How come ?
  • Martin Honnen

    #2
    Re: 'px' between JS and CSS



    maz wrote:
    [color=blue]
    > In IE expressions such like
    > | obj.style.top = 100;
    > work, but don't in mozilla... where i have to add
    > | obj.style.top = 100+'px';
    >
    > But the script described here :
    > http://www.quirksmode.org/js/layerscroll.html
    > do not add any 'px' to JS style calls... and it works in mozilla :S[/color]

    The name of that page is the program, "quirksmode " is what makes Mozilla
    (and IE 6) decide on how to deal with quirks like older browsers
    assuming 'px' as the unit if no unit is given in a CSS value expecting a
    unit. Thus if you want to make sure browsers interpret your CSS (even
    CSS used in script) properly then use the correct CSS syntax and for top
    that means a number plus a unit (unless the value is 0).

    More about quirks mode in Mozilla:
    <http://www.mozilla.org/docs/web-developer/quirks/>
    More about quirks mode in IE 6:
    <http://msdn.microsoft. com/library/default.asp?url =/library/en-us/dnie60/html/cssenhancements .asp>



    --

    Martin Honnen
    http://JavaScript.FAQTs.com/

    Comment

    Working...