子窗口关闭是刷新父窗口的一个奇怪问题,快来啊!!

nakey2008 2003-08-19 11:21:40
我在WebForm1.aspx中的一个Button(asp控件)事件中用Page.RegisterStartupScript("rrr", "<script language=javascript>window.showModalDialog('WebForm2.aspx');</script>");打开一个窗口WebForm2.aspx,在WebForm2.aspx中用Button(asp控件)关闭子窗口,同时刷新父窗口,可如下语句都不起作用,不知为何?
1:Page.RegisterStartupScript("myJs","<SCRIPT LANGUAGE=\"JavaScript\">window.close();window.opener.location = window.opener.location.href;</SCRIPT>");
2:Response.Write ("<script>window.close();window.opener.parent.location='WebForm1.aspx';</script>");
3.Response.Write ("<script>window.close();top.dialogArguments.location.reload();</script>");
4.Page.RegisterStartupScript("CloseAndRefrsh","<script language='javascript'>window.close();window.opener=null;window.parent.lacation.reload();</script>");
5.Response.Write("<script>window.close();document.123.href='WebForm1.aspx';</"+"script>");
请大侠帮忙!!
...全文
158 8 打赏 收藏 转发到动态 举报
写回复
用AI写文章
8 条回复
切换为时间正序
请发表友善的回复…
发表回复
saucer 2003-08-20
  • 打赏
  • 举报
回复
did you forget to pass the second parameter??

showModalDialog('WebForm2.aspx',window);
^^^^^^^^^

are you using
<base target="_self">
in your WebForm2.aspx?

if you are using frames, try

Response.Write ("<script>top.dialogArguments.location.reload();top.close();</script>");

or

Response.Write ("<script>top.dialogArguments.document.forms[0].submit();top.close();</script>");
nakey2008 2003-08-20
  • 打赏
  • 举报
回复
归大侠:
你说的在运行时提示:
第一个提示:window.dialogArguments.location为空或不是对象。
第二个提示:window.dialogArguments.document为空或不是对象。
这是怎么回事?
nakey2008 2003-08-20
  • 打赏
  • 举报
回复
要散分,可提示“贴子回复次数大于跟给分次数”什么意思?
seesea125 2003-08-20
  • 打赏
  • 举报
回复
借楼上地皮问问
<base target="_self">这个是帧页面才可以用啊??
Response.Write ("<script>top.dialogArguments.location.reload();top.close();</script>");这样子窗口又打开了一个子窗口,而且没有关闭本窗口
nakey2008 2003-08-20
  • 打赏
  • 举报
回复
对了,加了window参数就可以了!^_^
现在总结一下:
1.要刷新(submit)
Response.Write ("<script>window.dialogArguments.document.forms[0].submit();window.close();</script>");
2.要重新请求页面:
Page.RegisterStartupScript("CloseAndRefresh","<script language='javascript'>window.close();window.opener=null;window.parent.location.href='WebForm1.aspx';</script>");
I)
nakey2008 2003-08-20
  • 打赏
  • 举报
回复
这在弹出的子窗口中用,否则关闭后又会弹出窗口
孟子E章 2003-08-19
  • 打赏
  • 举报
回复
http://xml.sz.luohuedu.net/xml/ShowDetail.asp?id=49ML4AO8-5PB3-4KNY-NJZD-LJOIOXV4M1X4
saucer 2003-08-19
  • 打赏
  • 举报
回复
Page.RegisterStartupScript("rrr", "<script language=javascript>window.showModalDialog('WebForm2.aspx', window);</script>");

....

Response.Write ("<script>window.dialogArguments.location.reload();window.close();</script>");

or

Response.Write ("<script>window.dialogArguments.document.forms[0].submit();window.close();</script>");

62,041

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术交流专区
javascript云原生 企业社区
社区管理员
  • ASP.NET
  • .Net开发者社区
  • R小R
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

.NET 社区是一个围绕开源 .NET 的开放、热情、创新、包容的技术社区。社区致力于为广大 .NET 爱好者提供一个良好的知识共享、协同互助的 .NET 技术交流环境。我们尊重不同意见,支持健康理性的辩论和互动,反对歧视和攻击。

希望和大家一起共同营造一个活跃、友好的社区氛围。

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