By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,317 Members | 1,290 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,317 IT Pros & Developers. It's quick & easy.

'px' between JS and CSS

P: n/a
maz
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

How come ?
Jul 23 '05 #1
Share this Question
Share on Google+
1 Reply


P: n/a


maz wrote:
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


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/
Jul 23 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.