I have javascript in SVG observations of mouse events and need to convert the mouse coordinates to actual coordinates in SVG space (using viewBox and other transformations).
This code works in WebKit / Gecko browsers:
function transformEventCoordsToNodeCoords(evt,node)
{
var point = document.documentElement.createSVGPoint();
point.x = evt.clientX;
point.y = evt.clientY;
var ctm = node.getScreenCTM();
return point.matrixTransform(ctm.inverse());
}
In IE 9, getScreenCTM () throws an exception:
Unexpected call to method or property access.
I found code sample on the Internet, offering my code correctly, and I even found an SVG that seems to use exactly the same technique and works in IE 9:
Does anyone know why my code is not working?
Note: the variable nodematters <rect>:
<rect id="tooltip_box" x="698.7705078125" y="278.19676208496094" rx="20" ry="20" width="310" height="165" class="tooltip_box_region_level_1"></rect>
PS: It would be difficult to upload this SVG to a public server.