简体   繁体   中英

The offline version repl.it

不知道我是否正确提出了问题-是否可以具有repl.it的脱机版本(仅需要JavaScript),以便可以在没有Internet访问的情况下使用它?

If you're looking to install a way to run a JavaScript REPL on your local machine, you have two options:

  • Open your browser's console as usual. Lack of internet doesn't make it any less JavaScripty.
  • Install NodeJS

If you have a text editor that can run a dos command, you can use CScript.exe, the windows version of a javascript engine. Though beware, that this is not ES5 compatible, and there is no browser object. Writing to stdout can be done using CScript.Echo()

I use TextPad which has a tools configuration, in which you can set the CScript path (find it in your windows system directory).

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.

<!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>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM