[Javascript] DOCTYPE making div.style.top NOT WORK

Roger Roelofs rer at datacompusa.com
Thu Dec 14 06:57:40 CST 2006


Michael,

On Dec 14, 2006, at 7:49 AM, Michael Borchers wrote:

> the following script works fine so far but when adding the  
> following DOCTYPE into the first line:
>
> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"  
> "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
>
> the script stops working and div.style.top seems to have no effect.
>
> it took me a lot of time to find this. any reason?!
> -----  8<  ---
>    div.style.top  = a.x+58;
>    div.style.left = a.y+20;

I'm a little surprised this ever worked.  You are missing the units.   
Change the code to

div.style.top = (a.x+50) + "px";

When using an xhtml doctype, the javascript engine may be treating  
the markup as xml.  If so, xml is case sensitive while html is not.

Roger
--
Roger Roelofs
Datacomp Appraisal Services
3215 Eaglecrest Drive, NE
Grand Rapids, MI  49525-4593
Email rer at datacompusa.com




More information about the Javascript mailing list