1var theInstructions = "alert('Hello World'); var x = 100";
2
3var F=new Function (theInstructions);
4
5return(F());
1var theInstructions = "alert('Hello World'); var x = 100";
2
3var F=new Function (theInstructions);
4
5return(F());
6
1function ExecuteJavascriptString()
2{
3 var s = "alert('hello')";
4 // how do I get a browser to alert('hello')?
5}
6
1var myString = "console.log('I am Batman')";
2eval(myString);
3//carefull ! This will execute the code, therefore
4//be careful of where/how you got this string.