Xhtml Validation - hiding javascript content behind comments

I would like to know what is considered the correct approach to dealing with dynamically created javascript content with regards to xhtml validation (see attached code).

The two major errors i get (when not using comments) are of the form  "doc type doesnt allow div here..." and/or "having an illegal character in a script section 'i.e. <' ".  I have tried following the advise it offers but this doesnt solve the problem. For instance it recommends escaping the less than sign which is used as an operator and as such breaks the code.

Please see page: http://nuweb.northumbria.ac.uk/fashion/golfbook/nationalscore.php

Validation result (http://validator.w3.org/check?uri=http%3A%2F%2Fnuweb.northumbria.ac.uk%2Ffashion%2Fgolfbook%2Fnationalscore.php&charset=%28detect+automatically%29&doctype=Inline&group=0&user-agent=W3C_Validator%2F1.767)

I worry that by commenting out the javascript that im effectively removing the main content from the eyes of the search engine and hence falling in rankings etc.

Regards
Easynow
Place the javascript code between html comments tags, as so:

<script type="text/javascript">
<!--
var ar1 = new Array();

..

-->
</script>

Open in new window

LVL 12
Dean OBrienAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

exalkoniumCommented:
Replace the old comment style with CDATA tags
<script type="text/javascript">
/* <![CDATA[ */

var ar1 = new Array();

/* ]]> */
</script>

Open in new window

0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
i-CONICACommented:
Correct, CDATA islands are the way to go. Regarding search engines, if the content is rendered onto the DOM by Javascript, Javascript isn't processed by search engines so won't be indexed anyway. Google I know for one are starting to increase support for Javascript crawling (think of the enormous CPU overheads are their end), also processing AJAX (indexing more Facebook content for example) is the way it's going. But historically, JS wasn't and mostly still isn't processed.

It's important content, have server side scripts do the work where possible...
0
Dean OBrienAuthor Commented:
Thanks for the comments guys.

Easynow
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Software

From novice to tech pro — start learning today.