首页通过
mui.init({
swipeBack: false,
subpages: [{
id: 'main',
url: 'main.html',
styles: {
top: '45px',
bottom: 0
}
}]
});
创建了子页面
在子页面通过href跳转(类似html的iframe),父页面不变
但是在子页面通过mui.openWindow和plus.webview.open 打开新页面,会直接打开新的窗口(不再留在父页面下)
只能通过子页面.loadURL(新地址)的方式跳转么?(history.back()不起作用)
安家 (作者)
非常感谢,但是只适合一层调用(既a-b,b后退返回a),不适合a-b-c-d 从d history.back()直接就返回list.html了
2016-08-10 18:40
安家 (作者)
公共js方法
var template;
var historyUrls;
var subWebview;
var aniShow="slide-in-right";
mui.plusReady(function () {
template= plus.webview.getWebviewById(plus.runtime.appid);
// 预加载公用子页面
subWebview = plus.webview.getWebviewById("sub_template")||mui.preload({
url:'',
id:'sub_template',
styles:{
top: '45px',
bottom: '0px'
}
});
// 将子页面填充到父页面
template.append(subWebview);
})
var loadWindow=function(href,isBack){
isBack=isBack||false;
subWebview.hide("auto");
href=plus.io.convertLocalFileSystemURL(href);
// 加载子页面地址
if (plus.io.convertLocalFileSystemURL(subWebview.getURL())==href) {
setTimeout(function(){
subWebview.show(aniShow);
},150)
} else{
subWebview.loadURL(href);
if(!isBack){
historyUrls=JSON.parse(localStorage.historyUrls||"[]");
historyUrls.push(href);
localStorage.historyUrls=JSON.stringify(historyUrls);
}
// 子页面加载完成显示
subWebview.addEventListener('loaded', function() {
subWebview.show(aniShow,150)
});
}
}
主页面index.html
<script type="text/javascript">
mui.init();
mui.plusReady(function () {
localStorage.historyUrls="[]";
loadWindow(“demo.html");
})
</script>
子页面demo.html
<script type="text/javascript">
mui.init();
mui.plusReady(function () {
mui(".mui-table-view").on('tap','li a',function(){
loadWindow(this.href);
})
})
</script>
2016-08-11 13:43