html - Javascript "onmousemove()" works in Chrome but not in Firefox -


i tried googling couldn't find solutions.

the 4 towers @ bottom supposed display different images (less transparent) when mouse on them. works in google chrome not in firefox.

here's website: http://cdelphinus.com/test/mormontowerdefense.html (you can right click->view source) entire code(app.js)

here's problem code:

in html:

<canvas id="canvas_one" width="1160" height="580" style="border:2px solid yellow;          background-color:black; padding-left:0;margin-left:0;" onmousemove="lolol(event)"    onclick="haha(event)"></canvas> 

in app.js file:

here's condensed version of problem, works in chrome not firefox:

//function lolol(event) { //  event = event || window.event; //      alert(event.x); //} 

i have feeling once alert above shows in firefox rest fixed magically.

here's more detailed version of stuff going on

function lolol(event) { event = event || window.event; ix = event.x - canvas.offsetleft + 10;   iy = event.y- canvas.offsettop  + document.body.scrolltop; //... if(iy > 510) {     var dist = math.round(ix / 50) - 1;     if(dist < towerpurchaseoptions.length){     towerpurchaseoptions[dist].isactive = true;     //textout(towerpurchaseoptions[dist].name);      for(var i=0; i<towerpurchaseoptions.length; i++) {          if(i != dist) {     towerpurchaseoptions[i].isactive = false;          }      } }   } //.... } 

if towerpurchaseoptions[n].isactive == true, image replaced less-transparent image

i checked problem because of

function lolol(event) {      event = event || window.event; //for ie      ix = event.x - canvas.offsetleft + 10; 

//here ix ruturning nan

    iy = event.y- canvas.offsettop  + document.body.scrolltop; 

//here iy ruturning nan

so why this? because event not have propery .x in firefox may problem can change

 function lolol(event) {          event = event || window.event; //for ie          ix = event.clientx - canvas.offsetleft + 10;           iy = event.clienty- canvas.offsettop  + document.body.scrolltop; 

and work thanks.


Comments

Popular posts from this blog

javascript - RequestAnimationFrame not working when exiting fullscreen switching space on Safari -

Python ctypes access violation with const pointer arguments -