我寫了一段code想讓鼠標移到某些字時讓div tag出現在該字的下方
在IE裡可以跑了,不過FF不行,不知道是不是event.clientx的問題?有人遇過這種問題嗎,謝謝大家
範例:http://joehwang.myweb.hinet.net/1.htm
代碼:
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=big5" />
<title>test</title>
<style type="text/css">
<!--
.popwin {
font-family: Arial, Helvetica, sans-serif;
position: absolute;
top: 0px;
right: 0px;
border: 2pt solid #FFFFFF;
background-color: #FFFBF0;
font-size: 10pt;
height: 100px;
width: 100px;
}
-->
</style>
</head>
<script>
//單字pop程式
function popword(e){//設定出現的位置
//document.getElementById("popwin").style.left=(window.event.offsetX)+150;
//document.getElementById("popwin").style.top=(window.event.offsetY)+40;
document.getElementById("popwin").style.left=event.clientX+document.body.scrollLeft+10;
document.getElementById("popwin").style.top=event.clientY+document.body.scrollTop+10;
}
function popstart(a,b,c){//帶入中文、詞性、單字,啟動單字pop
document.getElementById("popwin").style.display="block";
document.getElementById("popwin").innerHTML="<div class=poptop>"+c+"</div><div class=popdown>"+a+b+"</div>";
document.onmousemove=popword;
}
function popclose(){//關掉單字pop
document.getElementById("popwin").style.display="None"
}
//單字pop結束
</script>
<body>
<p> </p>
<p> </p>
<p align="center"><a onMouseOver="popstart('test','test','test')" onmouseout="popclose()">點我</a></p>
<span id="popwin" class="popwin"></span>
</body>
</html>