Convert a string to a javascript code -


i have folowing string variable returned textarea : jtext = $('#putjs').val();

the result of string following:

ctx.beginpath();     ctx.moveto(172 + xoff, 29 + yoff);     ctx.beziercurveto(183 + xoff, 33 + yoff, 199 + xoff, 36 + yoff, 201 + xoff, 74 + yoff);     ctx.beziercurveto(191 + xoff, 91 + yoff, 197 + xoff, 130 + yoff, 196 + xoff, 110 + yoff);     ctx.beziercurveto(195 + xoff, 95 + yoff, 200 + xoff, 230 + yoff, 200 + xoff, 248 + yoff);     ctx.beziercurveto(200 + xoff, 256 + yoff, 85 + xoff, 251 + yoff, 70 + xoff, 251 + yoff);     ctx.beziercurveto(65 + xoff, 251 + yoff, 74 + xoff, 122 + yoff, 71 + xoff, 106 + yoff);     ctx.beziercurveto(68 + xoff, 88 + yoff, 65 + xoff, 87 + yoff, 65 + xoff, 73 + yoff);     ctx.beziercurveto(65 + xoff, 52 + yoff, 70 + xoff, 35 + yoff, 95 + xoff, 28 + yoff);     ctx.beziercurveto(99 + xoff, 37 + yoff, 130 + xoff, 72 + yoff, 171 + xoff, 29 + yoff);     ctx.stroke();  

the question is, how put string javascript code design canvas in code javascript file?

there eval function in can pass string. simple example can find here: https://developer.mozilla.org/en-us/docs/javascript/reference/global_objects/eval

but using eval function dangerous, careful this.


Comments

Popular posts from this blog

blackberry 10 - how to add multiple markers on the google map just by url? -

php - guestbook returning database data to flash -

delphi - Dynamic file type icon -