SitePoint Sponsor |
|
User Tag List
Results 1 to 3 of 3
-
Jun 28, 2009, 01:25 #1
xhtml validation problems with javascript
Hi,
I'm currently customising shopping cart software which contains some javascript. I'm replacing the old table based layout with my own xhtml/css design.
Some of the validation errors are in the javascript, which I know nothing about. When I try to fix these problems it completely stops the site from working!
Here are a couple of examples:
for(i=0; i< state_id_array.length; i+=1)
The validator complains about the unencoded < (<symbol. However,replacing this with < or even I found one web site that said %26lt%3B was the same.
The other link is:
" if (!country_id) return; //Empty option, like \"--- Select a Country ---\"". "\n".
The validator tells me:
invalid comment declaration: found name character outside comment but inside comment declaration
I've found an article that explains the -- must be in pairs - but everything I've tried seems to just completely break the site.
Thanks for any help!
-
Jun 28, 2009, 01:53 #2
From reading this article:
http://javascript.about.com/library/blxhtml.htm
it seems that the shopping cart is using a very old technique of using html commenting rather than the CDATA tag. Unfortunately I'm a bit worried about breaking something, as the start, content and end tags of the javascript seems to be spread over multiple files.
Presumably this old technique of inserting javascript into the pages is the underlying cause of my validation problems?
-
Jun 28, 2009, 12:50 #3
- Join Date
- Jun 2009
- Location
- Ottawa, Ontario, Canada
- Posts
- 120
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
The usual approach is to put the javascript functions in a separate file. That should work for you in this situation as the problems don't seem to be caused by function calls. There are probably other ways to do it but this is likely the easiest...
Last edited by floater; Jun 28, 2009 at 12:51. Reason: No clarity of thought...
Bookmarks