構文 | | ・Internet Explorer event.offsetX |
| |
説明
- イベントが発生した要素上のX座標の位置を値に持つプロパティ。
- Internet Explorer独自のプロパティのため,Mozilla系ブラウザは対応していない。Mozilla系ブラウザ,Internet Explorer両方の用法をサポートしているOpera,Safariは,対応している。
用例
ブラウザ上でマウス・ボタンが押し下げられたときをイベントとしてとらえ,イベントのタイプとイベントが発生した要素上のX座標の値をアラート・ダイアログ・ボックスに表示する。
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html><head>
<meta http-equiv="Content-Script-Type" content="text/javascript">
<meta http-equiv="Content-Style-Type" content="text/css">
<title>offsetX_InternetExplorer</title>
<script type="text/javascript">
<!--
function eve() {
alert ( "イベントのタイプ:" + event.type + "\n" +
"イベントが発生した要素上のX座標:" + event.offsetX );
return true;
}
document.onmousedown = eve;
//-->
</script>
<style type="text/css">
<!--
body { background-color: #ffffff; }
-->
</style>
</head>
<body>
*イベントが発生した要素上のX座標
<div id='STY' name='STY' style='position:absolute;left:50px;
top:100px;width:250px;height:150px;background:Tan'>
div要素...
</div>
</body></html>
この用例を実行する