views:

31

answers:

2

IE6 is getting to be pain but it still makes up (apparently) a good chunk of the browser market share, so I need to make this work.

 function getPosition(e)
    {
    e = e || window.event;
    var cursor = {x:0, y:0};
    if (e.pageX || e.pageY)
    {
    cursor.x = e.pageX;
    cursor.y = e.pageY;
    }
else
{
var dex = document.documentElement;
var b = document.body;
cursor.x = e.clientX + (dex.scrollLeft || b.scrollLeft) - (dex.clientLeft || 0);
cursor.y = e.clientY + (dex.scrollTop || b.scrollTop) - (dex.clientTop || 0);
}
return cursor;
}

function outCursor(e){
  var curPos = getPosition(e);
alert(curPos);
}

window.captureEvents(Event.MOUSEMOVE);


    window.onmousemove = outCursor;

IE is complaining about the Event in window.captureEvents(Event.MOUSEMOVE);

'Event' is undefined.

A: 

I think ie6 doesn't supports captureEvents. So try

if (window.captureEvents) {
 window.captureEvents(Event.MOUSEMOVE);
}
KooiInc
so is there no equivalence to captureEvents in IE6 ?
gahza
Well, window.onmousemove (or better: document.onmousemove) is the IE equivalent. By the way, if you want the function 'outCursor' to be workable, don't use alert (you could use defaultStatus = curPos)
KooiInc
A: 

Try running the script without window.captureEvents(Event.MOUSEMOVE);. I don't think it is necessary. Also, like someone mentioned change the window.onmousemove to document.onmousemove

Also here is a good resource on writing this kind of script http://www.quirksmode.org/js/events_properties.html#position

qw3n