猿问

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

我想将 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>


largeQ
浏览 298回答 2
2回答

侃侃尔雅

纯粹的客户端方法是使用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);&nbsp;现在,在你的第二页:var uni= localStorage.getItem("university"); //gets the value of "university" from localStorage

炎炎设计

<table id="myTable">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <tr class="header">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <th style="width:60%;">State</th>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <th style="width:40%;">University</th>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </tr>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <tr ng-repeat="value in myDynamicData track by $index">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <td>{{value.state}}</td>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <td><a href="universities.html?vu={{value.university}}">{{value.university}}</a></td>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </tr>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</table>然后在 university.html 中,您可以使用 window.location.search 阅读
随时随地看视频慕课网APP

相关分类

JavaScript
我要回答