SVG in HTML with script element
I have inline SVG code inside an HTML page,
<body><divstyle="width:1000px;height:1000px"><svgxmlns="http://www.w3.org/2000/svg"version="1.1"id="svgcanvas"xmlns:xlink="http://www.w3.org/1999/xlink"><gid="viewport"><circlecx="100"cy="50"r="40"stroke="black"stroke-width="2"fill="red"/><scriptxlink:href="js/SVGPan.js"type="text/javascript"/></svg>The script is correctly called in Firefox 7.0, but not in Chrome 16.0. Why is this so? And what changes should I make to the code to call javascript in Chrome too?
Interest Ask.
Some notes.
Inside normal HTML, the<script ... />will not be closed automatically, and everything else will be part of the contents of the script element.
Inside the<svg>element, the<svg><script ... />is self-closing and forms the entire element.
Both Firefox and Chrome get this right.
However, the HTML5 specification says that the script should be processedwhen the parser encounters an end tag. Since the element has no end tag, then the script should not be processed. This is what Chrome does.
However, the SVG specification requires that the script be run after the element has been closed by any means, and not just at the end of the tag. This is what Firefox does.
IMHO, the HTML5 specification is incorrect and should indicate SVG compatible behavior.
UPDATE: August 10, 2012
The HTML5 specification (currently only theWHATWG version) has been changed so that the SVG script is run. Seehttps://www.w3.org/Bugs/Public/show_bug.cgi?id=17995
UPDATE: September 16, 2012
Now the W3C version of the HTML5 specification has been fixed.