[英]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.