关于母窗口与子窗口的参数传递问题

starpan 2003-10-17 10:55:52
我在一个母窗口(send.asp)中调用子窗口(ShowAdd.asp)在传递参数的时候
为什么系统提示"window.opener.document"为空或不是对象呢?谢谢
...全文
57 6 打赏 收藏 转发到动态 举报
写回复
用AI写文章
6 条回复
切换为时间正序
请发表友善的回复…
发表回复
hover_online 2003-10-17
  • 打赏
  • 举报
回复
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<meta name="GENERATOR" content="Microsoft FrontPage 4.0">
<meta name="ProgId" content="FrontPage.Editor.Document">
<title>子父窗口的操作</title>
</head>
<body>
<script>
var win=null;
function op(){
win=window.open("about:blank","win","width=200,height=200");
win.document.write("<input type='button' value='关闭父窗口' onclick='window.opener.opener=null;window.opener.close()'>");
win.document.write("<input type='button' value='刷新你窗口' onclick='window.opener.location.reload()'>");
}
</script>
<input onclick="op()" value="打开窗口" type="button"><input type="button" value="最小化" onclick="if(win&&win.open&&!win.closed){win.resizeTo(0,0);win.moveTo(0,window.screen.width);}else alert('还没有打开窗口或已经关闭')"><input type="button" value="最大化" onclick="if(win&&win.open&&!win.closed){win.moveTo(-4,-4);win.resizeTo(screen.availWidth+8,screen.availHeight+8);}else alert('还没有打开窗口或已经关闭');"><input type=button value="关闭子窗口" onclick="if(win&&win.open&&!win.closed){win.opener=null;win.close()}else alert('还没有打开窗口或已关闭')"><input type=button value="刷新子窗口" onclick="if(win&&win.open&&!win.closed){win.location.reload();win.focus()}else alert('窗口还没有打开或已关闭')"><input type="button" value="看子窗口的大小" onclick="if(win&&win.open&&!win.closed){alert(win.document.body.clientWidth+'*'+win.document.body.clientHeight);win.focus();}else{alert('还没有打开窗口或者已关闭')};">
</body>
</html>
bluemoon0001 2003-10-17
  • 打赏
  • 举报
回复
把onClick="window.open("../account/showAdd.asp","","width=500,height=450")" 换成
onClick="window.open('../account/showAdd.asp','','width=500,height=450')"
因为你的单引号"在这里是不行的,要用'才可以。
starpan 2003-10-17
  • 打赏
  • 举报
回复
我就是用window.opener.mainform这个方法的
lovehwq21 2003-10-17
  • 打赏
  • 举报
回复
直接用window.opener.mainform呢?
starpan 2003-10-17
  • 打赏
  • 举报
回复
send.asp调用子窗口的代码:
<tr>
<td>接收手机:</td>
<td>
<input name="RecipientMobile" size="27" value maxlength="100">
<img src="/images/button/contactse.gif" alt="手机号码簿" border="0" onClick="window.open("../account/showAdd.asp","","width=500,height=450")" style="cursor:hand" align="absbottom">
</td>
</tr>

showadd.asp:

<%@ Language=VBScript %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>Address List</title>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<script language=javascript>

function filterEmail(multivalue,singlevalue){
alert(multivalue);
var nFirst = 0;
if(multivalue=="") return true;
if(multivalue.indexOf(",")==-1){
if(multivalue==singlevalue) return false;
}
for(var i=0;i<multivalue.length;i++){
if(multivalue.charAt(i)==","){
subvalue = multivalue.substring(nFirst,i);
nFirst = i + 1;
if(subvalue==singlevalue){
return false;
}
}
}
subvalue=multivalue.substring(nFirst,multivalue.length);
if(subvalue==singlevalue) return false;
return true;
}

function SubmitForm(formName) {
var frm = document.edit;
var elms = frm.elements;
var recipient = "";
var contactname = "";
for (var i=0; i<elms.length; i++) {
if (elms[i].type == "checkbox" && elms[i].checked) {
contactname = elms[i].name;
if((elms[i].value!="")&&filterEmail(recipient,elms[i].value)&&filterEmail(window.opener.document.mainform.RecipientMobile.value,elms[i].value)){
recipient +=elms[i].value;
recipient +=",";
}
}
}
if (recipient.length >0)
//alert("success");
recipient = recipient.substring(0,recipient.length-1);
try{
if((contactname == "mobileNum")&&(recipient!="")) {
if(window.opener.document.mainform.RecipientMobile.value == "")
window.opener.document.mainform.RecipientMobile.value = recipient;
else {
window.opener.document.mainform.RecipientMobile.value +=",";
window.opener.document.mainform.RecipientMobile.value += recipient;
}
}
}
catch(e){}
window.close();
}
</script>
<body bgcolor="#FFFFFF" text="#000000" leftmargin="0" topmargin="0" marginwidth="0" marginheight="0">
<form name="edit" method="post" id="edit">
<table width="90%" cellpadding="0" cellspacing="0" border="0" align="center">
<tr>
<td width="625" valign="top">
<table width="100%" cellpadding="0" cellspacing="0" border="0">
<tr>
<td width="30" bgcolor="#e1e1e1">  </td>
<td class="titlebg10pt" width="125" bgcolor="#e1e1e1" align="center"><b>
姓名</b></td>
<td class="titlebg10pt" nowrap width="154" bgcolor="#e1e1e1" align="center"><b>
移动电话</b></td>
<td class="titlebg10pt" width="136" bgcolor="#e1e1e1" align="center"><b>
Email</b></td>
</tr>
</table>

<table id="addressList" border="1" cellspacing="0" cellpadding="0" bordercolorlight="#E1E1E1" bordercolordark="#FFFFFF" width="100%">
<%for i = 1 to ubound(name)%>
<tr>
<td align="center" width="30" height="19">
<input type="checkbox" name="mobileNum" value="1">
</td>
<td class="t9pt" width="125" height="19" align="center">
<%=name(i)%> </td>
<td class="t9pt" width="154" height="19" align="center">
<%=mobile(i)%></td>
<td class="t9pt" width="136" height="19" align="center">
<span id="email"><%=email(i)%></span> </td>
</tr>
<%next%>
</table>
<tr>
<div align="center"><a href="javascript:SubmitForm();"><img src="/images/button/done.gif" width="70" height="22" border="0" hspace="0" vspace="5"></a>
<a href="javascript:window.close();"> <img src="/images/button/winclose.gif" width="70" height="22" border="0" hspace="0" vspace="5"></a>
</div>
</td>
</tr>

</table>
xxrl 2003-10-17
  • 打赏
  • 举报
回复
完全代码!

28,391

社区成员

发帖
与我相关
我的任务
社区描述
ASP即Active Server Pages,是Microsoft公司开发的服务器端脚本环境。
社区管理员
  • ASP
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧