zoukankan      html  css  js  c++  java
  • 父页面 js 取得弹出窗口所选择的值, 弹出窗口关闭后刷新父页面

    一:父页面js取得弹出窗口值
    本页面用一个textbox接受传值
    <input id="Text1" type="text" onclick="show();" runat="server" />
       function show()
        {
            var result= window.showModalDialog("top.aspx",null,"dialogWidth:350px;dialogHeight:350px;help:no;status:no");
            if (result)
            {
                var a = document.getElementById("Text1");
                a.value=result;
                //alert(result);
            }
            else
            {
                alert('子窗口返回假!');
            }
        }

    弹出窗口页面
    在页面添加 <base target="_self"></base>

    返回传值用
    string a = "传值成功";
    Response.Write( "<script>window.returnValue='" +a+ "';window.close();</script>" );


    二:弹出窗口关闭,刷新父页面
    父页面
    <script type="text/javascript">
        function show()
        {
            //弹出窗口方法1:
             //window.showModalDialog("Default3.aspx",null,"dialogWidth:350px;dialogHeight:350px;help:no;status:no");
            //弹出窗口方法2:
            window.open("Default3.aspx",null,"toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no,width=400,height=200,left=300,top=400");
    /    }
        </script>

    弹出页面
    <%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default3.aspx.cs" Inherits="Default3" %>

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

    <html xmlns="http://www.w3.org/1999/xhtml" >
    <head runat="server">
        <title>无标题页</title>
        <base target="_self"></base>
    </head>
    <body >
        <form id="form1" runat="server">
        <div>
            弹出页面       
            <asp:Button ID="Button2" runat="server" OnClick="Button2_Click" Text="Button" /></div>
        </form>
    </body>
    </html>



    代码:


     protected void Button2_Click( object sender, EventArgs e )
        {
            Response.Write( "<script>window.opener.location.reload();window.close();</script>" );       
        }

    刷新框架父页面

    Response.Write("<script>window.open('err.aspx','');window.parent.location.reload();</script>");

  • 相关阅读:
    Promise推荐
    ES6推荐
    vue学习笔记之项目创建流程
    vue学习笔记之环境搭建
    前端知识小总结3
    前端知识小总结2
    JavaScript语言精粹の笔记
    JavaScript修炼之道の笔记
    移动端及vue相关问题
    组件式开发Web App
  • 原文地址:https://www.cnblogs.com/Magicam/p/1354623.html
Copyright © 2011-2022 走看看