--- In svg-developers@yahoogroups.com, Jeroen Vanattenhoven <[EMAIL PROTECTED]> wrote: > > Is it possible to load .js files via js-code? With this I mean: is it > possible to create packages like in Java and use them with something > like import io.gis.something? If not, is there an alternative for > JavaScript? Because if you create a whole application (OO) with a lot of > .js-files, it looks a bit silly to write script elements every time.
The JavaScript core language itself has no file inclusion or import mechanism. You need to use the inclusion mechanism of the host language e.g. in HTML <script type="text/javascript" src="file.js"></script> in SVG <script type="text/ecmascript" xmlns:xlink="http://www.w3.org/1999/xlink" xlink:href="file.js" /> Of course with the DOM you can create script elements dynamically and DOM implementations like that in Mozilla by now do support loading script dynamically that way, see the example at <http://home.arcor.de/martin.honnen/svg/test2006030201.svg> where var scriptElement = document.createElementNS('http://www.w3.org/2000/svg', 'script'); scriptElement.setAttributeNS(null, 'type', 'text/ecmascript'); scriptElement.setAttributeNS('http://www.w3.org/1999/xlink', 'xlink:href', url); document.documentElement.appendChild(scriptElement); is used to dynamically create and insert an SVG script element when the blue rectangle is clicked. Other implementations like Adobe SVG viewer 3.0, Batik squiggle 1.6 or Opera 9 preview however do not seem to load the script file referenced by the dynamically inserted script element. ----- To unsubscribe send a message to: [EMAIL PROTECTED] -or- visit http://groups.yahoo.com/group/svg-developers and click "edit my membership" ---- Yahoo! Groups Links <*> To visit your group on the web, go to: http://groups.yahoo.com/group/svg-developers/ <*> To unsubscribe from this group, send an email to: [EMAIL PROTECTED] <*> Your use of Yahoo! Groups is subject to: http://docs.yahoo.com/info/terms/