弹出窗口的值传回文本框怎么做? 如果是window.open打开的新窗口,则可以通过window.opener.取父窗口元素的方法赋值。如果是模态窗口,则可以通过window.dialogArguments 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 父页面://打开媒体选择页面function OpenPage(){var PageLeft = parseInt(window.screen.availWidth)/2-100;window.open("GetImgSort.aspx","left="+PageLeft+",scrollbars=yes,height=600,width=200,toolbar=no,menubar=no,location=no,scroll=yes");}//将返回值赋给文本框以便调用if(window.opener){ window.opener.document.getElementById("txtValue").value = value;}子窗口:在"关闭"事件中实现下面方法function ReturnValue("父页面文本框ID"){ var str="返回值"; opener.document.getElementById("父页面文本框ID").value=str; window.close();} 怎么用啊?能不能给出那种HTML代码,我想运行下看看 father.html<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml" ><head> <title>Untitled Page</title> <script language="javascript"> //打开媒体选择页面 function OpenPage() { window.open("children.html",""); } </script> </head><body> <input id="result" type="text" /> <input id="Button1" type="button" value="弹出对话框" onclick="OpenPage();" /></body></html>children.html<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml" ><head> <title>Untitled Page</title> <script language="javascript"> function ReturnValue() { var str="返回值"; opener.document.getElementById("result").value=str; window.close(); } </script> </head><body onunload="ReturnValue();"></body></html> 我把四楼(liuyilidan )的那个源码,改成完整的html的形式,可能是因为注释写的不太好的原因吧.那我重新写一下.在children.html页面中有一个ReturnValue()函数,在这个函数中有下面一句话:opener.document.getElementById("result").value=str; 这句话,就是在子页面(弹出的那个页面)中,操作父页面(father.html)里面的那个<input id="result" type="text" />这个控件的.你可以在子页面的"选择按钮"中,添加该事件,就可以实现你想要的那个效果了. 你用var s= window.showModalDialog();然后在要的页面用window.returnValue获取要得到的值 你用的是window.open()--->只要在子窗口向父窗口的隐藏<input type="hidden" name="name" id="value1" value="value">opener.document.getElementById("value1").value=str; //这样关闭后就会得到 子页面的参数了还是 return = windos.showModalDialog()在关闭之前 调用一下 window.returnValue=1; 这样的就可以了return的值 就是 1了。 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN""http://www.w3.org/TR/html4/loose.dtd"><html><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8"><title>無標題文件</title><script language="javascript"> function openPage(){ window.open("te.htm","flag","width=400,height=400,left=300,top=100,fullscreen=0,menubar=0,toolbar=0,status=0,resizable=o,scrollbar=1"); }</script></head><body>客戶名稱:<input type="text" name="provice" id="provice"> <a href="#" onClick="openPage()">>></a></body></html>te.htm<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN""http://www.w3.org/TR/html4/loose.dtd"><html><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8"><title>無標題文件</title></style><script language="javascript"> function bt_choose(v){ provice=v.parentNode.parentNode.cells[1].innerHTML; //alert(provice); window.opener.document.getElementById("provice").value = provice; window.close(); }</script></head><body><table width="349" height="288" border="1"> <tr bgcolor="#6699FF"> <td width="92">代號</td> <td width="141">名稱</td> <td width="94"> </td> </tr> <tr> <td>1</td> <td>鄭州</td> <td><input type="button" name="bt" value="選擇" onClick="bt_choose(this)"></td> </tr> <tr> <td>2</td> <td>洛陽</td> <td><input type="button" name="bt" value="選擇" onClick="bt_choose(this)"></td> </tr> <tr> <td>3</td> <td>開封</td> <td><input type="button" name="bt" value="選擇" onClick="bt_choose(this)"></td> </tr></table></body></html> 為了減少代碼,我把後面的幾行刪除了,所以顯示的窗口可能會大些,你只要把window.open("","")那一句的height什值改小一點就行了.希望能對你有用 jquery滑动隐藏或显示问题? 用JavaScript和Jquery怎么样实现两个标签相互切换 。 高手们帮我改造一个方法下 麻烦高手看一下 简单的html JavaScript 问题 一个关于页面刷新的问题,请指点 html Frame问题急需解答,高手请进 谁能告诉我style properties 和style有什么区别阿,为什么样式不同阿 js中,在事件里更改了全局变量的值,如何将更改后的值传给全局变量,让把全局变量的值 如何编写跨浏览器的javascript? 如何使用JS页面验证
//打开媒体选择页面
function OpenPage()
{
var PageLeft = parseInt(window.screen.availWidth)/2-100;
window.open("GetImgSort.aspx","left="+PageLeft+",scrollbars=yes,height=600,width=200,toolbar=no,menubar=no,location=no,scroll=yes");
}//将返回值赋给文本框以便调用
if(window.opener)
{
window.opener.document.getElementById("txtValue").value = value;
}子窗口:
在"关闭"事件中实现下面方法
function ReturnValue("父页面文本框ID")
{
var str="返回值";
opener.document.getElementById("父页面文本框ID").value=str;
window.close();
}
能不能给出那种HTML代码,我想运行下看看
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head>
<title>Untitled Page</title>
<script language="javascript">
//打开媒体选择页面
function OpenPage()
{
window.open("children.html","");
}
</script>
</head>
<body>
<input id="result" type="text" />
<input id="Button1" type="button" value="弹出对话框" onclick="OpenPage();" />
</body>
</html>
children.html
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head>
<title>Untitled Page</title>
<script language="javascript">
function ReturnValue()
{
var str="返回值";
opener.document.getElementById("result").value=str;
window.close();
}
</script>
</head>
<body onunload="ReturnValue();">
</body>
</html>
可能是因为注释写的不太好的原因吧.
那我重新写一下.
在children.html页面中有一个ReturnValue()函数,
在这个函数中有下面一句话:opener.document.getElementById("result").value=str; 这句话,就是在子页面(弹出的那个页面)中,操作父页面(father.html)里面的那个
<input id="result" type="text" />
这个控件的.你可以在子页面的"选择按钮"中,添加该事件,就可以实现你想要的那个效果了.
然后在要的页面用window.returnValue获取要得到的值
//这样关闭后就会得到 子页面的参数了还是 return = windos.showModalDialog()在关闭之前 调用一下 window.returnValue=1; 这样的就可以了return的值 就是 1了。
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>無標題文件</title>
<script language="javascript">
function openPage(){
window.open("te.htm","flag","width=400,height=400,left=300,top=100,fullscreen=0,menubar=0,toolbar=0,status=0,resizable=o,scrollbar=1");
}
</script>
</head><body>
客戶名稱:<input type="text" name="provice" id="provice">
<a href="#" onClick="openPage()">>>
</a>
</body>
</html>
te.htm
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>無標題文件</title></style>
<script language="javascript">
function bt_choose(v){
provice=v.parentNode.parentNode.cells[1].innerHTML;
//alert(provice);
window.opener.document.getElementById("provice").value = provice;
window.close();
}
</script>
</head><body>
<table width="349" height="288" border="1">
<tr bgcolor="#6699FF">
<td width="92">代號</td>
<td width="141">名稱</td>
<td width="94"> </td>
</tr>
<tr>
<td>1</td>
<td>鄭州</td>
<td><input type="button" name="bt" value="選擇" onClick="bt_choose(this)"></td>
</tr>
<tr>
<td>2</td>
<td>洛陽</td>
<td><input type="button" name="bt" value="選擇" onClick="bt_choose(this)"></td>
</tr>
<tr>
<td>3</td>
<td>開封</td>
<td><input type="button" name="bt" value="選擇" onClick="bt_choose(this)"></td>
</tr>
</table>
</body>
</html>
希望能對你有用