从a页面跳转到b页面,从b页面返回到a页面时向a页面传递一个参数,a页面接收到参数后做出响应
a.html
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46
| <!DOCTYPE html> <html> <head> <meta charset="utf-8"> <meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no" /> <title></title> <script src="js/mui.min.js"></script> <link href="css/mui.min.css" rel="stylesheet"/> <script type="text/javascript" charset="utf-8"> mui.init(); (function($) { function plusReady() { mui('body').on('tap', '.jump', function() { mui.openWindow({ url: 'b.html', id: 'b' }); }); }
document.addEventListener('plusready', plusReady, false);
function backRes(e) { var val = e.detail.inputVal; $('.a1 font')[0].innerHTML = val; } window.addEventListener('doit', backRes); })(mui); </script> </head> <body style="padding: 15px;line-height: 1.7rem;"> <a class="jump">跳转到B页面</a> <div class="a1">返回传参为----<font style="font-size: 20px;color: #2AC845;"></font></div> <div style="font-size: 50px;text-align: center;display: block;margin: 50px 0 0 0;">a.html页面</div> </body> </html>
|
b.html
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36
| <!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 style="padding: 15px;line-height: 1.7rem;"> <input type="text" id="text" /> <a href="javascript:void(0)" class="jump">返回</a> <div style="font-size: 50px;text-align: center;display: block;margin: 50px 0 0 0;">b.html页面</div> <script src="js/mui.min.js"></script> <script type="text/javascript"> mui.init(); (function($) { if(window.plus) { plusReady(); } else { document.addEventListener('plusready', plusReady, false); } function plusReady() { mui('body').on('tap', '.jump', function() { var view = plus.webview.getWebviewById('HBuilder'); mui.fire(view, 'doit', { inputVal: $('#text')[0].value }); mui.back(); }); } })(mui); </script> </body> </html>
|