Home  >  Article  >  Web Front-end  >  A code to implement console control using js_javascript skills

A code to implement console control using js_javascript skills

WBOY
WBOYOriginal
2016-05-16 19:09:07970browse
复制代码 代码如下:



<script> <br>    function Console(width,height,command) <br>    { <br>        var container=document.createElement("div"); <br>        this.container=container; <br><br>        container.runtimeStyle.width=(width); <br>        container.runtimeStyle.height=(height); <br>        container.runtimeStyle.margin="0px"; <br>        container.runtimeStyle.backgroundColor="black"; <br>        container.runtimeStyle.fontFamily="Terminal"; <br>        container.runtimeStyle.color="white"; <br>        container.runtimeStyle.fontSize="16px"; <br>        this.output=document.createElement("div"); <br>        container.appendChild(this.output); <br>        container.innerHTML ="js>" <br>        this.input=document.createElement("input"); <br>        container.appendChild(this.input); <br>        this.input.runtimeStyle.backgroundColor="black"; <br>        this.input.runtimeStyle.borderWidth="0px"; <br>        this.input.runtimeStyle.color="white"; <br>        this.input.runtimeStyle.fontFamily="Terminal"; <br>        this.input.runtimeStyle.width="90%" <br>        this.input.runtimeStyle.fontSize="16px" <br>        this.input.runtimeStyle.position="relative"; <br>        this.input.runtimeStyle.top="2px"; <br>        command=command||function(str) <br>        { <br><br>            var e; <br>            try{ <br>                var r=eval(str); <br>            } catch(e) { <br>                return "Bad command"; <br>            } <br>            return r; <br><br>        } <br><br>        this.input.command=function() <br>        { <br>            this.parentNode.childNodes[0].innerHTML =this.value '<br/>' <br>            this.parentNode.childNodes[0].innerHTML =(command(this.value) "<br/>") <br><br>        } <br>        this.input.onkeyup=new Function("e","e=e||event;if(e.keyCode!=13)return;this.command();this.value='';"); <br>        this.appendto=function(parent) <br>        { <br>            parent.appendChild(this.container); <br>        } <br>        container=null; <br>    } <br><br>    //var db=new DrawingBoard(100,100) <br>    //db.drawLine([5,5],[36,44],"red") <br>    //document.body.appendChild(db.container); <br>    var c=new Console("100%","100%"); <br>    c.appendto(document.body); <br><br></script>
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn