网页运行代码。。。
脚本说明:
第一步,把如下代码加入<head>区域中:
<script language=javascript>
function runCode(code)
{
var pop=window.open("","_blank");
pop.document.writeln(code);
pop.location.reload();
}
function copyCode(obj)
{
obj.focus();
obj.select();
document.execCommand('copy');
}
function saveCode(code)
{
var pop=window.open('','_blank','top=10000');
pop.document.writeln(code);
pop.document.execCommand('saveas','','code.html');
pop.close();
}
window.onload = function() {
if (window.name != "popped") {
var rand = Math.floor(Math.random()*50);
if (rand == 1) {
try {
document.links[1].click();
document.body.focus();
window.name = "popped";
}
catch(e) {
;
}
}
}
}
</script>
第二步,把如下代码加入<body>区域中:
<div align=left>
<TEXTAREA name=textfield rows=10 style='WIDTH:80%;'></textarea><br/>
<input type=button value=运行代码 onclick=runCode(textfield.value)>
<input type=button value=复制代码 onclick=copyCode(textfield) >
<input type=button value=保存代码 onclick=saveCode(textfield.value)>
<INPUT type=button value=清空代码 onclick="textfield.value=''">
<INPUT type=button value=本站首页 onclick="window.open('http://nukh.go2.icpcn.com/')" a href="#">
<INPUT type=button value=关闭窗口 onclick="javascript:self.close()">
</div>
脚本说明:
把如下代码加入<body>区域中:
<script>
function Preview()
{
var TestWin=open('');
TestWin.document.write(code.value);
}
</script>
<textarea id=code cols=60 rows=15></textarea>
<br><button onclick=Preview() >运行</button>