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

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