html - Why is my javascript code not running? canvas and javascript events -


My Javascript code is not running, but HTML is dragging the canvas ..... I add an event listener Trying on the Canvas HTML element, I click on the element which should give me a warning. Ive tried it on Firefox and Google Chrome.

  & lt; Script language = "javascript" type = "text / javascript" & gt; Warning ("yo"); Canvas.addEventListener ('click', function () {}, false); Var elem = document.getElementById ("checkersq"), elemLeft = elem.offsetLeft, elemTop = elem.offsetTop, reference = elem.getContext ('2d'), element = []; Elem.addEventListener ('click', function (event) {var x = event.pageX - elemLeft, y = event.pageY - elemTop; elements.for each (function (element) {if (y> element.top & Amp;; Y & lt; element.top + element.height and x> element.left and x & lt; element.left + element.width) {warning ('an element clicked' );}}}) ; }, false); Elements.push ({color: '# 05EFFF', width: 150, height: 200, top: 20, left: 15}); Element.forEach (function (element) {context.fillStyle = element.colour; context.fillRect (element.left, element.top, element.width, element.height);});   

convert

 }}); }, false);   

to

 }); }, false);    

Comments

Popular posts from this blog

excel vba - How to delete Solver(SOLVER.XLAM) code -

jsp - Google line chart x-axis shrinks on transition -

java - Reaching JTextField in a DocumentListener -