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

Michael Borchers list at tridemail.de
Thu Dec 14 07:59:23 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.

using px makes the script work fine again, thanks!

one last thing: the div closes "on mouse out". inside the div i have a link
<a href="...">foo</a>

when touching the link "on mouse over" the div and the link dissappears.
can i use anything else than "on mouse out" for the div or add something
to the link inside the div?!




More information about the Javascript mailing list