看看下面这个吧,相信对你有帮助!sd.htm<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>TSD</title>
<SCRIPT language="javascript">
<!--
function OpenWin()
{
var getv = showModalDialog("eg.htm", "egwin", "dialogWidth:420px; dialogHeight:220px;status:no;help:yes");
if (getv != null){
document.getElementById('mydiv').innerHTML=getv;
}
}//-->
</SCRIPT>
<style type="text/css">
<!--
.style1 {color: #3366FF}
-->
</style>
<script language="JavaScript" type="text/JavaScript">
<!--
function MM_reloadPage(init) { //reloads the window if Nav4 resized
if (init==true) with (navigator) {if ((appName=="Netscape")&&(parseInt(appVersion)==4)) {
document.MM_pgW=innerWidth; document.MM_pgH=innerHeight; onresize=MM_reloadPage; }}
else if (innerWidth!=document.MM_pgW || innerHeight!=document.MM_pgH) location.reload();
}
MM_reloadPage(true);
//-->
</script>
</head><body>
<div id="mydiv" style="position:absolute; left:397px; top:164px; width:226px; height:140px; z-index:1; background-color: #CCCCCC; layer-background-color: #CCCCCC; border: 1px none #000000;">这是一个名为mydiv的图层,返回值将显示在这里</div>
<div align="center">
<p> </p>
<p> </p>
<p> </p>
<p>
<input type="button" name="Submit" value="打开" onClick="OpenWin()">
</p>
<p> </p>
</div>
</body>
</html>--------------------------------------------
eg.htm<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>TSD</title>
<SCRIPT language="javascript">
<!--
function GetValue()
{
window.returnValue=TextName.value
window.close();
}//-->
</SCRIPT></head><body>
<p> </p>
<p> </p>
<p align="center"> </p>
<p align="center">
<input name="TextName" type="text" id="TextName" value="因为有你而精彩">
<input type="button" name="Submit" value="关闭" onClick="GetValue()">
</p>
</body>
</html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>TSD</title>
<SCRIPT language="javascript">
<!--
function OpenWin()
{
var getv = showModalDialog("eg.htm", "egwin", "dialogWidth:420px; dialogHeight:220px;status:no;help:yes");
if (getv != null){
document.getElementById('mydiv').innerHTML=getv;
}
}//-->
</SCRIPT>
<style type="text/css">
<!--
.style1 {color: #3366FF}
-->
</style>
<script language="JavaScript" type="text/JavaScript">
<!--
function MM_reloadPage(init) { //reloads the window if Nav4 resized
if (init==true) with (navigator) {if ((appName=="Netscape")&&(parseInt(appVersion)==4)) {
document.MM_pgW=innerWidth; document.MM_pgH=innerHeight; onresize=MM_reloadPage; }}
else if (innerWidth!=document.MM_pgW || innerHeight!=document.MM_pgH) location.reload();
}
MM_reloadPage(true);
//-->
</script>
</head><body>
<div id="mydiv" style="position:absolute; left:397px; top:164px; width:226px; height:140px; z-index:1; background-color: #CCCCCC; layer-background-color: #CCCCCC; border: 1px none #000000;">这是一个名为mydiv的图层,返回值将显示在这里</div>
<div align="center">
<p> </p>
<p> </p>
<p> </p>
<p>
<input type="button" name="Submit" value="打开" onClick="OpenWin()">
</p>
<p> </p>
</div>
</body>
</html>--------------------------------------------
eg.htm<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>TSD</title>
<SCRIPT language="javascript">
<!--
function GetValue()
{
window.returnValue=TextName.value
window.close();
}//-->
</SCRIPT></head><body>
<p> </p>
<p> </p>
<p align="center"> </p>
<p align="center">
<input name="TextName" type="text" id="TextName" value="因为有你而精彩">
<input type="button" name="Submit" value="关闭" onClick="GetValue()">
</p>
</body>
</html>
function openWin()
{
var sReturn = window.showModalDialog("in.htm","","dialogHeight:200px;dialogWidth:400px");
var sUserName = sReturn.split("|")[0];
var sUserPwd = sReturn.split("|")[1];
show.innerHTML="UserName:"+sUserName+"\nUserPwd:"+sUserPwd;
}
</script>
<a href="JavaScript:openWin()">OpenWin</a>
<div id="show"></div>in.htm<style>
body
{
font-size:9pt;
background-color:D6D3CE;
margin-top:10px;
margin-left:10px;
}
</style>
<script>
function SubIt()
{
var sUserName = document.all.username.value;
var sUserPwd = document.all.userpwd.value;
var sReturn = sUserName+"|"+sUserPwd;
window.returnValue = sReturn;
window.close();
}
</script>
<form>
username:<input type="text" name="username"><br>
userpwd:<input type="text" name="userpwd"><br>
<input type="button" value="确定" onclick="SubIt()">
</form>