xhtml strict javascript problem trying to use "id" in plane of "name" attribute

Do you have a question? Post it now! No Registration Necessary.  Now with pictures!

Threaded View
I have tried to resolve this in several ways that I have found on the
internet, but none seems to work. Here is the shortened code which is
a website displaying a webcam. The .jpg is overwritten with new image
from the camera. This code works, but does not pass  W3C XHTML

1) How can I keep this working, and change the attribute to "id" so is
passes STRICT?
2) While I'm asking questions, what purpose does the "//" in the   //<!
[CDATA[   line perform? When I read the spec (http://www.w3.org/TR /
xhtml1/) it only says to use   <![CDATA[    ?

MY CODE ***************************************

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
        "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd ">
<html xmlns="http://www.w3.org/1999/xhtml " lang="en" xml:lang="en">
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<script type="text/javascript">

        function refreshIMG()

                var trimmedPath=new Array();

                var currentPath=document.image3.src;
                document.image3.src = trimmedPath[0] + "?" +

                setTimeout("refreshIMG()", 8*1000);


<body onload="refreshIMG()">
                <img class="cam" src="images/cam_3.jpg" width="320"
height="240" name="image3" alt="Image loading ..." id="image3" />

Re: xhtml strict javascript problem trying to use "id" in plane of "name" attribute

On Tue, 28 Aug 2007 00:07:27 -0000, meyazoo@gmail.com wrote:

Quoted text here. Click to load it

The 'id' is fine.  The validator doesn't like 'name.'

Quoted text here. Click to load it

There's an explanation here: <http://en.wikipedia.org/wiki/CDATA .

You may find that 'HTML 4.01 strict' is more suited to your needs.
Martin Jay

Re: xhtml strict javascript problem trying to use "id" in plane of "name" attribute

On Aug 27, 7:07 pm, meya...@gmail.com wrote:
Quoted text here. Click to load it

CDATA is an xml thing. Xhtml is a hybrid that handles both html and
xml. Javascript often contains some things that are not allowed in
xml. Thus if you serve the xhtml properly as application/xhtml+xml,
the page is parsed as xml and you get an error message rather than
viewing the page if the script contains things that are forbidden in
xml. Enclosing the script in the open and close CDATA tags tells the
xhtml parser not to check the enclosed section for xml errors, since
it is something other than xhtml. You can avoid all of this be using
an external script in the manner usual for html. Notice the // before
the opening and closing CDATA tags. If you serve the xhtml page
improperly as html, these // are javascript comment tags which mean
that the CData tags are not seen. However if the xhtml page is
properly served as application/xhtml+xml, the browser sees right
through the // to find the CDATA tags and understands what such xml
tags mean. This is fortunate, because most xhtml pages are mis-served
as html rather than application/xhtml+xml. If you have the bare CDATA
tags without // on an xhtml page so mis-served the script will not
work, since a parser for html does not know what they mean.
If you serve an xhtml correctly as application/xhtml+xml, the page can
not be viewed by any IE browser, and will have to resort to some
tricks to get a html page to IE browsers. Most other modern browsers
understand properly served xhtml. I would guess that well over 90% of
pages written in xhtml are not being served as application/xhtml+xml.
In that case the xhtml code serves no useful purpose over html, and
the page would be better written in html 4.01 strict.

Site Timeline