<html>![](http://b65.photo.store.qq.com/http_imgload.cgi?/rurl4_b=0f8c6598917081bbc474f74f1dfc07e798b0131a38a315f1fcf9c060636f88d276d2fbb3b3885c1054d62be911b67e82aaf08cb6a3020c2196aed4788d902effc43ef0abe154c9b715de2302210289d7b6a8ca81&a=65&b=65)
<head>
<title>JS、HTML代码运行工具</title>
<SCRIPT LANGUAGE="JavaScript">
function copyCode(obj) {
if(obj.value==""){
alert("请输入要复制的代码内容");
return false;}
var rng = document.body.createTextRange();
rng.moveToElementText(obj);
rng.scrollIntoView();
rng.select();
rng.execCommand("Copy");
rng.collapse(false);
}
![](http://b65.photo.store.qq.com/http_imgload.cgi?/rurl4_b=0f8c6598917081bbc474f74f1dfc07e798b0131a38a315f1fcf9c060636f88d276d2fbb3b3885c1054d62be911b67e82aaf08cb6a3020c2196aed4788d902effc43ef0abe154c9b715de2302210289d7b6a8ca81&a=65&b=65)
function runCode(obj) {
if(obj.value==""){
alert("请输入要运行的代码内容");
return false;}
var winname = window.open('', "_blank", '');
winname.document.open('text/html', 'replace');
winname.document.writeln(obj.value);
winname.document.close();
}
function saveCode(obj) {
if(obj.value==""){
alert("请输入要保存的代码内容");
return false;}
var winname = window.open('', '_blank', '');
winname.document.open('text/html', 'replace');
winname.document.writeln(obj.value);
winname.document.close();
winname.document.execCommand('saveas','','savecode.htm');
winname.close();
}
</SCRIPT>
</head>
<body>
<B>JS、HTML运行工具</B>
<textarea name="textarea" style="width:96%" rows="33" id="testcode"></textarea>
<input name="button" type="button" onclick="runCode(testcode)" value="运行代码">
<input name="button" type="button" onclick="copyCode(testcode)" value="复制代码">
<input name="button" type="button" onclick="saveCode(testcode)" value="保存代码">
<input name="button" type="button" onclick="document.getElementById('testcode').value='';" value="清空代码">
</body>
</html>