Shakashi
Shakashi

Reputation: 13

HTML validation / script JS

I'm having a little problem to validate a html page with a js script.

i have this js part : " .

var lastPage = this.getNumPages() - 1;

if (this.displayedPage < lastPage)

nextPageLink.css('visibility', 'visible');

Everything works fine but i have 1 error remaining when i try to validate it:

Line 856, Column 30: character is the first character of a delimiter but occurred as data if (this.displayedPage < lastPage)

✉ This message may appear in several cases: You tried to include the "<" character in your page: you should escape it as "<" You used an unescaped ampersand "&": this may be valid in some contexts, but it is recommended to use "&", which is always safe. Another possibility is that you forgot to close quotes in a previous tag.

Line 856, Column 30: StartTag: invalid element name if (this.displayedPage < lastPage)

I just want a way to replace the < sign with something that works whit my script and will pass the W3C validation.

Upvotes: 1

Views: 327

Answers (2)

Kylos
Kylos

Reputation: 1938

You need to declare your JavaScript as cdata. The < symbol is interpreted as part of a tag, causing the error.

When is a CDATA section necessary within a script tag?

Upvotes: 2

qw3n
qw3n

Reputation: 6334

You could use <script type="text/javascript" src=""></script> to load your javascript file instead of putting it in your htmle file.

Upvotes: 1

Related Questions