HTML Code execution from Javascript -


i obtain following string during runtime:

<path id= "3" d=" m 70.7107 40.8248 l -1.42109e-014 -7.10543e-015 " /> <path id= "4" d=" m 70.7107 -40.8248 l 70.7107 40.8248 " /> 

and generate svg element follows

var svg = document.createelementns("http://www.w3.org/2000/svg", "svg"); 

now generate 2 path elements children of dynamically created svg element. have hints me? lot in advance,

br

var svg = document.createelementns("http://www.w3.org/2000/svg", "svg"); svg.innerhtml = '<path id= "3" d=" m 70.7107 40.8248 l -1.42109e-014 -7.10543e-015 " /> <path id= "4" d=" m 70.7107 -40.8248 l 70.7107 40.8248 " />'; document.body.appendchild(svg); //replace document.body wherever want put svg  

via https://developer.mozilla.org/en-us/docs/web/api/node.appendchild

or maybe easier:

<html> <body>     <div id="svgdiv"></div>     <script>     var div = document.getelementbyid("svgdiv");     var paths = '<path id= "3" d=" m 70.7107 40.8248 l -1.42109e-014 -7.10543e-015 " /> <path id= "4" d=" m 70.7107 -40.8248 l 70.7107 40.8248 " />';     div.innerhtml = '<svg xmlns="http://www.w3.org/2000/svg" version="1.1">' + paths + '</svg>';     </script> </body> </html> 

alternatively, might want consider using jquery make dom manipulation easier.


Comments

Popular posts from this blog

java.util.scanner - How to read and add only numbers to array from a text file -

rewrite - Trouble with Wordpress multiple custom querystrings -