JavaScript:不从代码后面调用JavaScript函数

JavaScript:不从代码后面调用JavaScript函数,javascript,asp.net,Javascript,Asp.net,我已经制作了一个.aspx页面来上传图像文件 第1页-在这里,我使用window.open(小尺寸,如dialogbox)在js中打开Page2.aspx 然后,在第2页Javascript中,我使用下面的WindowRefresh()函数刷新第1页并关闭第2页(一旦文件上传完成) 这就是我使用“window.opener.location.href”引用父页面(第1页)的原因 在第2页中,我使用下面的Windowrefresh()函数刷新父窗口,它将关闭上载对话框窗口 function Wi

我已经制作了一个.aspx页面来上传图像文件

第1页-在这里,我使用window.open(小尺寸,如dialogbox)在js中打开Page2.aspx

然后,在第2页Javascript中,我使用下面的WindowRefresh()函数刷新第1页并关闭第2页(一旦文件上传完成)

这就是我使用“window.opener.location.href”引用父页面(第1页)的原因

在第2页中,我使用下面的Windowrefresh()函数刷新父窗口,它将关闭上载对话框窗口

 function Windowrefresh() {
        if (window.navigator.appName == "Netscape") {
            window.opener.location.href = window.opener.location.href;
            window.opener.location.reload(true);
            self.close();
        }
        else if (window.navigator.appName == "Microsoft Internet Explorer") {
            window.opener.location.href = window.opener.location.href;
            window.opener.location.reload(true);
            window.close();
        }
    }
现在,当一个会话变量有一些值时,我想从第2页的代码后面调用这个函数

我试过下面的东西

ClientScript.RegisterStartupScript(this.GetType(), "key", "Windowrefresh();", true);
以及

但它既不是刷新第1页,也不是结束第2页


我不知道这是怎么回事。

做点这样的事。。我还没有测试代码。。。。。。在儿童窗口


当您有会话变量时,关闭子窗口…(我不知道asp,因此无法帮助您使用该语法)

检查控制台是否有任何错误。此块多久被命中一次
window.navigator.appName==“Netscape”
。加载我打赌。
window.opener.location.href=window.opener.location.href?您正在调用代码刷新页面。。。当页面刚刚被回发刷新时?你为什么要这样做?回邮并没有让它恢复活力。它只是停留在上传文件对话框页面上。Srikanth-感谢您的回复。我正在尝试你的代码。但是,我将无法访问body标记中的Session变量来检查这次是否必须刷新parent。这就是我想从代码隐藏调用此函数的原因,在代码隐藏中,我有会话变量来控制此刷新。-Thanks会话变量在哪里?父窗口还是弹出窗口?Srikanth-我可以访问弹出窗口.cs文件中的会话变量。在那里,我想调用这个函数来刷新父对象并关闭弹出窗口。谢谢
Page.ClientScript.RegisterStartupScript(this.GetType(), "Call my function", "Windowrefresh()", true);
function refreshParent() {
  window.opener.location.href = window.opener.location.href;

  if (window.opener.progressWindow)

 {
    window.opener.progressWindow.close()
  }
  window.close();
}