■マウスの座標を表示する

座標はオブジェクトに座標が明示的に指定されていないと出力されないようである。
具体的には position:absolute; top:xx; left:xx; の指定をしている。


■虎の絵の座標を表示する



■ブラウザのオブジェクトの認識

ブラウザ種別 document.all document.getElementById document.layers
IE5.5 object function getElementById() { [native code] } undefined
NN4.75 undefined undefined object LayerArray
NN4.78 undefined undefined object LayerArray
NN6.2 undefined function getElementById() { [native code] } undefined
IE4 たぶん○ たぶん× たぶん×


■イベントの登録方法

ブラウザ種別イベントの登録方法
IE5.5document.onmousedown = function
NN4.75window.onmousedown = function
window.captureEvents(Event.MOUSEMOVE)
NN4.78window.onmousedown = function
window.captureEvents(Event.MOUSEMOVE)
NN6.2window.document.onmousedown = function
IE4document.onmousedown = function

■マウス座標の取得方法

ブラウザ種別マウス座標の取得方法
IE5.5event.x + document.body.scrollLeft *0 *2
NN4.75evt.pageX or evt.x *1
NN4.78evt.pageX or evt.x *1
NN6.2evt.pageX *1
IE4window.event.clientX + document.body.scrollLeft *0
*0: Windowのスクロールを考慮し、document.body.scrollLeftを足し込む。 *1: 'evt'は、functionの引数として指定した変数名。
*2: window.event.clientX でも可。


■オブジェクトの座標の取得・設定方法

ブラウザ種別取得方法設定方法
IE5.5document.all[オブジェクト名].style.leftdocument.getElementById(オブジェクト名).style.left *1
NN4.75document.layers[オブジェクト名].leftdocument.layers[オブジェクト名].left
NN4.78document.layers[オブジェクト名].leftdocument.layers[オブジェクト名].left
NN6.2document.getElementById(オブジェクト名).style.leftdocument.getElementById(オブジェクト名).style.left
IE4 document.all[オブジェクト名].style.left
*1:IE4と同じくdocument.all[オブジェクト名].style.leftでも可。

参考:

Cross Browser DHTML Reference
Working with Javascript

Javascript debug console for NN