javascript - JSLint errors: Undeclared 'Image', Undeclared 'Document', out of scope -


with basic javascript knowledge built simple slideshow (code below). works jslint shows following errors:

  • undeclared 'image' slideimages[0] = new image();
  • undeclared 'setinterval' setinterval(mycounter, 50);
  • 'mycounter' out of scope setinterval(mycounter, 50);
  • undeclared 'document' document.getelementbyid('slide').src =slideimages[step].src;

how can overcome issues e.g. declare elements?

var slideimages = [];  slideimages[0] = new image(); slideimages[0].src = "http://placehold.it/350x150?text=welcome"; slideimages[1] = new image(); slideimages[1].src = "imgs/slide_1.png"; slideimages[2] = new image(); slideimages[2].src = "imgs/slide_2.png";   var step = 0;  var c = 0; var = 0; setinterval(mycounter, 50); function mycounter() {      'use strict';  document.getelementbyid('slide').src = slideimages[step].src;      if ((c >= 0) && (c < 40)) {         c += 1;         = c;         step = 1; document.getelementbyid("demo").innerhtml = / 100; document.getelementbyid("slide").style.opacity = / 40;      } else if ((c >= 40) && (c < 80)) {          c += 1;         = c; document.getelementbyid("demo").innerhtml = / 100; document.getelementbyid("slide").style.opacity = 1;      } else if ((c >= 80) && (c < 100)) {          c += 1;         = c; document.getelementbyid("demo").innerhtml = 1 - ((a - 80) / 20); document.getelementbyid("slide").style.opacity = 1 - ((a - 80) / 20);      } else if ((c >= 100) && (c < 140)) {          c += 1;         = c;         step = 2; document.getelementbyid("demo").innerhtml = / 100; document.getelementbyid("slide").style.opacity = (a - 100) / 40;      } else if ((c >= 140) && (c < 180)) {          c += 1;         = c; document.getelementbyid("demo").innerhtml = / 100; document.getelementbyid("slide").style.opacity = 1;      } else if ((c >= 180) && (c < 200)) {          c += 1;         = c; document.getelementbyid("demo").innerhtml = 1 - ((a - 180) / 20); document.getelementbyid("slide").style.opacity = 1 - ((a - 180) / 20);      } else {         c = 0;     } } 

lslint doesn't allow browser-related things default. thus,

undeclared 'image' slideimages[0] = new image(); undeclared 'setinterval' setinterval(mycounter, 50); undeclared 'document' document.getelementbyid('slide').src =slideimages[step].src; 

look @ jslint options, , assume browser in special.


Comments

Popular posts from this blog

sublimetext3 - what keyboard shortcut is to comment/uncomment for this script tag in sublime -

java - No use of nillable="0" in SOAP Webservice -

ubuntu - Laravel 5.2 quickstart guide gives Not Found Error -