Now should work in any modern browser, including IE 8:
Code:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Cursor Direction Demo</title>
<script type="text/javascript">
/* <![CDATA[ */
//Cursor Direction
//Move mouse to see the cursor direction
;(function(){
document.documentElement.style.height = '100%';
var cursors = ['e-resize', 'n-resize', 'sw-resize', 'se-resize'], x1, y1, x2, y2, x3, y3;
x2 = y2 = 0;
function changecursor(index) {
document.documentElement.style.cursor = cursors[index];
}
function directcursor(e) {
e = e || event;
x1 = e.clientX;
y1 = e.clientY;
x3 = x1 - x2;
y3 = y1 - y2;
if (x3 > 2 && y3 > 2 || x3 < -2 && y3 < -2) {changecursor(3);}
else if (Math.abs(x3) > 2 && Math.abs(y3) > 2) {changecursor(2);}
else if (x3 < 2 && Math.abs(y3) > 2) {changecursor(1);}
else if (Math.abs(x3) > 2 && y3 < 2) {changecursor(0);}
x2 = x1;
y2 = y1;
}
document.onmousemove = directcursor;
})();
/* ]]> */
</script>
</head>
<body>
</body>
</html>
Bookmarks