Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/363.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/jsp/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 控制台模拟器。帮助编写输入函数_Javascript_Html_Input_Console_Emulation - Fatal编程技术网

Javascript 控制台模拟器。帮助编写输入函数

Javascript 控制台模拟器。帮助编写输入函数,javascript,html,input,console,emulation,Javascript,Html,Input,Console,Emulation,对于我正在进行的一个项目,我有一个控制台模拟器,如下所示,但我遇到了一个问题;接收用户输入。我需要它来创建一个文本框,等待用户按enter键,然后返回文本框中的值,或者如果按下enter键时文本框为空,则使用另一个文本框移动到下一行,直到接收到输入,但是,其他方法只要提供这种类型的输入即可。执行此操作的代码应放在函数输入中。在以下代码中,div“console”应为: 1 23[textbox] [whatever the user entered] 如果有人能给我展示一个能实现这个功能的函数

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

1
23[textbox]
[whatever the user entered]
如果有人能给我展示一个能实现这个功能的函数,我将不胜感激


你不是真的在寻求帮助。我建议你做更多的研究。像处理用户输入javascript、HTML输入文本、javascript检测关键事件、javascript获取输入值、HTML javascript添加元素、HTML javascript更改输入值。不要只输出纯文本-使用HTML元素-为用户inputvar myUserValue=提示“输入您的值:”,使用HTML文本输入;函数outputtext{document.write+text+

;}函数endl{document.write;}函数handleInput{var userPut;userPut=parseIntdocument.getElementById'userInput.value;返回userPut;}函数输入{document.write;}输出1;endl;输出2;输出3;输入var foo=手动输入;outputfoo;
<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>