我已成功在本地存储中放置了一个变量我现在正试图在下一页加载后立即显示该变量,我不确定如何在页面转换后立即执行此脚本。
我的代码如下
<script type="text/javascript">
$("#home").on('pageinit ', function() {
//alert('pageinit');
document.getElementById("output").innerHTML="Name: " +localStorage.userName;
});
</script>
</head><!-- Main Page -->
<div id="home" data-role="page" data-title="home">
<div data-role="header">
<h1>Home Page</h1>
</div>
<!-- /header -->
<div data-role="content">
<div id='customer'> Customer Name </div>
<p id="output"></p>
<a href="index.html" data-role="button">Alarm</a> <a href="index.html" data-role="button">Reports</a> <a href="index.html" data-role="button">Summary</a> </div>
<!-- /content -->
<div data-role="footer" data-position="fixed" class="ui-bar"> <a href="index.html" data-role="button" >Logout</a> <h4>©Home Page</h4> </div>
<!-- /footer -->
</body>
</html>