js父子窗口传值以及当前页面在js前台如何获得url参数

1.首先是父页面用window.open打开窗口

<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="WebForm3.aspx.cs" Inherits="WebApplication17.WebForm3" %>

<!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>
    <script type="text/javascript">

function openChild() {

var k = window.open(‘WebForm2.aspx?id=110&id1=120&id3=130‘, ‘newwindow‘, ‘height=100,width=400,top=0,left=0,toolbar=no,menubar=no,scrollbars=no, resizable=no,location=no, status=no‘);
            //window.showModalDialog("/WebForm2.aspx", "obj", "dialogWidth:335px;status:no;dialogHeight:300px");
 
        }

</script>
</head>
<body>
    <form id="form1" runat="server">
    <div>
              <input type="text" id="txt10" name="txt10"/>
            <input type="text" id="txt9" name="txt9"/>
                   <input type="text" id="txt11" name="txt11"/>
            <input type="button" id="btn1" name="btn1" value="提交" onclick="openChild()" />
      
    </div>
    </form>
</body>
</html>
2.这是子页面

<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="WebForm2.aspx.cs" Inherits="WebApplication17.WebForm2" %>

<!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>
    <script type="text/javascript">
        window.onload = function() {

var k = window.opener;
            document.getElementById("txt1").value = k.document.getElementById("txt10").value;
            var url = location.search;
            if (url.indexOf("id3")!=-1) {
                alert("url id3");
            }
            var theRequest = new Object();
            if (url.indexOf("?") != -1) {
                var str = url.substr(1);
              
                strs = str.split("&");
                for (var i = 0; i < strs.length; i++) {
                    theRequest[strs[i].split("=")[0]] = (strs[i].split("=")[1]);
                }
            }

};

function setFather() {

//给父窗口空间传值
            var k = window.opener;
            k.document.getElementById("txt10").value =
                document.getElementById("txt1").value;
        }
        //设置返回到父窗口的值
        function  retrunValue() {
            var s =
        document.getElementById("txt2").value;
            window.returnValue = s;
            window.close();
        }
</script>
</head>
<body>
    <form name="abc" runat="server">
          <input type="text" id="txt1" name="txt1"/>
       <input type="text" id="txt2" name="txt2"/>
        <input type="button" id="btn1" name="btn1" value="提交" onclick="setFather()" />
</form>
</body>
</html>

时间: 2024-08-11 01:35:58

js父子窗口传值以及当前页面在js前台如何获得url参数的相关文章

Vue.js父子组件如何传值

https://blog.csdn.net/qq_40259641/article/details/81265950 Vue.js父子组件如何传值 通俗易懂原创 阿猫阿狗哈 发布于2018-07-28 22:04:42 阅读数 14278 收藏展开父子组件传值原理图 一般页面的视图App.vue应为这样 一.父组件向子组件传值 1.创建子组件,在src/components/文件夹下新建一个Child.vue2.Child.vue的中创建props,然后创建一个名为message的属性 3.在A

JS 子窗口向父窗口传值

首先我们来了解下window对象的的方法open: 1,open() 方法用于打开一个新的浏览 window.open(URL,name,features,replace) 重要事项:请不要混淆方法 Window.open() 与方法 Document.open(),这两者的功能完全不同.为了使您的代码清楚明白,请使用 Window.open(),而不要使用 open(). 2,opener opener 属性是一个可读可写的属性,可返回对创建该窗口的 Window 对象的引用.---这句话怎么

js open窗口父子窗口操作

http://zhidao.baidu.com/question/61358246.html?an=0&si=1 js open窗口父子窗口操作 父窗口js代码: function openCrawlPage(){ var crawlWin = window.open("/createReportCrawl.do?          type=1&ao=y","crawl_window","width=1000,height=600,top

js拼接字符串传值,子窗口传值

避免下次再去查资料,记录一下 1.拼接字符串传值 "UpdateState?ids=" + subStr+"&remark="+reValue) 目标页面接受:public ActionResult UpdateState(string ids, string remark) 2.弹出窗口传值 弹出子窗口:var reValue = window.showModalDialog('Dialog', obj, 'dialogWidth=120px;dialog

JS弹出框、对话框、提示框,JS关闭窗口、关闭页面和JS控制页面跳转

一.JS弹出框.对话框.提示框 //====================== JS最常用三种弹出对话框 ======================== //1弹出对话框并输出一段提示信息 function ale() { //弹出一个对话框 alert("提示信息!"); } //2弹出一个询问框,有确定和取消按钮 function firm() { //利用对话框返回的值 (true 或者 false) if (confirm("你确定提交吗?")) { a

【vue】父组件主动调用子组件 /// 非父子组件传值

一  父组件主动调用子组件: 注意:在父组件使用子组件的标签上注入ref属性,例如: <div id="home"> <v-header ref="header"></v-header> <hr> 首页组件 <button @click="getChildData()">获取子组件的数据和方法</button> </div> 父组件主动获取子组件的数据和方法: 1

十八、React react-router4.x中:实现路由模块化、以及嵌套路由父子组件传值

一.路由模块化(用字典定义路由,然后循环出来) 1.官方文档参考 [官方文档]https://reacttraining.com/react-router/web/guides/quick-start [路由模块化实例]https://reacttraining.com/react-router/web/example/route-config 2.路由模块化:实现代码 其它代码参考:十七:https://blog.csdn.net/u010132177/article/details/1033

(转)JS浮动窗口(随浏览器滚动而滚动)

原文:http://hi.baidu.com/aiyayaztt/item/4201c55a6b729dced2e10c79 JS浮动窗口(随浏览器滚动而滚动) 往往用于一些联系方式,互动平台模块,随着浏览器的滚动而滚动. <div id="AdLayer"> <p>窗口中的内容</p> </div> 放在<body>下面(页面最上面) JS代码 window.onload=function(){ var n=0;//top值

FineUI小技巧(5)向子窗口传值,向父窗口传值(另附24张专业版高清大图)

前言 FineUI中经常会用到启用IFrame的Window控件,这样有助于从物理上进行代码解耦和.IFrame的引入就会涉及传值问题,如何在父窗口和子窗口之间相互传值呢? 向子窗口传值 向子窗口传值只需要把要传递的参数放在页面URL中即可,一般有两种做法: 页面回发,在后台通过C#代码拼接需要的URL(推荐做法,方便!) 页面第一次加载时,即注册需要的URL(如果参数是页面上某输入框的值,则需要在URL中嵌入JavaScript代码) 来看一个例子,分别用上述两种方式实现: 页面的初始显示 点