How do I execute some JavaScript that is a string?
JavaScript
x
6
1
function ExecuteJavascriptString()
2
{
3
var s = "alert('hello')";
4
// how do I get a browser to alert('hello')?
5
}
6
Advertisement
Answer
With the eval
function, like:
JavaScript
1
2
1
eval("my script here");
2