发表评论
◎欢迎参与讨论,请在这里发表您的看法、交流您的观点。
|
|
//*********************************************************
// 目的: 代码运行框
// 输入: obj
// 返回:
//*********************************************************
function copycode(obj) {
var rng = document.body.createTextRange();
var obj1=document.getElementById(obj)
rng.moveToElementText(obj1);
rng.scrollIntoView();
rng.select();
rng.execCommand("Copy");
rng.collapse(false);
}
function runCode(obj) {
var winname = window.open('', "_blank", '');
var obj1=document.getElementById(obj)
winname.document.open('text/html', 'replace');
winname.opener = null // 防止恶意修改
winname.document.writeln(obj1.value);
winname.document.close();
}
function saveCode(obj) {
var winname = window.open('', '_blank', 'top=10000');
var obj1=document.getElementById(obj)
winname.document.open('text/html', 'replace');
winname.document.writeln(obj1.value);
winname.document.execCommand('saveas','','code.htm');
winname.close();
}
objRegExp.Pattern="(\[CODE\])(.+?)(\[\/CODE\])"
strContent=objRegExp.Replace(strContent,"<textarea class=""code"" name=""runcode0"" rows=""10"" cols=""50"">$2</textarea>")
Dim codeNum,rndStr
codeNum=0
Randomize
rndStr=int(rnd*100)
strContent=objRegExp.Replace(strContent,"<textarea class=""code"" name=""code"&rndStr&codeNum&""" id=""code"&rndStr&codeNum&""" rows=""10"" cols=""50"">$2</textarea><br /><input type=""button"" value=""运行代码"" onclick=""runCode('code"&rndStr&codeNum&"')""> <input type=""button"" value=""复制代码"" onclick=""copycode('code"&rndStr&codeNum&"')""> <input type=""button"" value=""另存代码"" onclick=""saveCode('code"&rndStr&codeNum&"')""> 提示:您可以先修改部分代码再运行")
codeNum=codeNum+1
Posted by 小寒 at 11:34:01 | 代码片段 | Comments (0)
对我而言,zblog的几点不足 (2008-5-2 17:58:48)
伪造的规律 (2008-4-28 16:50:41)
我不用LBS了 (2007-11-21 10:29:45)