JavaScript 中用什么函数可以弹出一个窗口出来,并且可以输入字符串?

maohbao2 2003-08-22 04:12:54
JavaScript 中用什么函数可以弹出一个窗口出来,并且可以输入字符串?
怎样接收这个字符串? 希望能有一个例子,谢谢!!!
...全文
80 12 打赏 收藏 转发到动态 举报
写回复
用AI写文章
12 条回复
切换为时间正序
请发表友善的回复…
发表回复
wjcking 2003-08-24
  • 打赏
  • 举报
回复
可以,用window.open或showmodeldialg做
maohbao2 2003-08-24
  • 打赏
  • 举报
回复
我可不可以弹出一个窗口里面有两个输入框啊?
majunbo 2003-08-24
  • 打赏
  • 举报
回复
up
maohbao2 2003-08-24
  • 打赏
  • 举报
回复
我可不可以弹出一个窗口里面有两个输入框啊?
voidroom 2003-08-22
  • 打赏
  • 举报
回复
function inp()
{
var msg;
msg=prompt("请输入字符串:","输入这里");
alert("输入信息是:"+msg);
}
voidroom 2003-08-22
  • 打赏
  • 举报
回复
confirm("msg")返回yes or no
voidroom 2003-08-22
  • 打赏
  • 举报
回复
prompt("title","value")
alert("msg")
confirm("msg")
wjcking 2003-08-22
  • 打赏
  • 举报
回复
up
hansun 2003-08-22
  • 打赏
  • 举报
回复
prompt method
Displays a Prompt dialog box with a message and an input field.

语法
prompt(message, [inputDefault])
message is any string or a property of an existing object; the string is displayed as the message.
inputDefault is a string, integer, or property of an existing object that represents the default value of the input field.
kingdomzhf 2003-08-22
  • 打赏
  • 举报
回复
up
slumcherry 2003-08-22
  • 打赏
  • 举报
回复
<html>
<head>
<title>
</title>
<script language="javascript">
<!--
function show()
{
var name
name=window.prompt("please enter your name:","")
window.alert(name)

}
//-->
</script>
</head>
<body>
<input type="button" name="button1" value="click" onclick="show()">
</body>
</html>
这个例子是点击按钮才出现对话框,且名字是由一新的窗口显示。如果想显示到页面上,只用把
window.alert(name)换成:
document.write(name)
document.close()
如果想页面完全载入后直接弹出窗口,则如下:
<html>
<head>
<title>
</title>
<script language="javascript">
<!--
function show()
{
var name
name=window.prompt("please enter your name:","")
document.write(name)
document.close()
}
//-->
</script>
</head>
<body onload="show()">
</body>
</html>
meizz 2003-08-22
  • 打赏
  • 举报
回复
var mm = prompt("提示", "缺省值");
alert(mm);

87,901

社区成员

发帖
与我相关
我的任务
社区描述
Web 开发 JavaScript
社区管理员
  • JavaScript
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧