87,994
社区成员




var jsDocText = document.createTextNode(jsText);
var jsDoc = document.createElement("script");
jsDoc.appendChild(jsDocText);
document.getElementsByTagName("head")[0].appendChild(jsDoc);
var jsText = 'function(){alert(1)}'
var jscode = new Function('return '+jsText)();
jscode()
var jsText = '(function(){alert(1)})()'
var jsDoc = document.createElement("script");
jsDoc.innerHTML = jsText;
document.getElementsByTagName("head")[0].appendChild(jsDoc);
<html>
<head>
<meta charset=utf-8 />
<title>JS Bin</title>
</head>
<body>
<script type='text/javascript'>
var jsText = 'var myfn = function(){alert(1)}'
var jsDocText = document.createTextNode(jsText);
var jsDoc = document.createElement("script");
jsDoc.appendChild(jsDocText);
document.getElementsByTagName("head")[0].appendChild(jsDoc);
myfn()
</script>
</body>
</html>
var fun="function(){alert(123);}";
var f1=(new Function("alert(123)"))(),f2=(new Function("return "+fun))();
f2();
var s = 'function fn(s) { alert(s); }';
eval(s);
fn('test');