PDA

View Full Version : w3c validation service - error found



jmarian1
01-22-2011, 01:11 AM
1) Script Title: Cool DHTML Tooltip

2) Script URL (on DD): http://www.dynamicdrive.com/dynamicindex5/dhtmltooltip.htm

3) Describe problem:
Hi, I checked this site at http://validator.w3.org to validate our code and some of the error given are the scripts for the tooltip. I like this tooltip because of the nice feature of it based on our needs and looking on the code itself, it seems pretty valid. It's just that I don't know the reason why some of the syntax is not valid in the W3C validator. For example of the error from the validator are below with the reason. I hope you can help me how to fix it or give me insights how to fix it so our website will appear valid in w3c. Thanks in advance.


character X not allowed in attribute specification list

•Line 369, column 33: character ")" not allowed in attribute specification list
if (rightedge<tipobj.offsetWidth)•Line 372, column 23: character ")" not allowed in attribute specification list
else if (curX<leftedge)•Line 379, column 35: character ")" not allowed in attribute specification list
if (bottomedge<tipobj.offsetHeight)

end tag for X omitted, but OMITTAG NO was specified:

You may have neglected to close an element, or perhaps you meant to "self-close" an element, that is, ending it with "/>" instead of ">".
•Line 399, column 9: end tag for "tipobj.offsetHeight" omitted, but OMITTAG NO was specified
</script>•Line 399, column 9: end tag for "leftedge" omitted, but OMITTAG NO was specified
</script>•Line 399, column 9: end tag for "tipobj.offsetWidth" omitted, but OMITTAG NO was specified
</script>

element X undefined:
You have used the element named above in your document, but the document type you are using does not define an element of that name. This error is often caused by:

•incorrect use of the "Strict" document type with a document that uses frames (e.g. you must use the "Frameset" document type to get the "<frameset>" element),
•by using vendor proprietary extensions such as "<spacer>" or "<marquee>" (this is usually fixed by using CSS to achieve the desired effect instead).
•by using upper-case tags in XHTML (in XHTML attributes and elements must be all lower-case).
•Line 369, column 33: element "tipobj.offsetWidth" undefined
if (rightedge<tipobj.offsetWidth)•Line 372, column 23: element "leftedge" undefined
else if (curX<leftedge)•Line 379, column 35: element "tipobj.offsetHeight" undefined
if (bottomedge<tipobj.offsetHeight)•Line 431, column 11: element "center" undefined
<p><center>•Line 436, column 267: element "embed" undefined
…rsion=3" type="application/x-shockwave-flash" height="100" width="100"></embed>



character X is the first character of a delimiter but occurred as data

This message may appear in several cases:

•You tried to include the "<" character in your page: you should escape it as "&lt;"
•You used an unescaped ampersand "&": this may be valid in some contexts, but it is recommended to use "&amp;", which is always safe.
•Another possibility is that you forgot to close quotes in a previous tag.
•Line 339, column 33: character "&" is the first character of a delimiter but occurred as data
var ns6=document.getElementById && !document.all;•Line 339, column 34: character "&" is the first character of a delimiter but occurred as data
var ns6=document.getElementById && !document.all;•Line 345, column 29: character "&" is the first character of a delimiter but occurred as data
return (document.compatMode && document.compatMode!="BackCompat")? document.doc…•Line 345, column 30: character "&" is the first character of a delimiter but occurred as data
return (document.compatMode && document.compatMode!="BackCompat")? document.doc…•Line 351, column 34: character "&" is the first character of a delimiter but occurred as data
if (typeof thecolor!="undefined" && thecolor!="") tipobj.style.backgroundColor=…•Line 351, column 35: character "&" is the first character of a delimiter but occurred as data
if (typeof thecolor!="undefined" && thecolor!="") tipobj.style.backgroundColor=…•Line 363, column 17: character "&" is the first character of a delimiter but occurred as data
var rightedge=ie&&!window.opera? ietruebody().clientWidth-event.clientX-offsetx…•Line 363, column 18: character "&" is the first character of a delimiter but occurred as data
var rightedge=ie&&!window.opera? ietruebody().clientWidth-event.clientX-offsetx…•Line 364, column 18: character "&" is the first character of a delimiter but occurred as data
var bottomedge=ie&&!window.opera? ietruebody().clientHeight-event.clientY-offse…•Line 364, column 19: character "&" is the first character of a delimiter but occurred as data
var bottomedge=ie&&!window.opera? ietruebody().clientHeight-event.clientY-offse…•Line 366, column 27: character "<" is the first character of a delimiter but occurred as data
var leftedge=(offsetxpoint<0)? offsetxpoint*(-1) : -1000

traq
01-22-2011, 02:11 AM
javascript does not validate as html. it never will.

there are three possible courses of action:

1) do nothing. it doesn't really matter as long as everything works - js causing html validation errors is nothing to be concerned about.

2) mark the script code as character data.
<![CDATA[ ...javascript goes here... ]]> this tells the browser (and validation service) that the script is not html, and should be ignored by the html parser (validator). Seems ideal, yeah? but it's really a pain. it adds all kinds of markup, usually in conjunction with weird commenting syntax //<!--<![CDATA[ //]/>--> (don't use that, it's complete gibberish, not a correct example). I've never been satisfied with attempting this. it always causes more headaches (for me) than it cures.

3) the best option is to remove your scripts from the markup of your html page. If your page validates without javascript, you're fine. pull your javascript from external files.
<script src="path/to/javascript.js"> /* no problems : ) */ </script>