JavaScript Runcode

代码预览器

<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:

  1. JQUERY搜索框提示效果
  2. JavaScript可移动弹出层
  3. javascript+css 新闻滑轮显示
  4. Jquery 获取元素数量 length
  5. JQuery 新闻头条淡入淡出效果
此条目发表在 前端技术 分类目录,贴了 , 标签。将固定链接加入收藏夹。

发表评论

电子邮件地址不会被公开。 必填项已被标记为 *

*

您可以使用这些 HTML 标签和属性: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong> <pre lang="" line="" escaped="">

*
To prove you're a person (not a spam script), type the security word shown in the picture. Click on the picture to hear an audio file of the word.
Click to hear an audio file of the anti-spam word