javascript and strict doctype

javascript and strict doctype

am 26.01.2008 22:20:11 von jeff

I have a page with a bit of DHTML that I wrote years ago that I'm
updating.

This works as expected without a doctype, but when I add a html 4.01
doctype, strange things happen.

IE has trouble redrawing the page background color (I'm adding a rule
for that), it's funky and sometimes it leaves a bit of the previous
color. In Fire Fox, reading element positions is way wrong (I get 0 0
on somethings).

The page passes W3C validation.

What gives?

Jeff

Re: javascript and strict doctype

am 27.01.2008 00:08:44 von lws4art

Jeff wrote:
> I have a page with a bit of DHTML that I wrote years ago that I'm
> updating.
>
> This works as expected without a doctype, but when I add a html 4.01
> doctype, strange things happen.
>
> IE has trouble redrawing the page background color (I'm adding a rule
> for that), it's funky and sometimes it leaves a bit of the previous
> color. In Fire Fox, reading element positions is way wrong (I get 0 0
> on somethings).
>
> The page passes W3C validation.
>
> What gives?
>

It sometimes happens with code found on line 6.


--
Take care,

Jonathan
-------------------
LITTLE WORKS STUDIO
http://www.LittleWorksStudio.com

Re: javascript and strict doctype

am 27.01.2008 01:38:12 von Stanimir Stamenkov

Sat, 26 Jan 2008 16:20:11 -0500, /Jeff/:

> This works as expected without a doctype, but when I add a html 4.01
> doctype, strange things happen.
>
> IE has trouble redrawing the page background color (I'm adding a rule
> for that), it's funky and sometimes it leaves a bit of the previous
> color. In Fire Fox, reading element positions is way wrong (I get 0 0
> on somethings).

"http://websiterepairguru.com/colorpicker_2.htm", line 275:

target_menu.style.left=(pos.x);
target_menu.style.top=pos.y + pos.height;

You don't specify units:

target_menu.style.left=(pos.x) + "px";
target_menu.style.top=(pos.y + pos.height) + "px";

--
Stanimir

Re: javascript and strict doctype

am 27.01.2008 02:02:54 von PointedEars

Stanimir Stamenkov wrote:
> target_menu.style.left=(pos.x) + "px";

The parentheses are unnecessary.

> target_menu.style.top=(pos.y + pos.height) + "px";

This will most likely not work, because with this getPosition() method
pos.height would yield the value of the `height' property which would most
likely include a unit of length (the unit is not required only if the length
is 0). So for example the above could be evaluated to

target_menu.style.top = (42 + "23px") + "px";

and therefore

target_menu.style.top = "4223px" + "px";

and eventually

target_menu.style.top = "4223pxpx";

which would be an invalid property value.

It would work if pos.height would be the value of the `offsetHeight'
property of the element object instead. Same for pos.width and `offsetWidth'.


F'up2 comp.lang.javascript

PointedEars
--
var bugRiddenCrashPronePieceOfJunk = (
navigator.userAgent.indexOf('MSIE 5') != -1
&& navigator.userAgent.indexOf('Mac') != -1
) // Plone, register_function.js:16

Re: javascript and strict doctype

am 27.01.2008 05:54:19 von jeff

aoksite1@gmail.com wrote:
> On Jan 26, 3:20 pm, Jeff wrote:
>> I have a page with a bit of DHTML that I wrote years ago that I'm
>> updating.
>>
>> This works as expected without a doctype, but when I add a html 4.01
>> doctype, strange things happen.
>>
>> IE has trouble redrawing the page background color (I'm adding a rule
>> for that), it's funky and sometimes it leaves a bit of the previous
>> color. In Fire Fox, reading element positions is way wrong (I get 0 0
>> on somethings).
>>
>> The page passes W3C validation.
>>
>> What gives?
>>
>> Jeff
>
> Jeff,
>
> I think this may be what you wanted. Not sure but works a little
> better. Let me know something.
>
> http://a-ok-site.com/tmp/test.htm

I was going to say "genius"! That you had gotten rid of the IE
problem with strict. But then I noticed you changed the doctype to
transitional!

Thanks for your time, I know you spent a bit.

Jeff
>
> Daniel
>
> http://a-ok-site.com

Re: javascript and strict doctype

am 27.01.2008 16:14:19 von jeff

A-OK-SITE wrote:
> On Jan 26, 10:54 pm, Jeff wrote:
>> aoksi...@gmail.com wrote:
>>> On Jan 26, 3:20 pm, Jeff wrote:
>>>> I have a page with a bit of DHTML that I wrote years ago that I'm
>>>> updating.
>>>> This works as expected without a doctype, but when I add a html 4.01
>>>> doctype, strange things happen.
>>>> IE has trouble redrawing the page background color (I'm adding a rule
>>>> for that), it's funky and sometimes it leaves a bit of the previous
>>>> color. In Fire Fox, reading element positions is way wrong (I get 0 0
>>>> on somethings).
>>>> The page passes W3C validation.
>>>> What gives?
>>>> Jeff
>>> Jeff,
>>> I think this may be what you wanted. Not sure but works a little
>>> better. Let me know something.
>>> http://a-ok-site.com/tmp/test.htm
>> I was going to say "genius"! That you had gotten rid of the IE
>> problem with strict. But then I noticed you changed the doctype to
>> transitional!
>>
>> Thanks for your time, I know you spent a bit.
>>
>> Jeff
>>
>>
>>
>>> Daniel
>>> http://a-ok-site.com

Hello Daniel,
>
> I changed it to strict. Sorry didn't think it was important. The IE
> is still fixed.
>
> http://a-ok-site.com/tmp/test.htm

Well, I'll give you that. Thanks!

Now, I notice you did several things. What do you think "fixed" it?

Jeff
>
> Daniel
>
> http://a-ok-site.com