11.7.06

for posterity

when developing for the web w/ firefox or safari/opera/konqueror, if you take the browser out of quirks mode by specifying a doctype such as XHTML 1.0 transitional or strict, or even HTML 4.01 transitional etc. If your javascript uses something like:
var myObj = document.getElementById("MyObjectsId");
myObj.left = 100;
myObj.top = 200;

you'll notice it doesn't work.. sometimes complaining with an error like: "Declaration Dropped"
In any case, the solution is simple (and a little stupid) add "px" at the end of the number to indicate you meant 100 pixels and not 100 something else.. (em, etc)
so the corrected code should read:
var myObj = document.getElementById("MyObjectsId");
myObj.left = 100 + "px";
myObj.top = 200 + "px";
or:
var myObj = document.getElementById("MyObjectsId");
myObj.left = "100px";
myObj.top = "200px";

that was really frustrating till I figured it out. So, in case you are lost, I hope you find this page, and it helps!

Comments


Related posts

Blog Widget by LinkWithin