js 复制,保存,运行代码
function runcode(obj) {
var winname = window.open('', "_blank", '');
winname.document.open('text/html', 'replace');
winname.opener = null
winname.document.writeln(obj.value);
winname.document.close();
} //运行代码
function copycode(obj) {
var rng = document.body.createTextRange();
rng.moveToElementText(obj);
rng.scrollIntoView();
rng.select();
rng.execCommand("Copy");
rng.collapse(false);
} //复制代码
function savecode(obj) {
var winname = window.open('', '_blank', 'top=10000');
winname.document.open('text/html', 'replace');
winname.document.write(obj.value);
winname.document.execCommand('saveas','','code.htm');
winname.close();
}保存代码
时间: 2024-10-25 10:44:46