JS---使用localStorage传递参数
Posted 有挫败才有成长
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了JS---使用localStorage传递参数相关的知识,希望对你有一定的参考价值。
localStorage_send_page.html(发送页面)
<!doctype html> <html> <head> <meta charset="UTF-8"> <title></title> <meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no" /> <link href="css/mui.min.css" rel="stylesheet" /> </head> <body> <button type="button" class="mui-btn mui-btn-red">用localStorage向recieve_page页面传值</button> <script src="js/mui.min.js"></script> <script type="text/javascript"> mui.init(); //localStorage document.getElementsByTagName(‘button‘)[0].addEventListener(‘tap‘, function() { localStorage.setItem(‘name‘, ‘Harden‘); window.location.href = ‘localStorage_recieve_page.html‘; }); </script> </body> </html>
localStorage_recieve_page.html(接收页面)
<!doctype html> <html> <head> <meta charset="UTF-8"> <title></title> <meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no" /> <link href="css/mui.min.css" rel="stylesheet" /> </head> <body> <button type="button" class="mui-btn mui-btn-red">用localStorage向recieve_page页面传值</button> <script src="js/mui.min.js"></script> <script type="text/javascript"> mui.init(); //localStorage document.getElementsByTagName(‘button‘)[0].addEventListener(‘tap‘, function() { localStorage.setItem(‘name‘, ‘Harden‘); window.location.href = ‘localStorage_recieve_page.html‘; }); </script> </body> </html>
以上是关于JS---使用localStorage传递参数的主要内容,如果未能解决你的问题,请参考以下文章
使用对象和 localStorage 在 Phonegap 页面周围传递数据