W3C home > Mailing lists > Public > www-svg@w3.org > March 2009

RE: Script in SVG vs. HTML (was: Input on the agenda)

From: Dailey, David P. <david.dailey@sru.edu>
Date: Tue, 10 Mar 2009 12:16:49 -0400
Message-ID: <1835D662B263BC4E864A7CFAB2FEEB3D0203C961@msfexch01.srunet.sruad.edu>
To: "Doug Schepers" <schepers@w3.org>, <public-html@w3.org>
Cc: <public-html@w3.org>, "www-svg" <www-svg@w3.org>
Hi Doug,

Just off the top of my head, the differences I remember include:

(1) In HTML (most browsers, at least) one can say

var O=document.getElementsByTagName(sometag)
var q=O[i]

whereas in SVG you have to do
var O=document.getElementsByTagName(sometag)
var q=O.items(i)

(it's nice to have the flexibility of doing it the former way -- both as a list and an array, though maybe that isn't an option)

(2) In SVG you can rely on function Q(evt) receiving the event and knowing what evt.target is. In HTML (as deployed in current browsers), you can't. SVG is nicer in that way.

(3)There used to be difference between browsers and between HTML and SVG in terms of when onload happens:

<svg xmlns=http://www.w3.org/2000/svg


xmlns:xlink=http://www.w3.org/1999/xlink


onload="alert('message')">

<ellipse cx="75" cy="75" rx="40" ry="30" fill="blue"/>

</svg>

IE/ASV fires the ellipse before the ellipse is drawn. In HTML it appears that most browsers (even IE) seem to be moving to a model that onload doesn't happen til all content has arrived?

(4)In HTML one has to run animations with script. In SVG many can be done with SMIL. SVG is better about this.

(5) In SVG you have to use a <![CDATA[ thingy inside your <script> to avoid parsing <'s. That scares some learners.

(6) in HTML one can use createElement(tag); in SVG you have to use createElementNS(namespace, tag) . Again that's a bit scary for some of us. Same thing with setAttribute. It currently works in SVG, in Opera, FF and IE, but is deprecated. Likewise for I.setAttributeNS(null,"xlink:href","newone.jpg") . If one is hoping to do svg in html or html in svg, I'm not sure how one gets around namespaces.

(7) accessing SVG DOM from within HTML frames seems to be inconsistent across browsers. Not sure whose purview this would be.

cheers
David


------Doug wrote-------

Along not-entirely-unrelated lines, the SVG WG is currently looking at 
aligning SVG script handling with that of HTML.  Feedback on this topic 
is most welcome.

Regards-
-Doug Schepers
W3C Team Contact, SVG and WebApps WGs

Received on Tuesday, 10 March 2009 16:18:00 GMT

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