代码预览器
<html>
<head>
<title>代码预览器</title>
<meta http-equiv=Content-Type content="text/html; charset=gb2312">
<script language=JavaScript>
var currentpos,timer;
function initialize()
{
timer=setInterval("scrollwindow()",50);
}
function sc()
{
clearInterval(timer);
}
function scrollwindow()
{
currentpos=document.body.scrollTop;
window.scroll(0,++currentpos);
if (currentpos != document.body.scrollTop)
sc();
}
document.onmousedown=sc
document.ondblclick=initialize
</script>
</head>
<body>
<h1 align="center">代码预览器</h1>
<hr SIZE=1>
<p align="center"><textarea id="p" onfocus="this.select()" onKeyDown="submitCode()" name="p" rows="30" cols="100"></textarea></p>
<p align="center">
<input onclick=runcode() type=button tabindex="2" value=代码运行 name="button">
<input onClick="window.close();return false;" type="button" value="关闭窗口" name="close">
</p>
<div align="center">
<script>
function runcode()
{
code=p.value;
a=window.open()
a.opener=null
a.document.write(code)
a.document.close()
}
function submitCode()
{
if(123==event.keyCode)
runcode();
}
</script>
</div>
</body>
</html>提示:你可以先修改部分代码再运行。
Related posts:
