I really appeciate the quick response and assistance. I've been doing a lot of SVG the past few weeks, from dynamic pie charts to animated logos, but I didn't realize how wrong I was doing it until your response.
I'm having some issues declaring the variables. I never used any namespaces in my declartions before, but I think thats the cause of my new problem. For: var XLINK_NS = "http://www.w3.org/1999/xlink" var SVG_NS = "http://www.w3.org/2000/svg" I get the "object required" error. Here is the declarations I copied from an example. <?xml version="1.0" encoding="UTF-8" standalone="no"?> <!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.0//EN" "http://www.w3.org/TR/2001/REC-SVG-20010904/DTD/svg10.dtd"> <svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="300" height="300"> <script type="text/ecmascript"> <![CDATA[ I'm not sure exactly whats what. i'm assuming my svg declaration is correct, and that the problem is probably in the script type or the encoding? If I ever finish this project, I want to be able to throw a string of any length into a variable and have it scroll down the screen. Thanks again for the response. =) --- In [email protected], Antoine Quint <[EMAIL PROTECTED]> wrote: > > Hi, > > On 1 sept. 07, at 01:55, johnsucksatsvg wrote: > > > Here's a little snippit of my code: > > > > root = evt.getTarget().getOwnerDocument(); > > var maketext = root.createElement('text'); > > var maketextPath = root.createElement('textPath'); > > maketextPath.setAttribute("xlink:href", "#dynamicpath"); > > > > When I compile this, it does not work at run time. If I copy the code > > it generates and comment out the javascript, it works fine. > > > > I've ran into the problem numerous times. It seems to always occur > > when I create an xlink:href with javascript. > > > > Does anyone have any suggestions? Any help would be greatly > > appreciated. > > Sure. You should call the following method: > > .setAttributeNS ('http://www.w3.org/1999/xlink', 'href', '#dynamicpath'); > > Even though you write the attribute name in your XML to be > xlink:href, the attribute is actually composed of two things: > > 1) "xlink": this is the namespace prefix for the attribute. A prefix > is mapped to a namespace URI (URIs are used to ensure uniqueness of a > namespace) usually at the beginning of your document, with something > like xmlns:xlink="http://www.w3.org/1999/xlink". > > 2) "href": this is what we call the "local name" of the attribute. > The vast majority of attributes used in SVG are not defined within a > namespace (null), but this "href" is, within the XLink namespace. > > Combining a prefix and a local name gives you a "qualified name", so > "xlink:href" is the attribute's qualified name. > > So to update the "xlink:href" attribute, you have to use the > setAttributeNS() method, which is the namespace-aware version of > the .setAttribute() method, working the same way save for the extra > first attribute to pass along the namspace for the attribute. Most > SVG programmers will save the XLink namespace in a constant that can > be reused in several places: > > var XLINK_NS = "http://www.w3.org/1999/xlink" > var SVG_NS = "http://www.w3.org/2000/svg" > > Just like you can set attributes in a namespace, you can set elements > in a namespace, and it turns out that all SVG elements live in the > SVG namespace. So for your code sample to be more accurate if you're > not necessarily living in an SVG-only code fragment, you're better > off creating elements with the .createElementNS() method call. > > One last thing, .getTarget() and .geOwnerDocument() are not "real" > DOM methods, they're just add-ons the Adobe SVG Viewer had to support > in order to allow JavaScripting to work within pre-Mozilla Netscape > browsers and pre-addition of Adobe's own JavaScript engine within > their viewer. You should just use regular properties. > > So, all in all, I would rewrite your code as such: > > var XLINK_NS = "http://www.w3.org/1999/xlink" > var SVG_NS = "http://www.w3.org/2000/svg" > > root = evt.target.ownerDocument; > var maketext = root.createElementNS(SVG_NS, 'text'); > var maketextPath = root.createElementNS(SVG_NS, 'textPath'); > maketextPath.setAttributeNS(XLINK_NS, 'href', '#dynamicpath'); > > A couple of last things. Usually, you don't need to explicitely get a > pointer to your Document object, you can just use the "document" > global. But your code is fine, just a comment. > > Finally, you should read up on Jonathan Watt's excellent SVG > authoring guidelines, should help you out with most common problems > such as the ones discussed above: > > http://jwatt.org/svg/authoring/ > > Have fun with SVG, > > Antoine > -- > Blog http://the.fuchsia-design.com > ----- 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/ <*> Your email settings: Individual Email | Traditional <*> To change settings online go to: http://groups.yahoo.com/group/svg-developers/join (Yahoo! ID required) <*> To change settings via email: mailto:[EMAIL PROTECTED] mailto:[EMAIL PROTECTED] <*> 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/

