Rumah > hujung hadapan web > tutorial js > 一个用js实现控制台控件的代码_javascript技巧

一个用js实现控制台控件的代码_javascript技巧

WBOY
Lepaskan: 2016-05-16 19:09:07
asal
1000 orang telah melayarinya
复制代码 代码如下:



<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>
sumber:php.cn
Kenyataan Laman Web ini
Kandungan artikel ini disumbangkan secara sukarela oleh netizen, dan hak cipta adalah milik pengarang asal. Laman web ini tidak memikul tanggungjawab undang-undang yang sepadan. Jika anda menemui sebarang kandungan yang disyaki plagiarisme atau pelanggaran, sila hubungi admin@php.cn
Tutorial Popular
Lagi>
Muat turun terkini
Lagi>
kesan web
Kod sumber laman web
Bahan laman web
Templat hujung hadapan