Joe
Here is the code I use:

function serializeNode (node) {
  if (typeof XMLSerializer != 'undefined') {
    var nodeString = new XMLSerializer().serializeToString(node)
    return nodeString;
  }
  else if (typeof node.xml != 'undefined') {
    return node.xml;
  }
  else if (typeof printNode != 'undefined') {
    return printNode(node);
  }
  else if (typeof Packages != 'undefined') {
    try {
      var stringWriter = new java.io.StringWriter();
      Packages.org.apache.batik.dom.util.DOMUtilities.writeNode(node,
stringWriter);
      return stringWriter.toString();
    }
    catch (e) {
      // might want to handle problem here
      return '';
    }
  }
  else {
    // might want to handle problem here
        alert("No method to serialize node!");
    return '';
  }
}

If you pass a node to the function serializeNode it will return a
string with all the current transformations and modifications to the
SVG document.  For example:
str = serializeNode(document.getElementById('svg_root'));
 If you pass it the root node of the SVG doc is is the same as the
"Copy SVG" in the menu.  This works for IE/ASV, Firefox, Opera and Batik.

I found this code during a frantic search to do exactly what you are
asking but I forgot to note where I got it and give credit for the
original author. :(  To whoever wrote this - Thanks!

Bruce Rindahl

--- In [email protected], "troutyjoe" <[EMAIL PROTECTED]> wrote:
>
> Hi all,
> 
> Does anyone know if it is possible to call the ASV "copy svg"
> functionality located on the context menu, from javascript?
> 
> Cheers,
> 
> Joe
>
Joe






-----
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/
 



Reply via email to