W3C home > Mailing lists > Public > www-svg@w3.org > May 2014

Re: SVG in JavaScript (parseXML, printNode,contextMenu)

From: Gavin Kistner <phrogz@me.com>
Date: Tue, 20 May 2014 18:02:55 +0000 (GMT)
To: Nelson Marisco <nmarisco@uol.com.br>
Cc: www-svg@w3.org
Message-id: <cd564d61-eb27-487f-8520-74519e7eecd7@me.com>
On May 20, 2014, at 07:26 AM, Nelson Marisco <nmarisco@uol.com.br> wrote:
 In 2004 I used the Adobe SVG Viewer displays it in the browser. I'm trying to use the same code in a browser with native SVG. But I'm having problems with parseXML, setData, printNode, contextMenu. How do I replace these functions so that the JavaScript can be played back directly in Browser natively?
 
Perhaps if you supplied details on the way you are using these functions, the browser(s) and version(s) you are testing in, and the error(s) you are seeing, you might get more helpful responses. Also, I kindly suggest that you might try http://stackoverflow.com/ for additional assistance. And, you may be interested in this page:
http://lbvenkatesh.wordpress.com/2012/04/17/replacing-adobe-svg-viewer-plugin-with-html5-support-from-the-browser/

But in summary, disregarding any IE-specific nonsense:

printNode():
var xmlString = (new XMLSerializer).serializeToString( myNode );
http://stackoverflow.com/q/43455/405017

parseXML():
var node = (new DOMParser).parseFromString(xmlString,'image/svg+xml');
http://stackoverflow.com/q/17604071/405017

setData():
myTextNode.nodeValue = "some string";
https://developer.mozilla.org/en-US/docs/Web/API/Node.nodeValue

contextMenu():
document.addEventListener('contextmenu',function(e){
  // do what you want here
  e.preventDefault();
},false);
http://stackoverflow.com/q/4909167/405017



Received on Tuesday, 20 May 2014 18:03:31 UTC

This archive was generated by hypermail 2.4.0 : Friday, 17 January 2020 22:54:53 UTC