Created
February 9, 2024 08:31
-
-
Save kaiili/f4a0ce882b5ea7935643e56bd5f506ad to your computer and use it in GitHub Desktop.
一个纯粹的 html 文件,用来执行 js 代码,方便调试,不依赖于特殊的库和函数。
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<html> | |
<head> | |
<title>JavaScript Execution</title> | |
<script> | |
function executeCode() { | |
const input = document.getElementById('inputCode').value; | |
const output = document.getElementById('outputResult'); | |
try { | |
const result = eval(input); | |
output.textContent = result; | |
} catch (error) { | |
output.textContent = error.message; | |
} | |
} | |
function resetFields() { | |
document.getElementById('inputCode').value = ''; | |
document.getElementById('outputResult').textContent = ''; | |
} | |
</script> | |
</head> | |
<body> | |
<h1>JavaScript Execution</h1> | |
<label for="inputCode">Input JavaScript code:</label><br> | |
<textarea id="inputCode" rows="5" cols="50"></textarea><br> | |
<button onclick="executeCode()">Execute</button><br><br> | |
<label for="outputResult">Output:</label><br> | |
<textarea id="outputResult" rows="5" cols="50" readonly></textarea><br><br> | |
<button onclick="resetFields()">Next</button> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment