[英]The offline version repl.it
如果要安装在本地计算机上运行JavaScript REPL的方法,则有两种选择:
如果您有可以运行dos命令的文本编辑器,则可以使用CScript.exe(JavaScript引擎的Windows版本)。 尽管要注意,这与ES5不兼容,并且没有浏览器对象。 可以使用CScript.Echo()写入stdout
我使用TextPad,它具有工具配置,您可以在其中设置CScript路径(在Windows系统目录中找到它)。
我想知道为什么您不能创建自己的REPL,而只需创建一个新window.open("", "_Jres", "", "false")
您也可以拥有window.open("", "_self")
替换当前文档。
<!DOCTYPE html>
<html>
<head><title>Js Execute</title></head>
<body>
<textarea id="code" rows="10" cols="50">
//write your code here
alert("Clicking OK will write heading 1 in the new window");
document.write("<h1>heading 1</h1>");
</textarea>
<br/>
<button onclick="Execute()">Click To execute the above written JS</button>
<script>
function Execute() {
var win2 = window.open("", "_Jres", "", "false");
var content = document.getElementById("code");
var datacode = content.value;
console.log(datacode);
var hbody = "<script>" + datacode + "</" + "script>";
win2.document.writeln(hbody);
}
</script>
</body>
</html>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.