答案 0 :(得分:0)
打开你的控制台,你会看到:
未捕获的TypeError:无法读取未定义的属性“MouseX”
您的javascript代码中的line 33
似乎document.Show
为undefined
。
document.Show.MouseX.value = tempX;
当你click
时,你得到了这个:
未捕获的TypeError:无法读取null的属性'style'
line 52
mark
null
为<div id="map" onclick="
mark.style.left = tempX + 'px';
mark.style.top = tempY + 'px';
">
<div id="mark"></div>
:
<script>
您可以将整个</body>
标记向下移动到底部,将其放在收尾的document.getElementById('mark');
标记内,以便<body>
<div id="map" onclick="
mark.style.left = tempX + 'px';
mark.style.top = tempY + 'px';
">
<div id="mark"></div>
</div>
<script type="text/javascript">
<!--
var IE = document.all?true:false;
if (!IE) document.captureEvents(Event.MOUSEMOVE)
document.onmousemove = getMouseXY;
var mark = document.getElementById('mark');
var tempX = 0;
var tempY = 0;
function getMouseXY(e) {
if (IE) { // grab the x-y pos.s if browser is IE
tempX = event.clientX + document.body.scrollLeft;
tempY = event.clientY + document.body.scrollTop;
}
else { // grab the x-y pos.s if browser is NS
tempX = e.pageX;
tempY = e.pageY;
}
if (tempX < 0){tempX = 0;}
if (tempY < 0){tempY = 0;}
document.Show.MouseX.value = tempX;
document.Show.MouseY.value = tempY;
return true;
}
//-->
</script>
</body>
找到该元素。
像这样:
{{1}}