Advertisement
Guest User

Untitled

a guest
Jun 23rd, 2013
64
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. Pomocí <img src=... onMouseOver='getMousePos(this, myFunction)'> chci spustit tuto funkci, ale hlásí mi to chybu
  2.  
  3. [pre]
  4.   var getMousePos = function (that, myFunction = Null){
  5.     var imgWidth = $(that).width();
  6.     var imgHeight = $(that).height();
  7.     var imgPosition = $(that).position();
  8.     imgPosition.left = Math.round(imgPosition.left);
  9.     imgPosition.right = imgPosition.left + imgWidth;
  10.     imgPosition.top = Math.round(imgPosition.top);
  11.     imgPosition.bottom = imgPosition.top + imgHeight;    
  12.     console.log(imgPosition);
  13.     if ( mousePos.x > imgPosition.left &&
  14.          mousePos.x < imgPosition.right &&
  15.          mousePos.y > imgPosition.top &&
  16.          mousePos.y < imgPosition.bottom
  17.         )
  18.        {
  19.        console.log("You clicked in the image");
  20.        if ( myFunction )
  21.          {
  22.          return myFunction();
  23.          }    
  24.       }
  25.   }
  26. [/pre]
  27.  
  28. Nevíte co je špatně?
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement