第一个页面通过url把学好和姓名传到第二个页面通过url中的查询字符串取得可以么?

解决方案 »

  1.   

    第一个页面 test.html<html>
    <head>
    <title>清单</title>
    <script type="text/javascript" src="jquery-1.3.2.min.js"></script>
    <script type="text/javascript">
    var stu_id = "";
    var stu_name = "";
    $(function(){
        $("#list > tbody > tr").bind("click",function(){
           stu_id = $(this).find("td:nth-child(1)").text();
           stu_name = $(this).find("td:nth-child(2)").text();
           alert("学号:" + stu_id + ",姓名:" + stu_name);
    //要open一个新页面
    window.open("test2.html");
        });
    });
    </script>
    </head>
    <body>
    <table id='list' border="1">
       <thead><tr><th>学号</th><th>姓名</th></tr></thead>
       <tbody>
          <tr><td>1</td><td>张</td></tr>
          <tr><td>2</td><td>李</td></tr>
          <tr><td>3</td><td>刘</td></tr>
          <tr><td>4</td><td>王</td></tr>
       </tbody>
    </table>
    </body>
    </html>
    第二个页面 test2.html<html>
    <head>
    <title>明细</title>
    <script type="text/javascript" src="jquery-1.3.2.min.js"></script>
    <script type="text/javascript">
    $(function(){
        var id = window.opener.stu_id;
    var name = window.opener.stu_name;
    alert("学号:" + id + ",姓名:" + name);
    $("#No").val(id);
    $("#Name").val(name);
    });
    </script>
    </head>
    <body>
    <form>
    学号:<input type="text" id="No" />
    姓名:<input type="text" id="Name" />
    </form>
    </body>
    </html>
      

  2.   

    test.html 
    var 参数="?stu_id="+选中学号+"&stu_name="+选中姓名
    window.open("test2.html"+参数);test2.html
    window.location.search