====== Mouse Cursor Position ======
document.compatMode
- Quirks mode[BACKCompat] : Standard-compliant mode is not switched on.
- Strict mode[CSS1Compat] : Standard-compliant mode is switched on.
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 de = document.documentElement;
var b = document.body;
cursor.x = e.clientX +
(de.scrollLeft || b.scrollLeft) - (de.clientLeft || 0);
cursor.y = e.clientY +
(de.scrollTop || b.scrollTop) - (de.clientTop || 0);
}
return cursor;
}
{{keywords> mouse cursor position change background color selected row}}
===== Test Sample =====
function TT_click(oR) {
var oT = oR.parentNode.parentNode; //Table node
if(oT.targetRec == oR) { //再度クリックすると色を消す
oR.style.backgroundColor = '';
oT.targetRec = false;
} else {
if(oT.targetRec)oT.targetRec.style.backgroundColor = '';
oR.style.backgroundColor = oT.currentBackgroundColor;
oT.targetRec = oR;
}
}
function TT(Tid,SetColor) {
var oT = document.getElementById(Tid);
if(! oT)return;
for(var i=0;i
===== Code sample =====