问个简单的问题:窗口之间如何传值?? window.opener.form1.text1.value=form2.text2.value..... 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 1.htm<form name="form1" method="post" action=""> <input type="text" name="txt"> <input type="submit" name="Submit" value="Submit" onclick="window.open('2.asp')"></form>2.htm<script language="JavaScript" type="text/JavaScript">window.opener.form1.txt.value="ok"window.close()</script> 给你一个好理解点的例子,希望能对你有所帮助第一个文件:main.htm<!--author:zangleo filename:main.htm--><html><head><title>JavaScript示例</title></head><script language="javascript">function openOtherPage(){ window.open("sub.htm");}</script><body><input type="text" id="txtMain" value=""><input type="button" value="打开子页面" onclick="openOtherPage()"></body></html>第二个文件 sub.htm<!--author:zangleo filename:sub.htm--><html><head><title>JavaScript示例</title></head><script language="javascript">function returnValue(){ window.opener.txtMain.value=txtSub.value;}</script><body><input type="text" id="txtSub" width="200" value="Input a value"><input type="button" value="返回值" onclick="returnValue()"></body></html> 但是当副页面是公用是呢??例如副页面是用来设置一些属性时!!!无法在副页面确定主页面中input的name?? window.opener;返回打开本窗口的窗口对象你把window.opener这个弄清楚就行了~ 静态页面的值传递(三部曲). wanghr100 [原作] http://dev.csdn.net/develop/article/29/29975.shtm 因为偶对js从没怎么编写过,以前都是直接拿来用的,所以很多细节真不懂呵!这边其实是这样的:设置显示模板,主窗口是很多条款,比如,物品名称,物品价格,物品描述,物品产地等等,每个条款下有相关hidden类型的input,然后后面是"类型选择"链接,打开副窗口是属性页面,如字体,大小,颜色等等; 每次点击类型选择打开副窗口,选择属性后返回,最后按确认,把每个条款的相关属性存入DB中 有一点,上面的例子中子窗口是已知父窗口的ID或Name值了:window.opener.txtMain.value=txtSub.value; 但这里需要有可能txtMain不固定; 也就是第一次是这样:window.opener.txtMain.value=txtSub.value另一次需要赋的是: window.opener.bakMain.value=txtSub.value --------- Scl_main.asp --------<% Dim strTT1 If Request.Form("TT1") <> "" Then strTT1 = Trim(Request.Form("TT1")) Else strTT1 = "大连理工大学" End If%><html> <head> <title>Login</title> <script language="javascript"> <!-- function Win_open() { window.open("Scl_sub.asp",'newwindow', 'height=100, width=400, top=0,left=0, toolbar=no, menubar=no, scrollbars=no, resizable=no,location=no, status=no'); } //--> </script> </head> <body> <form name="form1"> <table> <tr> <td> <input type="buttom" name="B1" value="修改" onclick="Win_open();"> </td> <td> 学校名称:<input name="T1" size="30" value="<%= strTT1 %>" disabled> </td> </tr> </table> </form> </body></html>-------- Scl_sub.asp ----------<html> <head> <title>PhoneCode</title> <script language="javascript"> <!-- function Win_close() { if (document.form1.TT1.value == '') { alert(" 必須填学校名!"); } else { form1.method = 'post'; form1.target='_self'; form1.action='Scl_main.asp'; form1.submit(); alert("学校名修改成功"); window.close(); } } //--> </script> </head> <body> <form name="form1"> <table> <tr> <td> <input type="submit" name="B1" value="提交" onclick="Win_close();"> </td> </tr> <tr> <td> 请输入学校名: </td> <td> <input type="text" name="TT1" size="20"> </td> </tr> </table> </form> </body></html> 怎么实现用户名第一个不能是数字 鼠标经过延迟时间 设置。。。 紧急!有10条规则,可以任意制定,比如如果第2条到第5条有1条不符合 关于jquery取值的问题 求一个验证FQDN的正则表达式!不是域名! ext3.2 ajax传值 大哥们。。帮我一下。只能发这一个了。。 最新版本chrome(版本 30.0.1599.69 m) iframe 加载时自适应高度失效! firefox中实现ie的showModalDialog效果,但modal=yes不管用。 急:怎么读取表格中的数据,在线等! checkbox复选框的值传递问题 clip的小问题
<form name="form1" method="post" action="">
<input type="text" name="txt">
<input type="submit" name="Submit" value="Submit" onclick="window.open('2.asp')">
</form>
2.htm
<script language="JavaScript" type="text/JavaScript">
window.opener.form1.txt.value="ok"
window.close()
</script>
<!--author:zangleo filename:main.htm-->
<html>
<head>
<title>JavaScript示例</title>
</head>
<script language="javascript">
function openOtherPage(){
window.open("sub.htm");
}
</script>
<body>
<input type="text" id="txtMain" value="">
<input type="button" value="打开子页面" onclick="openOtherPage()">
</body>
</html>第二个文件 sub.htm
<!--author:zangleo filename:sub.htm-->
<html>
<head>
<title>JavaScript示例</title>
</head>
<script language="javascript">
function returnValue(){
window.opener.txtMain.value=txtSub.value;
}
</script>
<body>
<input type="text" id="txtSub" width="200" value="Input a value">
<input type="button" value="返回值" onclick="returnValue()">
</body>
</html>
例如副页面是用来设置一些属性时!!!
无法在副页面确定主页面中input的name??
http://dev.csdn.net/develop/article/29/29975.shtm
这边其实是这样的:设置显示模板,主窗口是很多条款,比如,物品名称,物品价格,物品描述,物品产地等等,每个条款下有相关hidden类型的input,然后后面是"类型选择"链接,打开副窗口是属性页面,如字体,大小,颜色等等;
每次点击类型选择打开副窗口,选择属性后返回,
最后按确认,把每个条款的相关属性存入DB中
window.opener.txtMain.value=txtSub.value;
但这里需要有可能txtMain不固定;
也就是第一次是这样:window.opener.txtMain.value=txtSub.value
另一次需要赋的是: window.opener.bakMain.value=txtSub.value
Dim strTT1
If Request.Form("TT1") <> "" Then
strTT1 = Trim(Request.Form("TT1"))
Else
strTT1 = "大连理工大学"
End If
%><html>
<head>
<title>Login</title>
<script language="javascript">
<!--
function Win_open()
{
window.open("Scl_sub.asp",'newwindow', 'height=100, width=400, top=0,left=0, toolbar=no, menubar=no, scrollbars=no, resizable=no,location=no, status=no');
}
//-->
</script>
</head>
<body>
<form name="form1">
<table>
<tr>
<td>
<input type="buttom" name="B1" value="修改" onclick="Win_open();">
</td>
<td>
学校名称:<input name="T1" size="30" value="<%= strTT1 %>" disabled>
</td>
</tr>
</table>
</form>
</body>
</html>-------- Scl_sub.asp ----------<html>
<head>
<title>PhoneCode</title>
<script language="javascript">
<!--
function Win_close()
{
if (document.form1.TT1.value == '')
{
alert(" 必須填学校名!");
}
else
{
form1.method = 'post';
form1.target='_self';
form1.action='Scl_main.asp';
form1.submit();
alert("学校名修改成功");
window.close();
}
}
//-->
</script>
</head>
<body>
<form name="form1">
<table>
<tr>
<td>
<input type="submit" name="B1" value="提交" onclick="Win_close();">
</td>
</tr>
<tr>
<td>
请输入学校名:
</td>
<td>
<input type="text" name="TT1" size="20">
</td>
</tr>
</table>
</form>
</body>
</html>