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 SVGDocument object.

  • Obtain it by passing to the onload event of the SVG graphic the keyword evt and returning the object in the event handler with getTarget( ).

  • The method getElementById accesses named elements.

  • Read attributes with the method getAttribute; set them with setAttribute.

Questions and exercises

  1. Which browsers currently fail to execute scripts, or execute them incorrectly?

  2. How are scripts defined in an SVG file?

  3. The following exercises form a single unit.

  4. Create a navigation bar with three adjacent rectangles and text. Give the rectangles and texts hyperlinks.

  5. Format these rectangles and text with stylesheets.

  6. Add an invisible message box containing another rectangle and text.

  7. Create a function that shows the message box and explanatory text when the pointer hovers over navigation elements.

  8. Extend it to visually highlight the navigation button currently under the pointer.

   

 

 

 

back to top