summaryrefslogtreecommitdiff
path: root/examples/script-file/README
blob: 8f10bdf80be59290f37a75d11cd9eb548c846c71 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
SVGC interactive-script example
===============================

This example demonstrates __svg_sheet_add_script_file().

The user writes only change-color.js as plain UTF-8 JavaScript source.
The C application registers that file with the SVG sheet; SVGC reads and
copies it into a <script type="text/javascript"><![CDATA[...]]></script>
definition when serializing the SVG.

After installing SVGC:

  make

Open example.svg directly as an SVG document, or use view.html, which
embeds it with <object type="image/svg+xml">. Click the red circle: the
script changes its fill to blue.  Loading the SVG with <img> deliberately
does not execute scripts in modern browsers.  Opening local files may also
be affected by browser security settings; a local HTTP server is an
alternative for manual testing when the browser restricts file://.

No binary scripts or external dependencies are bundled with the SVG.
No JavaScript parser is part of the SVGC library; the viewer executes
any embedded source in its normal security context.