运行,复制,保存,runCode,copyCode,saveCode,运行代码框
<script>
//对代码进行操作
function runCode(obj)
{
var winname =
window.open("",
"_blank","resizable=yes,scrollbars=yes,status=yes");
winname.document.open("text/html",
"replace");
winname.document.writeln(obj.value);
winname.document.close();
}
function
saveCode(obj,filename)
{
var winname = window.open("", "",
"top=10000,left=10000");
winname.document.open("text/html",
"replace");
winname.document.writeln(obj.value);
winname.document.execCommand("saveas",
"", filename + ".htm");
winname.close();
}
function
copyCode(obj)
{
var rng =
document.body.createTextRange();
rng.moveToElementText(obj);
rng.scrollIntoView();
rng.select();
rng.execCommand("Copy");
rng.collapse(false);
}
</script>
<textarea name=yongfa365
id=yongfa365></textarea>
<input type=button
onclick=runCode(document.getElementById("yongfa365"))
value="运行代码">
<input type=button
onclick=copyCode(document.getElementById("yongfa365"))
value="复制代码">
<input type=button
onclick=saveCode(document.getElementById("yongfa365"),"运行,复制,保存,run,copy,save,代码")
value="保存代码">
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】凌霞软件回馈社区,博客园 & 1Panel & Halo 联合会员上线
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步