473,498 Members | 1,911 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

doctype breaks my script

I have a page with the following basic structure:

body
div .container
div .header
div #content

An event on the page triggers a function in the head that sets the
color and the width of the content div:

function setBox() {
document.getElementById("content").style.backgroun dColor = 'green';
document.getElementById('content').style.width = '250px';
}

This works when I use no doctype or a html transitional doctype.
When I use the html strict doctype the script sets the width but fails
to set the color. I spent way too much time searching and figuring out
what is wrong. Should this work or am I making a mistake? So I hope one
of you experienced programmer can help me along... Thanks,

--
Bart
Jul 23 '05 #1
4 1386
Bart wrote:

<snip>

An event on the page triggers a function in the head that sets the
color and the width of the content div:

function setBox() {
document.getElementById("content").style.backgroun dColor = 'green';
document.getElementById('content').style.width = '250px';
}

This works when I use no doctype or a html transitional doctype.


What is your dtd, and in which browser?

Mick
Jul 23 '05 #2
In article <04*********************@thuis.bla>, Bart <ba**@thuis.bla>
wrote:
I have a page with the following basic structure:

body
div .container
div .header
div #content

An event on the page triggers a function in the head that sets the
color and the width of the content div:

function setBox() {
document.getElementById("content").style.backgroun dColor = 'green';
document.getElementById('content').style.width = '250px';
}

This works when I use no doctype or a html transitional doctype.
When I use the html strict doctype the script sets the width but fails
to set the color. I spent way too much time searching and figuring out
what is wrong. Should this work or am I making a mistake? So I hope one
of you experienced programmer can help me along... Thanks,


Oops, forget it, I already found out what was wrong in my page. I
defined the colors as RGB hexadecimal triplets but forgot the hash
marks. Apparently that is accepted in transitional but not in strict...

--
Bart
Jul 23 '05 #3
Bart <ba**@thuis.bla> writes:
Oops, forget it, I already found out what was wrong in my page. I
defined the colors as RGB hexadecimal triplets but forgot the hash
marks. Apparently that is accepted in transitional but not in strict...
It's accepted in quirks mode, but not in standards compliant mode
(because the standard mandates that invalid values are ignored, and
the # is required for it to be a valid value)

--
Bart


--
Lasse Reichstein Nielsen - lr*@hotpop.com
DHTML Death Colors: <URL:http://www.infimum.dk/HTML/rasterTriangleDOM.html>
'Faith without judgement merely degrades the spirit divine.'
Jul 23 '05 #4
Bart <ba**@thuis.bla> writes:
Oops, forget it, I already found out what was wrong in my page. I
defined the colors as RGB hexadecimal triplets but forgot the hash
marks. Apparently that is accepted in transitional but not in strict...


It's accepted in quirks mode, but not in standards compliant mode
(because the standard mandates that invalid values are ignored, and
the # is required for it to be a valid CSS value).

It has nothing to do with the version of *HTML*, but browsers are also
using the DOCTYPE declaration to change between stanards and quirks
mode. You can have HTML 4.01 Transitional with standards compliant
rendering.
<URL:http://msdn.microsoft.com/library/en-us/dnie60/html/cssenhancements.asp>

/L
--
Lasse Reichstein Nielsen - lr*@hotpop.com
DHTML Death Colors: <URL:http://www.infimum.dk/HTML/rasterTriangleDOM.html>
'Faith without judgement merely degrades the spirit divine.'
Jul 23 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

8
1572
by: Matthew Schubert | last post by:
I have reason for an element on a page to be static, like the CSS property "position: fixed" defines. Obviously, this CSS property doesn't work in IE :-/ I have looked around at alternatives,...
1
2651
by: Sugapablo | last post by:
I have the following script (below). If I have the DOCYPE at the top, tDIV.style.top and tDIV.style.left don't return a value. If I remove the DOCTYPE from the first line, it works fine and...
11
1928
by: Simon Shutter | last post by:
Forgive me if I am posting to wrong newsgroup and for a couple of loaded questions. First, from what I understand, one of the advantages of XHTML/CSS is the ability of screen readers/braille...
6
1462
by: Chris Botha | last post by:
I am porting an existing 2003 project to 2005. Yesterday I found that some of my Java script did not want to work. After eventually examining the HTML view of the new and old form for differences,...
6
2263
by: reynard | last post by:
I have a page that uses this doctype <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> but when I change to this: <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"...
2
6579
by: PapaRandy | last post by:
Hello, I am trying to validate the following .py webpage as HTML (through W3C). I put: ----------------------------------------------------------------------------- print "Content-type:...
15
5375
by: Lennart | last post by:
Hi folks, I have created an animated image gallery in dhtml. It works fine in Internet Explorer. In Firefox, it only works if I ommit the DOCTYPE tag. The page is valid xhtml-strict but with a...
0
3191
by: =?Utf-8?B?SGFyZHkgV2FuZw==?= | last post by:
Hi all, I have a web form, and I want to use ModalPopupExtender from Ajax Toolkit. I am using IE 7.0 as browser, VS 2005 and Ajax and Ajax Tool Kit installed. Windows XP Pro. Now I have a...
1
1687
by: rfr | last post by:
Apparently the Transitional Doctype kills this script because the script does not make proper use of units like "px". It works well without a doctype statement. But once someone adds a...
0
7002
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
1
6885
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
7379
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
5462
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
4908
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
4588
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3093
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
1417
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
0
290
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.