Why my .style.left doesn’t work with FireFox?

This is a simple & stupid knowledge that I taken about 2 days to solve it.

I have a project that have to use this code….

var con = document.getElementById(”menu”);

con.style.left = “10″;

con.style.top = “20″;

When I run this code in Internet Explorer 6, 7.

I got it working like I want!

But when I try with Mozilla FireFox.

It never works!

Man! I hate DOM, if I have enough money. I’ll buy Microsoft and stop Internet Explorer project to reduce browser compatibility issues. :-)

I try to use FireBug to change the css real-time, it does work very well.

The key point of this issue is that YOU MUST APPEND the property with UNIT!

I changed the code to…

con.style.left = “10px”;

con.style.top = “20px”;

And now it works!

Gotcha!

Simple & Stupid, right?

:-)

Share and Enjoy: These icons link to social bookmarking sites where readers can share and discover new web pages.
  • Digg
  • del.icio.us
  • Netvouz
  • DZone
  • ThisNext
  • MisterWong
  • Wists

Leave a Comment