Js——elementFromPoint方法
生活随笔
收集整理的這篇文章主要介紹了
Js——elementFromPoint方法
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
src:http://www.aspxuexi.com/html/dhtml/2007-8-30/elementFromPoint.htm
語法:
oElement = document . elementFromPoint ( iX , iY )
參數:
iX : 必選項。整數(Integer)。單位:象素(Pixel)。定位橫坐標偏移量。
iY : 必選項。整數(Integer)。單位:象素(Pixel)。定位縱坐標偏移量。
返回值:
oElement : 對象(Element)。返回獲取的對象的引用。
說明:
根據橫縱坐標值 iX 和 iY 獲取對象 oElement 。 oElement 必須支持和響應鼠標事件。
提供的坐標是客戶區坐標。客戶區的左上角為 (0,0)。
當將此方法用于 Structured Graphics 或 Sprite 對象時,必須設置 MouseEventsEnabled 屬性值為 1 。
語法:
oElement = document . elementFromPoint ( iX , iY )
參數:
iX : 必選項。整數(Integer)。單位:象素(Pixel)。定位橫坐標偏移量。
iY : 必選項。整數(Integer)。單位:象素(Pixel)。定位縱坐標偏移量。
返回值:
oElement : 對象(Element)。返回獲取的對象的引用。
說明:
根據橫縱坐標值 iX 和 iY 獲取對象 oElement 。 oElement 必須支持和響應鼠標事件。
提供的坐標是客戶區坐標。客戶區的左上角為 (0,0)。
當將此方法用于 Structured Graphics 或 Sprite 對象時,必須設置 MouseEventsEnabled 屬性值為 1 。
示例:(www.aspxuexi.com)
<script>
function rdl_eventHandle(e){
event.cancelBubble=true;
var oPoint=document.elementFromPoint(event.clientX,event.clientY);
if (oPoint.tagName.toLowerCase()!="li") oCode.innerHTML="請將鼠標移動到項目列表上。";
else oCode.innerHTML="您的鼠標指針現在位于<font color='#FF3300'>"+oPoint.innerText+"</font>上面";
}
document.οnmοuseοver=rdl_eventHandle;
</script>
<ul id=oList style="cursor:default;">
<li>列表項目1
<li>列表項目2
<li>列表項目3
<li>列表項目4
</ul>
<br><div id=oCode>請將鼠標移動到項目列表上。</div>
轉載于:https://www.cnblogs.com/htht66/archive/2007/10/03/913443.html
總結
以上是生活随笔為你收集整理的Js——elementFromPoint方法的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 代码检查与代码走查
- 下一篇: win10大文件无法移动到U盘