日期:2014-05-16  浏览次数:20469 次

请问当鼠标移动到曲线时,怎样知道鼠标在曲线上面? 怎样取得曲线的坐标?
我用如下程序画曲线,曲线出来后,我想当鼠标移动到曲线上,就感知到就鼠标在曲线上面,同时可以显示曲线的坐标.   请问怎样实现?

function   drawCanvas()
{
var   arr   =   eval(req.responseText);
            var   x1   =   arr[0];
var   y1   =   arr[1];
if(!Working){
document.getElementById( "show ").style.display= "none ";
Working=true;
lastPoint.x   =   x1;
lastPoint.y   =   y1;
points.push(   {x:x1,y:y1}   );

}else{
var   s= ' <v:line   from= " '+lastPoint.x+ ', '+lastPoint.y+ ' "   to= " '+x1+ ', '+y1+ ' "   style= "color:red;position:absolute;left:0px;top:0px; "> </v:line> ';
//var   s= ' <v:line   strokecolor= "#5af85a "   from= " '+lastPoint.x+ ', '+lastPoint.y+ ' "   to= " '+x1+ ', '+y1+ ' "   style= "color:red;position:absolute;left:0px;top:0px; "> </v:line> ';
lastPoint.x   =   x1;
lastPoint.y   =   y1;
points.push(   {x:x1,y:y1}   );

var   o=document.createElement(s);
document.body.insertAdjacentElement( 'BeforeEnd ',o);
}
//window.scrollTo(document.body.scrollWidth,0);
document.body.scrollLeft     =     document.body.scrollWidth;  
}


</script>

------解决方案--------------------
v:line 就是正常的对象了,可能有事件的
------解决方案--------------------
触发时间的时候你在去获取鼠标坐标

o.onmouseover = function(){aaa();alert(window.event.clientX + ", " + window.event.clientY)}