dispatchEvent on svg node in firefox
"Volker Gersabeck" <[email protected]>
| Newsgroups | gmane.comp.mozilla.devel.svg |
|---|---|
| Message-ID | <[email protected]> |
Hi there,
I'm developing a test framework for our web-app (http://rapidrabb.it) where
I'd like to trigger some click events on svg nodes within an xhtml page in
order to check whether the link targets are ok. The svg looks similar to
this one:
<g>
<a xlink:href="/link/to/some/page">
<rect id="myRect" .../>
</a>
</g>
The xhtml and svg are allright, by clicking myself I get to the desired
page. However, triggering a click event from within Javascript won't work in
Firefox (tested with 3.0 and 3.1 Beta 2). The Javascript that i wrote is
this:
var rect = document.getElementById("myRect");
var evtObj = document.createEvent('MouseEvents');
evtObj.initMouseEvent("click", true, true, window, 0, 0, 0, 0, 0,
false, false, false, false, 0, null);
rect.dispatchEvent(evtObj);
This snippet works just fine in Safari 3.2 as well as in Opera 9.6. In
Firefox, the dispatchEvent function returns true, however the page does not
change. I also tried with the SVGEvents, but this works only in Safari 3.2:
var rect = document.getElementById("myRect");
var evtObj = document.createEvent('SVGEvents');
evtObj.initEvent("click", true, true);
rect.dispatchEvent(evtObj);
When using the first snippet on an HTML node, it works just fine in Firefox,
but not with SVG. Would be nice, if anyone has a suggestion or can point me
to some other mailinglist / forum to ask there.
Thanks
Volker
--
RapidRabb.it GmbH
Kirchhofstr. 43
12055 Berlin
Tel. +49 30 6920 3773
volker.gersabeck at rapidrabb.it
www.rapidrabb.it
Accelerate your Prototyping!
RapidRabb.it GmbH
Sitz der Gesellschaft: Berlin
Registergericht Berlin-Charlottenburg, HRB 115010
Geschäftsführer: Philipp Huy