浏览器打开 Page1.jsp,单击按钮,弹出输入框,输入完毕,单击确定,Page1.jps内的输入框出现相应录入信息。
password_box.jsp 对话框页面代码
------------------------------------------------------------
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
<script lang="javascript">
function OnClose(check)
{
if(check == true)
{
var value = document.getElementById("password").value;
window.returnValue = value;
}
window.close();
}
</script>
</head>
<body scroll="no">
<div style="width:200px; left:10px; top:20px; position:relative; height:55px">
<div style="width:208px; left:0px; top:0px; position:absolute; height:24px">
<font class="big1_text">输入审核密码</font>
</div>
<div style="width:auto; left:114px; top:0px; position:absolute; height:20px">
<input type="text" id="password" size="12" maxlength="20"/>
</div>
<div style="width:60px; left:170px; top:30px; position:relative; height:20px">
<input type="button" value="确认" οnclick="OnClose(true)" />
</div>
</div>
</body>
</html>
-------------------------------------------------------------------------------------------
Page1.jsp 调用页面代码
---------------------------------------------------------------------------------------
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>JSP Page</title>
<script language="javascript" type="text/javascript">
function ShowPasswordBox()
{
// 显示密码输入框
var pwd =window.showModalDialog("password_box.jsp","box","dialogHeight: 100px; dialogWidth:200px; edge: Sunken; center: Yes; resizable: No; status: No;");
if(pwd)
{
// 设置显示内容为输入框中的内容
document.getElementById("showpwd").value = pwd;
}
}
</script>
</head>
<body>
<input type="button" value="button" οnclick="ShowPasswordBox()"/>
<input type="text" name="showpwd" id="showpwd" />
</body>
</html>