XML technologies / SVG / Interactive graphics / Creating elements dynamically / Storing text and links
(Excerpt from “Das Einsteigerseminar SVG — Webgrafiken mit XML” by Helma Spona)
To make the sitemap easy to extend, define its texts and links in arrays. You can then iterate over an array and create elements from its entries. If the array names include the group names, the text clicked lets you calculate which array names to use. Text arrays begin with “w”, for the German “Werte” (values), and link arrays with “l”, for “Links”.
var wkontakt=new Array("Impressum", "Kontakt", "Gästebuch", "Forum");
var lkontakt=new Array("impressum.htm", "kontakt.htm", "gaestebuch.htm" ,"forum.htm")
var winhalte=new Array("SVG", "Skripting", "XML", "FAQ", "Links");
var linhalte=new Array("svg.htm", "skripting.htm", "xml.htm", "faq.htm", "links.htm");
var wprojekte=new Array("Browser-Bugs", "MeineWebseite");
var lprojekte=new Array(http://www.browser-bugs.de, "http://www.helma-spona.de");
In the code, simply assign the required arrays to the variables werte and links. Use the eval statement, passing the assignment as a string. For example, eval("werte=w"+elem.getAttribute("id")); assigns to the variable werte the array whose name is “w” followed by the group name. The eval statement evaluates the supplied expression as a JavaScript command. The variable werte then contains the array with the required texts.
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
back to top