首页 > 语言 > JavaScript > 正文

JS 实现获取打开一个界面中输入的值

2024-05-06 14:19:16
字体:
来源:转载
供稿:网友

需求
在一个界面中打开另一个界面,通过JS获取在另一个界面中用户输入的值。
示例:
Index.html

代码如下:
   <html>

   <head>

     <meta http-equiv="content-type" content="text/html; charset=gbk">

         <title>主页</title>

        <script type="text/javascript">

            function EntryPoint() {

                var style = 'dialogHeight:600px;dialogWidth:800px;status:no;help:0;scrool:yes';

                var a = window.showModalDialog('other.html', '', style);

      

               if (a == undefined) {

                   a = window.returnValue;

               }

              // debugger;

               if (a != null && a.length > 0) {

                   document.getElementById("name").value = a[0];

                   document.getElementById("age").value = a[1];

               }

           }

    </script>

    </head>

    <body>

    <input type="button" value="调用" onclick="EntryPoint()"/><br/>

    <input type="text" name="name" id="name" /><br/>

    <input type="text" name="age" id="age" />

    </body>

    </html> 


另一个界面:

other.html

代码如下:
  <html>

     <head>

         <title>操作界面</title>

         

         <meta http-equiv="content-type" content="text/html; charset=gbk">

         

        <script type="text/javascript">

发表评论 共有条评论
用户名: 密码:
验证码: 匿名发表

图片精选