网页中window.open 弹出 父页面和子页面数值交互

//首先建立一个父页面

<!doctype html>

<html>

<head>

<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />

<title>父页面</title>

<script>

  function tanchu(){

    window.open("son.html","ziyemian","width=300,height=400,top=200,left=300,toobar=no,menubar=no,scrollbars=no,location=no,status=no");

  }

  function reTurn(){

    return document.getElementById("aaa");

  }

</script>

</head>

<body>

  <input value="提交" id ="button" type="button" οnclick="tanchu()"/>

  <input type="text" id="bbb">

  <input type="text" id="ddd" value="123456">

</body>

</html>

 

//son.html

<!doctype html>

<html>

<head>

<meta http-equiv="Content-Type" content="text/html;charset=utf-8">

<title>子页面</title>

</head>

<body>

  <script>

    function aaa(){

      window.opener.document.getElementById("bbb").value="123123123";//向父页面传值

      //获取父级页面的的值

      //window.opener.a();   调用父级页面的方法

      alert(window.opener.a().value);

      window.opener.location.reload(); //刷新父级页面

    }

  </script>

  <input type="button" id="button" value="提交" οnclick="aaa()">

  <input type="button" value="返回" οnclick="top.close()">  //点击返回按钮关闭 页面

</body>

  <script>

    //当页面的关闭的时候,执行的方法

    window.onbeforeunload = function(){

      window.opener.document.getElementById("bbb").value="123123123qweqwe123";

    }

</script>

</html>

转载于:https://www.cnblogs.com/Super-Zhen-/p/6063942.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值