zoukankan      html  css  js  c++  java
  • js实现页面传值

    今天做东西用到,在网上查到了这样的一种方法,学习学习:

    来源:http://bbs.csdn.net/topics/310229114

    Page1:

    <!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>
        <title>无标题页</title>
        <script type="text/javascript">
        function OpenWin()
        {
          window.open("father.htm","aa","","");
        }
        </script>
    </head>
    <body>
        <input id="T1" type="text" />
        <input id="Button1" type="button" value="提交" onclick="OpenWin();" />
    </body>
    </html>

    Page2:

    <!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>
        <title>无标题页</title>
        <script type="text/javascript">
        function ReturnVal()
        {
          window.opener.document.getElementById('T1').value=document.getElementById('Text1').value;
          window.close();
        }
        </script>
    </head>
    <body>
        <input id="Text1" type="text" />
        <input id="Button1" type="button" value="关闭" onclick="ReturnVal();" />
    </body>
    </html>

    PS:

    使用window.opener可以访问js的变量 :window.opener.变量名

    -------------

  • 相关阅读:
    Java基础知识_毕向东_Java基础视频教程笔记(5-10 面向对象)
    Java 运算符-=,+=混合计算详解
    VS Code 基本介绍 和 快捷键
    Access-Control-Allow-Origin 跨域问题
    Linux常用命令收藏
    常用正则表达式
    IntelliJ IDEA 快捷键列表
    PAT A除以B
    PAT 部分A+B
    PAT 德才论
  • 原文地址:https://www.cnblogs.com/KeenLeung/p/3848722.html
Copyright © 2011-2022 走看看