Markup Validation error in Javascript -


i getting error in markup validation:

warning line 23, column 23: character "<" first character of delimiter occurred data

for (var = 0; < array.length; i++) { 

is there wrong "<" character in following js?

function preloadimages(array) { if (!preloadimages.list) {     preloadimages.list = []; } (var = 0; < array.length; i++) {     var img = new image();     img.src = array[i];     preloadimages.list.push(img); } } 

it looks document xhtml , javascript inlined. @ least seem validating against xhtml. since xhtml rather strict , closer xml, < interpreted start of new tag , confused validator.

there number of ways fix this:

  • use html5 instead of xhtml; really, best choice unless have reason stick xhtml. understood major browsers , latest , modern doctype allows cool new features of web 2.0. doctype html5 looks this:

    <!doctype html> <html> .... 
  • don't inline javascript, add external resource. should doing time anyway, no matter doctype using:

    <script type="text/javascript" src="yourscript.js"></script> 
  • enclose script in cdata block:

    <script type="text/javascript"> <![cdata[     // code ]]> </script> 

you can read on doctypes , xhtml further details.


Comments

Popular posts from this blog

android - Get AccessToken using signpost OAuth without opening a browser (Two legged Oauth) -

org.mockito.exceptions.misusing.InvalidUseOfMatchersException: mockito -

google shop client API returns 400 bad request error while adding an item -