Uncaught TypeError?

Recommend this page to a friend!

      dollar B  >  All threads  >  Uncaught TypeError?  >  (Un) Subscribe thread alerts  
Subject:Uncaught TypeError?
Summary:Uncaught TypeError: Cannot read property 'clientY' of undefined
Messages:4
Author:Travis Jones
Date:2015-08-09 06:18:47
 

  1. Uncaught TypeError?   Reply   Report abuse  
Picture of Travis Jones Travis Jones - 2015-08-09 06:18:48
I have this before the closing body tag:
<script type="text/javascript" src="dollarB.js"></script>
<script type="text/javascript" src="main.js"></script>

and this in the main.js file:
console.log("Mouse Y"+$B.mouseY());
console.log("Mouse X"+$B.mouseX());

Can someone help?

Thanks for your time :)

  2. Re: Uncaught TypeError?   Reply   Report abuse  
Picture of Stephen Chapman Stephen Chapman - 2015-08-09 19:11:38 - In reply to message 1 from Travis Jones
You can only get the mouse position when an event is triggered. As you haven't triggered an event in that code there is no event to get the mouse position of.

  3. Re: Uncaught TypeError?   Reply   Report abuse  
Picture of Stephen Chapman Stephen Chapman - 2015-08-09 19:16:27 - In reply to message 2 from Stephen Chapman
For example:

window.onmousemove = function(evt) {
console.log("Mouse Y"+$B.mouseY(evt));
console.log("Mouse X"+$B.mouseX(evt));
}

  4. Re: Uncaught TypeError?   Reply   Report abuse  
Picture of Travis Jones Travis Jones - 2015-08-09 20:00:27 - In reply to message 3 from Stephen Chapman
Ohhh I can't believe I didn't notice that! :\ Thanks for the quick reply! :)