javascript - Avoiding use of eval in raphael.sketchpad function -


i have following code works expected:

                var svg_height = $("#svg-container").height();                 var svg_width = $("#svg-container").width();                 var name = "sketchpad";      eval("window." + name + "= raphael.sketchpad('"                                 + "svg-container" + "',{" + " width:"                                 + svg_width + "," + "height: " +           svg_height                                 + "," + "editing: true," + " });"); 

however want avoid using eval security reasons. tried following not work

window.sketchpad = raphael.sketchpad("'svg-container',{width:"+ svg_width +",height:"+ svg_height +", editing: true}"); 

can solved using json. if yes, how? appreciated.

disclaimer: know nothing raphael, translating eval code.

window[name] = raphael.sketchpad("svg-container", {                                         width: svg_width,                                         height: svg_height,                                         editing: true                  }); 

the function had there, has couple erroneous quotes messing up.


Comments

Popular posts from this blog

javascript - RequestAnimationFrame not working when exiting fullscreen switching space on Safari -

Python ctypes access violation with const pointer arguments -