如何实现以下效果:
A页面的一个超联接上用widow.open()打开了一个新窗口B,当B这个窗口执行完某一命令时自动关闭.A窗口获得焦点后自动刷新.

解决方案 »

  1.   

    window.opener.location.href="父页面.aspx"
      

  2.   


    this.opener.location.href="A.aspx"
      

  3.   

    b.html<input type=button value="try" onclick="window.opener.location.reload();window.close();" />这段示例是以try在click时触发. 把onclick里执行的语句放到你的"某一命令执行完毕后" 执行即可.
      

  4.   

    b页面中使用<script>
    function unload()
    {
         window.opener.location.reload(true);
    }
    </script>
    <body onunload="unload()">
      

  5.   

    接着问,如果需要把B页面选定的信息返回给A页面,并写到A页面指定的地方
    而且A页面不刷新,有办法吗
      

  6.   

    b.html
    <input id="t1" value="okok" />
    <input type=button value="try" onclick="window.opener.document.getElementById('t2').value = document.getElementById('t1').value;" />点击 try 时,将 b.html t1的值写回给a.html的t2.自己按需要调整.
      

  7.   

    楼主问的是用C#语言写吧。
    A页面:window.open()B页面
    B页面:操作完后,Response.write("<script language='javascript'>window.opener.window.location.reload();window.close();</script>");
    效果是:A页面刷新,B页面关闭
      

  8.   


    <head id="Head1" runat="server">
        <title>父窗体</title>    <script>
            var sUserName="";
            //打开一个模式对话框
            function fnCallDialog()
            {
                showModalDialog("要打开网页的链接",window,"status:false;dialogWidth:300px;dialogHeight:300px");
            }
            //主窗体更新文本框方法
            function fnUpdate()
            {
                document.getElementById("oName").innerText = sUserName;
            }
        </script></head>
    <body>
        <form id="form1" runat="server">
            <div>
                <p>
                    输入内容: <span id="oName" style="color: red; font-size: 24">默认值</span></p>
                <input type="button" value="显示模式对话框" onclick="fnCallDialog()">
            </div>
        </form>
    </body>
    </html>
    由父窗体打开的新窗体<head id="Head1" runat="server">
        <title>子窗体</title>
        <script>
            function fnGetInfo()
            {
                //通过dialogArguments获取打开该模式窗口的父对象
                var sData = dialogArguments;
                //将父窗体中的sUserName的值设置为模式对话框中"oEnterName"框架的值
                sData.sUserName = document.getElementById("oEnterName").value;
                //调用父窗体的funUpdate()方法更新主页面的控件值
                sData.fnUpdate();
            }        function fnCancel()
            {
                var sData = dialogArguments;
                sData.sUserName = "默认值";
                sData.fnUpdate();
            }
        </script></head>
    <body>
        <form id="form1" runat="server">
            <div>
                <label for="oEnterName" accesskey="f">
                    输入内容</label>
                <input id='oEnterName'><br>
                <br>
                <input value="应用" type="button" onclick="fnGetInfo();">
                <input value="确定" type="button" onclick="fnGetInfo();window.close();">
                <input value="取消" type="button" onclick="fnCancel();window.close();">
            </div>
        </form>
    </body>
    </html>