W3C home > Mailing lists > Public > www-svg@w3.org > August 2000


From: 심규찬 <sim@multics.co.kr>
Date: Tue, 22 Aug 2000 18:04:56 +0900
To: <www-svg@w3.org>
Hi, all
I have a question onmouse event and coordinates.
I want to get viewbox coordinate  where on mouse clicked in SVG documenton.
In below example . I want to get coordinate of point on clicked and to add 'cronenode' in that point.
but,  funtion "evt.getClientX()", "evt.getClientY()" returns viewport coordinates, not user coordinates of SVGDOC. 
How to get   vewbox coodinates in svg document?
<?xml version = "1.0" standalone = "no"?>
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 20000303 Stylable//EN" 
<svg width = "500px" height="800px" viewBox="-32000 -25600 64000 50000">
function DoOnclick(evt)
		  var dx,dy;
                          var objnode;
                          var contents;  
                          var svgdoc =getSVGDocument(evt.getTarget()); 
		  contents = svgdoc.getElementById ('my');
                          var crnode = newnode.cloneNode(true);
		  crnode.setAttribute ('x', dx);
		  crnode.setAttribute ('y', dy);
		  contents.appendChild (crnode);

<rect style="fill:#ebebeb;stroke:#ebebeb"  x="-31872" y="-25344" width="63744" height="50944"/>
Received on Tuesday, 22 August 2000 05:08:23 UTC

This archive was generated by hypermail 2.3.1 : Wednesday, 8 March 2017 09:46:49 UTC