控制台模拟器。帮助编写输入功能

时间:2015-03-20 02:55:04

标签: javascript html input console emulation

对于我正在进行的项目,我有一个控制台模拟器(如下所示),但我遇到了一个问题;接收用户输入。我需要它来创建一个文本框,等待用户按Enter键,然后返回文本框中的值,或者如果文本框在按下输入时为空,则移动到下一行与另一个文本框(同样的事情,直到输入但是,只要它们提供这种输入方式,其他方法就可以了。执行此操作的代码应放在函数“input”中。在下面的代码中,div“console”应为:

1
23[textbox]
[whatever the user entered]

如果某人可以向我展示执行此操作的功能,那么会非常感激


<html>
<head></head>
<body>
<style>
div
{
font-family: Consolas;
color: #ffffff;
background: #000000;
height: 310px;
width: 670px;
overflow-y: scroll;
outline: 100px;
outline-color: #888888;
margin: 0;
}
p
{
margin: 0;
}
#headbar
{
background: #0000ff;
color: orange;
height: 20px;
overflow-y: auto;
width: 650px;
}
#redx
{
height: 20px;
width: 20px;
color: black;
background: red;
overflow: auto;
display: inline-block;
margin-left: 650px;
margin-top: -20px;
padding: auto;
}
#console
{
font-size: 15;
overflow-x: hidden;
}
br
{
margin: 0;
}
input
{
margin: 0;
}
</style>
<div id="headbar">
<p style ="margin-left: 5">file://C:/Documents%20and%20Settings/User/Desktop/th-df.html</p>
</div>
<div id="redx">
X
</div>
<div id = "console">
<script>
function output(text)
{
document.write(text);
}
function endl()
{
document.write("<br/>");
}
function input()
{
return 0;
}
output("1");
endl();
output("2");
output("3");
var foo = input();   
output(foo);
</script>
</div>
</body>
</html>

0 个答案:

没有答案