W3C home > Mailing lists > Public > www-svg@w3.org > December 2003

Bad influence of alert() on events in SVG

From: Mathias FATENE <mathias.fatene@wanadoo.fr>
Date: Wed, 24 Dec 2003 22:42:30 +0100
To: <www-svg@w3.org>
Message-ID: <LOEIKKFNGNCIKIBJKADKGENPCCAA.mathias.fatene@wanadoo.fr>

Hi all,
I experiement a problem generated by alert() function in SVG, which cause
event loose. This is demonstrated in Message 38230 on
http://groups.yahoo.com/group/svg-developers/messages.

When we have this example :
---------------------------------------------
<svg>
<defs>
<rect id="titleBar" x="10" y="10" width="100" height="100" fill="red" />
</defs>
<g id="title" onmousedown="alert('title')">
<use xlink:href="#titleBar" x="-5" y="200" />
<animateMotion from="0,0" to="600,0" dur="1s" fill="freeze"
begin="title.click" />
</g>
<text id="status" x="100" y="100"> ? </text>
</svg>
---------------------------------------------
We can't see the click event effect, bacause of the javascript function
alert().

If we change the code like that :
---------------------------------------------
<svg>
<defs>
<rect id="titleBar" x="10" y="10" width="100" height="100" fill="red" />
</defs>
<g id="title"
onmousedown="document.getElementById('status').firstChild.setData('title')">
<use xlink:href="#titleBar" x="-5" y="200" />
<animateMotion from="0,0" to="600,0" dur="1s" fill="freeze"
begin="title.click" />
</g>

<text id="status" x="100" y="100"> ? </text>
</svg>
---------------------------------------------
All works perfectly.

Conclusion :
---------------
                alert() can help for debugging, but is very bad when it
interacts with events. It simply eats them. Must be deprecated in
interactive SVG.


Cordialement
--------------------------------------
Mathias FATENE
  Consultant ORACLE - BDD - Unix / Linux / Windows
  mathias.fatene@wanadoo.fr
Received on Wednesday, 24 December 2003 16:49:10 GMT

This archive was generated by hypermail 2.3.1 : Friday, 8 March 2013 15:54:26 GMT