Script Error Checking

For general web development questions that are not specifically related to CSS HTML Validator. This includes (but is not limited to) general HTML, CSS, Accessibility, JavaScript, and SEO questions.
Post Reply
paulp575
Rank IV - Intermediate
Posts: 170
Joined: Tue Aug 09, 2005 1:20 pm
Location: Spokane WA
Contact:

Script Error Checking

Post by paulp575 »

I keep getting an error about not using '<!--' and '-->' in scripts (to keep older browsers from viewing the contents of the script rather than running the script).

Problem is, on some scripts, if I insert that code, the script no longer runs!!!
Is there a way to avoid this - I don't write the scripts, so changing the scripts is above my head!

Thanks,
User avatar
Albert Wiersch
Site Admin
Posts: 3783
Joined: Sat Dec 11, 2004 9:23 am
Location: Near Dallas, TX
Contact:

Post by Albert Wiersch »

Hello,

In XHTML, you shouldn't surround scripts and styles (in the "style" element) with comment markers because they could (and should) be ignored by the browser/agent, but you should be able to in HTML, so it depends on the DOCTYPE.

If you want to simply not use comment markers at all, then you can always disable that validator message by right-clicking on it when it apepars in the Results Window and choosing Options for this Message->Disable Message.

I should probably remove that message by default in v8.0 because most people today don't use such old browsers where not using comment markers would be an issue.
Albert Wiersch, CSS HTML Validator Developer • Download CSS HTML Validator FREE Trial
thenitbit
Rank 0 - Newcomer
Posts: 6
Joined: Wed Oct 11, 2006 12:16 am

Re: Script Error Checking

Post by thenitbit »

paulp575 wrote:I keep getting an error about not using '<!--' and '-->' in scripts (to keep older browsers from viewing the contents of the script rather than running the script).

Problem is, on some scripts, if I insert that code, the script no longer runs!!!
Is there a way to avoid this - I don't write the scripts, so changing the scripts is above my head!

Thanks,
Hi Paul,

I got the same problem earlier, until I realised that comment markers can change a script into a comment when coded on the same line.
Make sure you insert a line break after '<!--' and one before '-->' and everything works fine!

Regards,
Alfred Vorsselman, the Netherlands.
Post Reply