以文本方式查看主题

-  计算机科学论坛  (http://bbs.xml.org.cn/index.asp)
--  『 SVG/GML/VRML/X3D/XAML 』  (http://bbs.xml.org.cn/list.asp?boardid=21)
----  如何获取鼠标所在位置的坐标  (http://bbs.xml.org.cn/dispbbs.asp?boardid=21&rootid=&id=67389)


--  作者:hfutzhu
--  发布时间:9/18/2008 12:25:00 PM

--  如何获取鼠标所在位置的坐标
如题!如何获取鼠标所在位置的坐标!
--  作者:hfutzhu
--  发布时间:9/18/2008 12:25:00 PM

--  
不点击svg图片!!!!
--  作者:Qr
--  发布时间:9/18/2008 3:10:00 PM

--  
这个好象只适用于ASV,
<svg width="400" height="400" onmousemove="mousePos(evt)">

<script><![CDATA[

function mousePos(evt)

{

cx=evt.clientX;cy=evt.clientY;

sx=evt.getScreenX();sy=evt.getScreenY();

root=evt.target.ownerDocument;

root.getElementById("pos1").firstChild.setData("Client: "+cx+" "+cy);

root.getElementById("pos2").firstChild.setData("Screen: "+sx+" "+sy)

}

]]></script>

<rect x="0" y="0" width="400" height="400"   

style="stroke-width:1; stroke:black;fill:white"/>

<text id="pos1" x="5" y="20" style="font-size:15"></text>

<text id="pos2" x="5" y="40" style="font-size:15"></text>

</svg>


W 3 C h i n a ( since 2003 ) 旗 下 站 点
苏ICP备05006046号《全国人大常委会关于维护互联网安全的决定》《计算机信息网络国际联网安全保护管理办法》
31.250ms