从一个html页面获取价值

时间:2019-10-24 17:31:12

标签: javascript html angular

我想将value.university从我的index.html转移到university.html页面。我怎样才能做到这一点?可能带有隐藏值吗?

public class MainActivity extends BaseActivity implements NavigationView.OnNavigationItemSelectedListener  {

}

2 个答案:

答案 0 :(得分:1)

一种纯粹的客户端方法是使用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

答案 1 :(得分:0)

<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

阅读