输入对话框的实现 怎么能实现 象confrim那样的对话框 有“确定”和“取消“ 按钮(样式象confrim 但不是prompt) 不过在他们(“确定”和“取消“)上面有一个可输入内容的输入框 程序中可以用变量接受输入的内容 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 prompt()方法该对话框提示用户输入某些信息除OK按钮和Cancel按钮外,该对话框还有文本框,要求用户在此输入某些数据。该方法接受两个参数,即要显示给用户的文本和文本框中的默认文本(可以是空串)。例如:var sResult = prompt("name", "");if(sResult) alert("you are "+sResult);如果点击OK按钮,将文本框中的值作为函数值返回。如果点击Cancel按钮,返回null。 你自己模拟可以,但是要效果好的话就要下一番功夫,其实prompt就可以满足你的要求,不知道你为什么不用 HOHO,prompt的输入框好像是在下面吧!用showModalDialog可以实现.不过画面布局当然要你自己来做了.用法,google一下就可以了. prompt可以设置大小吗 初始时候太大了 效果不是太好 一般用showModalDialog模拟index.html文件:<script>function hehe(){ var name = "hehe"; var result = window.showModalDialog("hehe2.html",name,"dialogLeft=100;dialogTop=150;dialogWidth=500px;dialogHeight=300px;status=no"); var haha = document.getElementById("haha"); haha.value = result;}</script><body><input type="button" value="Test" onclick="hehe();" /><input type="text" id="haha" /></body>hehe2.html文件:<script>function hehe(){ var name = window.dialogArguments; var hehe = document.getElementById("hehe"); hehe.value = name;}function haha(){ window.returnValue = "haha";}window.onload=hehe;window.onunload=haha;</script><body bgColor="#FF7788"><input type="text" id="hehe" /></body> ShowModalDialog函数的功能:打开一个子窗口,并且可与父窗口相互传递数据,它与window.open的最大区别就在于由ShowModalDialog打开子窗口后,父窗口将不能操作。使用方法:vReturnValue = window.showModalDialog(sURL [, vArguments] [, sFeatures])参数说明:sURL必选参数,类型:字符串。用来指定对话框要显示的文档的URL。vArguments可选参数,类型:变体。用来向对话框传递参数。传递的参数类型不限,包括数组等。对话框通过window.dialogArguments来取得传递进来的参数。sFeatures可选参数,类型:字符串。用来描述对话框的外观等信息,可以使用以下的一个或几个,用分号“;”隔开。 dialogHeight 对话框高度,不小于100px,IE4中dialogHeight 和 dialogWidth 默认的单位是em,而IE5中是px,为方便其见,在定义modal方式的对话框时,用px做单位。 dialogWidth: 对话框宽度。 dialogLeft: 距离桌面左的距离。 dialogTop: 离桌面上的距离。 center: {yes | no | 1 | 0 }:窗口是否居中,默认yes,但仍可以指定高度和宽度。 help: {yes | no | 1 | 0 }:是否显示帮助按钮,默认yes。 resizable: {yes | no | 1 | 0 } [IE5+]:是否可被改变大小。默认no。 status: {yes | no | 1 | 0 } [IE5+]:是否显示状态栏。默认为yes[ Modeless]或no [Modal]。 scroll:{ yes | no | 1 | 0 | on | off }:指明对话框是否显示滚动条。默认为yes。参数传递方法:父窗口向子窗口传递参数采用ShowModalDialog的第2个参数即可,父窗口要获取子窗口传回的参数则可通过ShowModalDialog函数的返回值获取。子窗口获取父窗口参数的方法为采用子窗口window对象dialogArguments属性获取,例如:var a=window.dialogArguments;子窗口向父窗口返回参数采用window.returnValue属性,如:window.returnValue=1;window.close(); 做个sample供你参考一下.<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"><html> <head> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> <title>Untitled Document</title> </head> <script language="JavaScript"> function doSel(){ var ret = showModalDialog("popup.html"); if(ret.btn == 1) document.getElementById("text1").value = ret.value; } </script> <body> <input type="text" id="text1" value=""><input type="button" value="select" onclick="doSel();"> </body></html>弹出窗口popup.html<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"><html> <head> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> <title>Untitled Document</title> </head> <script language="JavaScript"> function doRet(btn){ var retVal = {}; retVal.btn = btn; retVal.value = document.getElementById("text1").value; window.returnValue = retVal; close(); } </script> <body> please Input:<br> <input type="text" id="text1" value=""> <br> <input type="button" value="ok" onclick="doRet(1);"> <input type="button" value="cancel" onclick="doRet(0);"> </body></html> Jquery 不能修改样式!急在线等! 这个使用的什么技术? 问各位个简单的正则表达式。 关于双层iframe高度自适应的问题 如何同时显示两棵梅花树 VBscript 里 chr() 与 chrB()到底什么区别???我快疯了!!! 如何得到IE标题栏的拖动事件,禁止拖动 请教一个简单的关于window.event.srcElement的问题。谢谢 javasript 如何实现打开网页时的_blank功能 如何自动生成邮件? 求一个正则表达式(偶数字符匹配) 如何通过js实现最近浏览功能?
该对话框提示用户输入某些信息
除OK按钮和Cancel按钮外,该对话框还有文本框,要求用户在此输入某些数据。
该方法接受两个参数,即要显示给用户的文本和文本框中的默认文本(可以是空串)。
例如:
var sResult = prompt("name", "");
if(sResult) alert("you are "+sResult);
如果点击OK按钮,将文本框中的值作为函数值返回。如果点击Cancel按钮,返回null。
不知道你为什么不用
prompt的输入框好像是在下面吧!用showModalDialog可以实现.
不过画面布局当然要你自己来做了.
用法,google一下就可以了.
index.html文件:
<script>
function hehe()
{
var name = "hehe";
var result = window.showModalDialog("hehe2.html",name,"dialogLeft=100;dialogTop=150;dialogWidth=500px;dialogHeight=300px;status=no");
var haha = document.getElementById("haha");
haha.value = result;
}
</script>
<body>
<input type="button" value="Test" onclick="hehe();" />
<input type="text" id="haha" />
</body>
hehe2.html文件:
<script>
function hehe()
{
var name = window.dialogArguments;
var hehe = document.getElementById("hehe");
hehe.value = name;
}
function haha()
{
window.returnValue = "haha";
}
window.onload=hehe;
window.onunload=haha;
</script>
<body bgColor="#FF7788">
<input type="text" id="hehe" />
</body>
打开一个子窗口,并且可与父窗口相互传递数据,它与window.open的最大区别就在于由ShowModalDialog打开子窗口后,父窗口将不能操作。
使用方法:
vReturnValue = window.showModalDialog(sURL [, vArguments] [, sFeatures])
参数说明:
sURL
必选参数,类型:字符串。用来指定对话框要显示的文档的URL。
vArguments
可选参数,类型:变体。用来向对话框传递参数。传递的参数类型不限,包括数组等。对话框通过window.dialogArguments来取得传递进来的参数。
sFeatures
可选参数,类型:字符串。用来描述对话框的外观等信息,可以使用以下的一个或几个,用分号“;”隔开。
dialogHeight 对话框高度,不小于100px,IE4中dialogHeight 和 dialogWidth 默认的单位是em,而IE5中是px,为方便其见,在定义modal方式的对话框时,用px做单位。
dialogWidth: 对话框宽度。
dialogLeft: 距离桌面左的距离。
dialogTop: 离桌面上的距离。
center: {yes | no | 1 | 0 }:窗口是否居中,默认yes,但仍可以指定高度和宽度。
help: {yes | no | 1 | 0 }:是否显示帮助按钮,默认yes。
resizable: {yes | no | 1 | 0 } [IE5+]:是否可被改变大小。默认no。
status: {yes | no | 1 | 0 } [IE5+]:是否显示状态栏。默认为yes[ Modeless]或no [Modal]。
scroll:{ yes | no | 1 | 0 | on | off }:指明对话框是否显示滚动条。默认为yes。
参数传递方法:
父窗口向子窗口传递参数采用ShowModalDialog的第2个参数即可,父窗口要获取子窗口传回的参数则可通过ShowModalDialog函数的返回值获取。
子窗口获取父窗口参数的方法为采用子窗口window对象dialogArguments属性获取,例如:
var a=window.dialogArguments;
子窗口向父窗口返回参数采用window.returnValue属性,如:
window.returnValue=1;
window.close();
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title>Untitled Document</title>
</head>
<script language="JavaScript">
function doSel(){
var ret = showModalDialog("popup.html");
if(ret.btn == 1)
document.getElementById("text1").value = ret.value;
}
</script>
<body>
<input type="text" id="text1" value=""><input type="button" value="select" onclick="doSel();">
</body>
</html>弹出窗口
popup.html
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title>Untitled Document</title>
</head>
<script language="JavaScript">
function doRet(btn){
var retVal = {};
retVal.btn = btn;
retVal.value = document.getElementById("text1").value;
window.returnValue = retVal;
close();
}
</script>
<body>
please Input:<br>
<input type="text" id="text1" value="">
<br>
<input type="button" value="ok" onclick="doRet(1);">
<input type="button" value="cancel" onclick="doRet(0);">
</body>
</html>