XML technologies / SVG / Interactive graphics / Summary, questions and exercises
(Excerpt from “Das Einsteigerseminar SVG — Webgrafiken mit XML” by Helma Spona)
Summary
Scripts can be defined inside SVG files.
In SVG Viewer, these scripts use the browser’s JavaScript implementation.
The scripting language is ECMAScript, a JavaScript standard.
To manipulate or create SVG file elements, access the parent
SVGDocumentobject.Obtain it by passing to the
onloadevent of the SVG graphic the keywordevtand returning the object in the event handler withgetTarget( ).The method
getElementByIdaccesses named elements.Read attributes with the method
getAttribute; set them withsetAttribute.
Questions and exercises
Which browsers currently fail to execute scripts, or execute them incorrectly?
How are scripts defined in an SVG file?
The following exercises form a single unit.
Create a navigation bar with three adjacent rectangles and text. Give the rectangles and texts hyperlinks.
Format these rectangles and text with stylesheets.
Add an invisible message box containing another rectangle and text.
Create a function that shows the message box and explanatory text when the pointer hovers over navigation elements.
Extend it to visually highlight the navigation button currently under the pointer.
Copyright © verlag moderne industrie GmbH 2001
You may print the online version for your private use.
Otherwise, this chapter from “Das Einsteigerseminar SVG — Webgrafiken mit XML” is subject to the same conditions as the bound edition. The work, including all its parts, is protected by copyright. All rights reserved, including reproduction, translation, microfilming, and storage and processing in electronic systems.
verlag moderne industrie GmbH, Justus-von-Liebig-Straße 1, D-86899 Landsberg/Lech, fon ++49 (0) 81 91 / 125 – 0, leserservice(at)mi-verlag.de