< html > < head > < meta http-equiv ="Content-Type" content ="text/html; charset=GB2312" /> < META NAME ="Author" CONTENT ="Linc" /> < META NAME ="Keywords" CONTENT ="JS、HTML代码运行工具" /> < META NAME ="Description" CONTENT ="JS、HTML代码运行工具" /> < 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);}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 >