<html>
<head>
<script type="text/javascript">
function $(id)
{
return document.getElementById(id);
}
var TotalCount=10;
var pointCount=0;
function showPoint()
{
if(pointCount<TotalCount)
{
pointCount++;
var point=document.createElement("div");
point.style.backgroundColor="#000000";
point.style.position="absolute";
point.style.width="4px";
point.style.height="4px";
point.style.fontSize="0";
point.style.top=event.y;
point.style.left=event.x;
point.style.zIndex=100;
document.body.appendChild(point); var pointX=parseInt(event.x)-parseInt($("img1").style.left);
var pointY=parseInt(event.y)-parseInt($("img1").style.top);
$("sp1").innerHTML+="Point "+pointCount+" : "+"("+pointX+","+pointY+")<br/>";
}
}
</script>
</head>
<body>
<img id="img1" style="z-index:10;position:absolute;left:200px;top:100px;" onclick="showPoint()" src="a.jpg"/><br/>
<span id="sp1"></span>
</body>
</html>
<head>
<script type="text/javascript">
function $(id)
{
return document.getElementById(id);
}
var TotalCount=10;
var pointCount=0;
function showPoint()
{
if(pointCount<TotalCount)
{
pointCount++;
var point=document.createElement("div");
point.style.backgroundColor="#000000";
point.style.position="absolute";
point.style.width="4px";
point.style.height="4px";
point.style.fontSize="0";
point.style.top=event.y;
point.style.left=event.x;
point.style.zIndex=100;
document.body.appendChild(point); var pointX=parseInt(event.x)-parseInt($("img1").style.left);
var pointY=parseInt(event.y)-parseInt($("img1").style.top);
$("sp1").innerHTML+="Point "+pointCount+" : "+"("+pointX+","+pointY+")<br/>";
}
}
</script>
</head>
<body>
<img id="img1" style="z-index:10;position:absolute;left:200px;top:100px;" onclick="showPoint()" src="a.jpg"/><br/>
<span id="sp1"></span>
</body>
</html>
解决方案 »
- JavaScript验证数据
- (JS)div收缩的时候 子元素没有跟进(兼容问题)
- 只用一次的属性需要删除吗?
- JAVASCRIPT 如何输入的字符串判断是否是大于0的数字
- 请高手指点~~谢谢
- 如何写:一个JS的对话框,对话框里面有个文本框,一个确定按键
- document.getElementById(sid).style.display='none'的问题
- 紧急求助,有没有哪个兄弟实现过javascript里的异步啊
- windows自带控件DAcontrol怎么用啊?哪里可以找到详细资料?
- JS怎么去字符串两端空格
- 脚本定位问题---想了一个星期都没想出结果,请大虾指点
- 表单脚本的问题,在线等!
<html>
<head>
<script type="text/javascript">
function $(id)
{
return document.getElementById(id);
}
var TotalCount=10;
var pointCount=0;
function showPoint(event)
{
if(pointCount<TotalCount)
{
pointCount++;
var point=document.createElement("div");
point.style.backgroundColor="#000000";
point.style.position="absolute";
point.style.width="4px";
point.style.height="4px";
point.style.fontSize="0";
point.style.top=event.y?event.y:event.pageY;
point.style.left=event.x?event.x:event.pageX;
point.style.zIndex=100;
document.body.appendChild(point);
var pointX=parseInt(event.x?event.x:event.pageX)-parseInt($("img1").style.left);
var pointY=parseInt(event.y?event.y:event.pageY)-parseInt($("img1").style.top);
$("sp1").innerHTML+="Point "+pointCount+" : "+"("+pointX+","+pointY+")<br/>";
}
}
</script>
</head>
<body>
<img id="img1" style="z-index:10;position:absolute;left:200px;top:100px;" onclick="showPoint(event)" src="a.jpg"/><br/>
<span id="sp1"></span>
</body>
</html>