为了账号安全,请及时绑定邮箱和手机立即绑定

从一个 html 页面到另一个页面取值

从一个 html 页面到另一个页面取值

largeQ 2021-12-02 17:02:47
我想将 value.university 从我的 index.html 带到 university.html 页面。我怎样才能做到这一点?这可能有隐藏的价值吗?<table id="myTable">  <tr class="header">    <th style="width:60%;">State</th>    <th style="width:40%;">University</th>  </tr>  <tr ng-repeat="value in myDynamicData track by $index">    <td>{{value.state}}</td>    <td><a href="universities.html">{{value.university}}</a></td>  </tr></table>
查看完整描述

2 回答

?
侃侃尔雅

TA贡献1801条经验 获得超15个赞

纯粹的客户端方法是使用localStorage,它将变量存储在客户端浏览器中。您可以使用:


var university = "some value here";

//creates a variable in the browser called university, which is now accessible from all pages of your website.

localStorage.setItem("university", university); 

现在,在你的第二页:


var uni= localStorage.getItem("university"); //gets the value of "university" from localStorage



查看完整回答
反对 回复 2021-12-02
?
炎炎设计

TA贡献1808条经验 获得超4个赞

<table id="myTable">

                <tr class="header">

                  <th style="width:60%;">State</th>

                  <th style="width:40%;">University</th>

                </tr>

                <tr ng-repeat="value in myDynamicData track by $index">

                  <td>{{value.state}}</td>

                  <td><a href="universities.html?vu={{value.university}}">{{value.university}}</a></td>

                </tr>

             </table>

然后在 university.html 中,您可以使用 window.location.search 阅读


查看完整回答
反对 回复 2021-12-02
  • 2 回答
  • 0 关注
  • 274 浏览
慕课专栏
更多

添加回答

举报

0/150
提交
取消
意见反馈 帮助中心 APP下载
官方微信