Loading ...
Sorry, an error occurred while loading the content.

Re: [svg-developers] Re: Firefox issues with createElementNS, works in IE

Expand Messages
  • Jonathan Watt
    Hi, ... As Ronan says, when running in Mozilla, ASV doesn t have support to allow script in the HTML to talk to the SVG it s rendering. In other words that
    Message 1 of 5 , Jan 7, 2006
    • 0 Attachment
      Hi,

      On 1/7/06, jaychambers <jaychambers@...> wrote:
      >
      > Hi Jonathan,
      >
      > This didnt work either, at least, not entirely. the JScript
      > console is cool. Learn something new every day!!! Does IE have
      > similar tool? didnt see one. Anyway, I've been looking around, and
      > this appears to be a pretty common issue with FF. The FF JScript
      > console says "svgDocument has no properties." From what I've read,
      > this is common in FF when using getSVGDocument. Whats more wierd,
      > is I disabled the FF SVG and loaded Adobe, and thats where I saw the
      > behavior.


      As Ronan says, when running in Mozilla, ASV doesn't have support to allow
      script in the HTML to talk to the SVG it's rendering. In other words that
      error is always going to occur if you're using ASV in Firefox.

      For grins, this morning, I changed back to native SVG in
      > FF, and all the sudden, it works using
      >
      > function onload=draw(), SVG native support, well-formed XML SVG
      > file, and this line
      > svgDocument = document.embeds["SVGNAME"].getSVGDocument();


      Yes, everything should work fine using Mozilla Firefox's native SVG support.

      dosent work with Adobe loadedup. I'm doing some further testing,
      > because FF is producing some very wierd "works when the sun is @ 45
      > degress of the ....." kind of issues. Its somewhat irritating that
      > the browser I have some to love and defend, has such flaky issues it
      > turns out.


      I played around with your files, modified in a variety of ways. It
      consistantly works for me. If you can keep copies of the files exactly as
      they are when they don't work for you I'll look into this.

      BTW, here is a link to a site that has a example at the bottom
      > trying to accomplish the same thing! Dosent work on FF (although
      > youl have to use adobe plugin, guess they arent using well-formed
      > XML)
      > http://www.svgopen.org/2002/papers/hauser_wenz__scripting_svg/


      Yes, well as you can see the SVG document hasn't loaded. Instead there's a
      grey background with the text: "This XML file does not appear to have any
      style information associated with it." If you google on that plus "SVG"
      you'll find the reason why. In short if the author had added the attribute:

      xmlns="http://www.w3.org/2000/svg"

      then the SVG document would load, and then the script would have something
      to access when you click the button.

      I wanted to thank you for your time to respond to my question!


      You're very welcome. :-)

      There are a couple of demos I have on my site showing how to script across
      the <object> and <embed> tags in both IE+ASV and in FF. They are heavily
      commented to explain how things work.

      http://jwatt.org/svg/demos/scripting-across-embed.html
      http://jwatt.org/svg/demos/scripting-across-object.html

      I hope you find them informative.

      -Jonathan

      -j
      > --- In svg-developers@yahoogroups.com, Jonathan Watt <wattie@g...>
      > wrote:
      > >
      > > Hi,
      > >
      > > The problem is likely that the SVG document hasn't yet loaded when
      > draw() is
      > > called. Instead of calling it in the <script> element, call it
      > onload. This
      > > should work I think:
      > >
      > > <html>
      > > <body onload="draw();">
      > > <EMBED NAME="mydoc" WIDTH="800" HEIGHT="600" SRC="canvas.svg" />
      > > <script language="javascript">
      > >
      > > var svgDocument;
      > >
      > > function draw() {
      > > var svgns = "http://www.w3.org/2000/svg";
      > >
      > > svgDocument = this.document.mydoc.getSVGDocument();
      > > var shape = svgDocument.createElementNS('
      > > http://www.w3.org/2000/svg','circle');
      > >
      > > shape.setAttributeNS(null, 'cx', 25);
      > > shape.setAttributeNS(null, 'cy', 25);
      > > shape.setAttributeNS(null, 'r', 20);
      > > shape.setAttributeNS(null, 'fill', 'green');
      > > svgDocument.documentElement.appendChild(shape);
      > > }
      > >
      > > </script>
      > > <p>testing</p>
      > > </body>
      > > </html>
      > >
      > > BTW, the JavaScript console is very useful in finding errors. See
      > Tools >
      > > JavaScript Console from the menubar. getSVGDocument() will have
      > returned
      > > null, so likely there was an error for the next line.
      > >
      > > Regards,
      > > Jonathan
      > >


      [Non-text portions of this message have been removed]
    Your message has been successfully submitted and would be delivered to recipients shortly.