UNPKG

safe-run

Version:

Run unsafe JavaScript using WebWorkers

33 lines (29 loc) 969 B
<!DOCTYPE html> <html> <head> <meta charset="utf-8" /> <meta http-equiv="X-UA-Compatible" content="IE=edge"> <title>JS-Runner</title> <meta name="viewport" content="width=device-width, initial-scale=1"> <script src="index.js"></script> <script> function run() { var code = document.getElementById('codeArea').value; window.runner.run(['https://momentjs.com/downloads/moment.js'], code) .then(function (result) { document.getElementById("output").style.color = "black"; document.getElementById("output").innerHTML = result }) .catch(function (err) { document.getElementById("output").style.color = "red"; document.getElementById("output").innerHTML = err }) } </script> </head> <body> <textarea name="codeArea" id="codeArea" cols="30" rows="10"></textarea> <button onclick="run()">Press Me</button> <div id="output"></div> </body> </html>