在javaScript里添加鼠标事件获得经纬度,怎么让他显示在文本框里呢
1个回答
展开全部
<script type="text/javascript">
window.onload = function() {
var mousex = 0;
var mousey = 0;
document.onmousemove = function(e) {
if(document.all) {
mousex = event.clientX + document.body.scrollLeft;
mousey = event.clientY + document.body.scrollTop;
}
else {
mousex = e.pageX;
mousey = e.pageY;
}
document.getElementById('mousex').value = mousex;
document.getElementById('mousey').value = mousey;
};
};
</script>
X: <input id="mousex" type="text" value="" />
Y: <input id="mousey" type="text" value="" />
window.onload = function() {
var mousex = 0;
var mousey = 0;
document.onmousemove = function(e) {
if(document.all) {
mousex = event.clientX + document.body.scrollLeft;
mousey = event.clientY + document.body.scrollTop;
}
else {
mousex = e.pageX;
mousey = e.pageY;
}
document.getElementById('mousex').value = mousex;
document.getElementById('mousey').value = mousey;
};
};
</script>
X: <input id="mousex" type="text" value="" />
Y: <input id="mousey" type="text" value="" />
本回答被提问者采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询