A summary
In the development of the app, can not avoid the occurrence of two pages between the value of the two pages in the development of iOS common values are: attribute value, block, agent, notification and so on. So what is the format of the two pages of the Web application, and here I give you a summary.
1) PC version of the Web program
The main ways of transmitting values between two two pages are:
1.cookie2.查询字符串3.还可以通过服务端的session来交换数据
2) How the HTML app is transmitted
Mainly include:
1.HTML5 LocalStorage 本地存储2.隐藏字段3.服务器端的session等4..页面已创建,通过自定义事件传值5.扩展参数
Here is not the above one by one interpretation of the value of the method, we have to understand. In this show you the last one by extending the parameters to pass the value. Here is an example of the MUI framework.
MUI in the initialization of the page, provides the extras configuration parameters, the parameter can be set page parameters, so as to achieve the value between pages;
The MUI framework performs a page initialization operation in the following scenarios:
1. Create a sub-page through the Mui.init () method;
mui.init({ subpages: [{ //子页面HTML地址,支持本地地址和网络地址 idid//子页面标志 styles: { //子页面顶部位置 //子页面底部位置 //子页面宽度,默认为100% //子页面高度,默认为100% ...... }, //额外扩展参数 }]
2. Pre-load the page via the Mui.init () method; general form
mui.init({ preloadPages: [{ url: prelaod - page - url, idid, //窗口参数 //自定义扩展参数 //预加载页面的子页面 }] });
3. Pre-load page general form via Mui.preload () method
var page = mui.preload({ new - page - url, new//默认使用当前页面的url作为id //窗口参数 //自定义扩展参数
4) Pre-load page general form by Mui.openwindow method
Mui.Openwindow ({URL:New -Page-URL, ID:New -Page-ID, styles: {top:newpage-Top-Position//Top position of new pageBottom:newage-Bottom-Position//New page bottom positionWidth:newpage-Width//New page width, default to 100%Height:newpage-Height//New page height, default to 100% ......}, Extras: {..... //Custom extension parameter, can be used to handle the value between pages} Show: {autoshow:true,//Page loaded event occurs automatically, default is TrueAnishow:animationtype,//page display animation, default to "Slide-in-right"; Duration: Animationtime//Page animation duration, Android platform default 100 milliseconds, iOS platform default 200 ms;}, Waiting: {autoshow:true,//Auto Show wait box, default to TrueTitle' Loading ... ',//Wait for the prompt to appear on the dialog boxOptions: {width:waiting-Dialog-WIDHT,//Waiting box background area width, default automatically calculates appropriate width based on contentHeight:waiting-Dialog-Height//Wait box background area height, default automatically calculates appropriate height based on content ......} } })
5) Mui.openwindow Specific use of first.html files
<! DOCTYPE html><html> <head> <meta charset="UTF-8"> <title></title> <link rel="stylesheet" type="text/css" href="css /mui.min.css "/> <script src="js/mui.min.js" type="Text/javascript " CharSet="Utf-8"></script> </head> <body> <script type="Text/javascript">mui.openwindow ({url:' second.html ', ID:' second ', extras:{name:' second ' ' 1.0.0 ' }}); </script></body></html>
second.html file
<! DOCTYPE html><html> <head> <meta charset="UTF-8"> <title></title> <link rel="stylesheet" type="text/css" href ="Css/mui.min.css"/> <script src="js/mui.min.js" type="Text/javascript " CharSet="Utf-8"></script> <script src="js/mui.js" type="Text/javascript " CharSet="Utf-8"></script> <style type="Text/css"> Div{ width: px; height: px; background: red; } </style> </head><body><div id="Footer"></div><script type="Text/javascript"> var div = document.getElementById ("Footer"); Mui.init (); var self = Plus.webview.currentWebview (); var name = Self.name; var version = self.version;div.innerhtml = name;</script></body></html>
注意:一定要在手机上进行模拟运行,否则看不出效果的且会报错出现plus未定义.
Several ways to transfer values between app pages based on HTML5