javascript 座標 如何取得 e

2008-03-20 12:23 pm
<script language="javascript">
function gete(e){

if (navigator.appName != "Microsoft Internet Explorer"){

mouX = e.pageX;

}else{

mouX = event.clientX;

}

alert(mouX);

}
</script>

<a href="#" onclick="gete()">Show</a>

在 ie 下可顯示座標,但在firefox就不可,請問如何才可顯示 e.pageX

回答 (1)

2008-03-21 8:27 am
✔ 最佳答案
Change the code as follows:

<script language="javascript">
function gete(e) {
mouX = e.clientX;
alert(mouX);
}
</script>

<a href="#" onclick="gete(event)">Show</a>

The code works for both IE and Firefox. pageX is not supported in IE.


收錄日期: 2021-04-25 20:33:49
原文連結 [永久失效]:
https://hk.answers.yahoo.com/question/index?qid=20080320000051KK00369

檢視 Wayback Machine 備份