Unfortunately there is no way to retrieve the location of the mouse cursor outside of an event handler. One option do you have is to register an event handler for the onmousemove event and store the coordinates in a global(ish) variable.
Using plain old javascript the following code should do the trick for Safari and FF3.
var coords = {x: NaN, y: NaN};
...
if (coords.x === ... && coords.y === ...) {
/* insert your magic here */
}
...
window.addEventListener('mousemove', function(e) {
coords.x = e.clientX;
coords.y = e.clientY;
}, true);
In short, an event listener (handler) is registered for the "onmousemove" event. When the event fires the anonymous function is called with the event. The event contains several properties, two of which are clientX and clientY. These are the coordinates of the mouse relative to the window, not the top of the document. These coordinates are placed in a variable that is accessible to both the handler and the code that needs the coordinates. This could be a global or a closed-over variable of some kind.
I should note that typically javascript implementations within the browsers are single-threaded. Simply put this means that the values contained in the coords
variable may not always be up to date if the mouse has moved since the last time the event handler was called.