一個(gè)用js實(shí)現(xiàn)控制臺控件的代碼
更新時(shí)間:2007年09月04日 11:46:04 作者:
復(fù)制代碼 代碼如下:
<body margin="0">
</body>
<script>
function Console(width,height,command)
{
var container=document.createElement("div");
this.container=container;
container.runtimeStyle.width=(width);
container.runtimeStyle.height=(height);
container.runtimeStyle.margin="0px";
container.runtimeStyle.backgroundColor="black";
container.runtimeStyle.fontFamily="Terminal";
container.runtimeStyle.color="white";
container.runtimeStyle.fontSize="16px";
this.output=document.createElement("div");
container.appendChild(this.output);
container.innerHTML+="js>"
this.input=document.createElement("input");
container.appendChild(this.input);
this.input.runtimeStyle.backgroundColor="black";
this.input.runtimeStyle.borderWidth="0px";
this.input.runtimeStyle.color="white";
this.input.runtimeStyle.fontFamily="Terminal";
this.input.runtimeStyle.width="90%"
this.input.runtimeStyle.fontSize="16px"
this.input.runtimeStyle.position="relative";
this.input.runtimeStyle.top="2px";
command=command||function(str)
{
var e;
try{
var r=eval(str);
} catch(e) {
return "Bad command";
}
return r;
}
this.input.command=function()
{
this.parentNode.childNodes[0].innerHTML+=this.value+'<br/>'
this.parentNode.childNodes[0].innerHTML+=(command(this.value)+"<br/>")
}
this.input.onkeyup=new Function("e","e=e||event;if(e.keyCode!=13)return;this.command();this.value='';");
this.appendto=function(parent)
{
parent.appendChild(this.container);
}
container=null;
}
//var db=new DrawingBoard(100,100)
//db.drawLine([5,5],[36,44],"red")
//document.body.appendChild(db.container);
var c=new Console("100%","100%");
c.appendto(document.body);
</script>
您可能感興趣的文章:
- AngularJS 如何在控制臺進(jìn)行錯(cuò)誤調(diào)試
- javascript控制臺詳解
- js調(diào)試系列 控制臺命令行API使用方法
- 禁用JavaScript控制臺調(diào)試的方法
- 利用瀏覽器的Javascript控制臺調(diào)試PHP程序
- 如何使Chrome控制臺支持多行js模式——意外發(fā)現(xiàn)
- JavaScript中輸出信息的方法(信息確認(rèn)框-提示輸入框-文檔流輸出)
- javascript中常見的3種信息提示框(alert,prompt,confirm)
- Js 訂制自己的AlertBox(信息提示框)
- JS簡單實(shí)現(xiàn)仿百度控制臺輸出信息效果
相關(guān)文章
document.documentElement和document.body區(qū)別介紹
body是DOM對象里的body子節(jié)點(diǎn),即body標(biāo)簽,documentElement 是整個(gè)節(jié)點(diǎn)樹的根節(jié)點(diǎn)root,詳細(xì)介紹請看本文,感興趣的朋友可以參考下2013-09-09JavaScript Event學(xué)習(xí)補(bǔ)遺 addEventSimple
這里有個(gè)addEventSimple和removeEventSimple函數(shù),有時(shí)候需要不那么顯眼的事件處理程序的時(shí)候我就用這兩個(gè)函數(shù)注冊。2010-02-02淺析JavaScript中兩種類型的全局對象/函數(shù)
這篇文章主要介紹了JavaScript中兩種類型的全局對象/函數(shù)。需要的朋友可以過來參考下,希望對大家有所幫助2013-12-12JavaScript實(shí)現(xiàn)計(jì)數(shù)器基礎(chǔ)方法
這篇文章主要為大家詳細(xì)介紹了JavaScript實(shí)現(xiàn)計(jì)數(shù)器的基礎(chǔ)方法2017-10-10
,文中示例代碼介紹的非常詳細(xì),具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下