[英]The offline version repl.it
If you're looking to install a way to run a JavaScript REPL on your local machine, you have two options: 如果要安装在本地计算机上运行JavaScript REPL的方法,则有两种选择:
If you have a text editor that can run a dos command, you can use CScript.exe, the windows version of a javascript engine. 如果您有可以运行dos命令的文本编辑器,则可以使用CScript.exe(JavaScript引擎的Windows版本)。 Though beware, that this is not ES5 compatible, and there is no browser object.
尽管要注意,这与ES5不兼容,并且没有浏览器对象。 Writing to stdout can be done using CScript.Echo()
可以使用CScript.Echo()写入stdout
I use TextPad which has a tools configuration, in which you can set the CScript path (find it in your windows system directory). 我使用TextPad,它具有工具配置,您可以在其中设置CScript路径(在Windows系统目录中找到它)。
I wonder why can't you do to create your own REPL instead, you just have to create a new window.open("", "_Jres", "", "false")
you can also have window.open("", "_self")
to replace the current document. 我想知道为什么您不能创建自己的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.