index页面只写的底部选项卡点击后跳转到对应子页面(都是外部网址)
在各个子页面监听安卓返回键后。当点击A页面里的链接进入可以按安卓返回键返回。
现在问题来了!!!
遇到的问题: 当点击A页面的链接进入后,再点击底部选项卡选择B页面,在B页面里随便点击一个链接后B页面按安卓返回键可以返回。这时点击底部选项卡选择A页面再按安卓返回键就会提示无法再后退了。
意思就是A页面点了链接后,再去B页面随便点击后,B页面可以后退,这时切换到A页面,应该是可以返回到A页面上一个页面,问题就是无法返回。
以下贴出index页面代码以及A,B页面代码,求大神指点下!!!感谢
index页面代码
<!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"/>
<link rel="stylesheet" type="text/css" href="css/style.css"/>
<link rel="stylesheet" type="text/css" href="css/iconfont.css"/>
<script type="text/javascript" charset="utf-8">
mui.init();
</script>
</head>
<body>
<div class="mui-content">
<nav class="mui-bar mui-bar-tab">
<a id="defaultTab" class="mui-tab-item mui-active" href="1.html">
<span class="mui-icon mui-icon-home"></span>
<span class="mui-tab-label">首页</span>
</a>
<a class="mui-tab-item" href="2.html">
<span class="mui-icon mui-icon-search"></span>
<span class="mui-tab-label">搜卷</span>
</a>
<a class="mui-tab-item" href="6.html">
<span class="mui-icon iconfont icon-9"></span>
<span class="mui-tab-label">9.9包邮</span>
</a>
<a class="mui-tab-item" href="sx.html">
<span class="mui-icon iconfont icon-jinrishangxin"></span>
<span class="mui-tab-label">每日上新</span>
</a>
<a class="mui-tab-item" href="gywm.html">
<span class="mui-icon iconfont icon-guanyu"></span>
<span class="mui-tab-label">关于我们</span>
</a>
</nav>
</div>
<!--
第一步引入castapp.js
第二步写js
第三步ca.init();初始化
-->
<!--
第一步引入castapp.js
-->
<script type="text/javascript" src="js/castapp.js" ></script>
<!--
第二步写js
第三步ca.init();初始化
-->
<script type="text/javascript">
ca.init();
var pathArray = ['1.html','2.html','6.html','sx.html','gywm.html'];
castapp.tabBar(pathArray);
</script>
</body>
</html>
A页面代码
<!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" />
<link rel="stylesheet" type="text/css" href="css/style.css"/>
<script src="js/mui.min.js"></script>
</head>
<body>
<header class="mui-bar mui-bar-nav heaber-bg">
<h1 class="mui-title">创客优选</h1>
</header>
<div class="mui-content">
<script type="text/javascript" src="js/castapp.js" ></script>
<script type="text/javascript">
mui.init();
mui.plusReady(function() {
var self = plus.webview.currentWebview();
var youhuixWV = plus.webview.create("http://www.youhuix.com", "youhuix", {
top: "0px",
bottom: 0,
titleNView:{
progress:{
color:'#0000FF' //进度条的颜色
},
titleColor:'#FAFAFA', //标题栏文字颜色为白色
autoBackButton:"true",
titleText:" "
}
});
self.append(youhuixWV);
/**
* 重写mui.back()方法
* http://dev.dcloud.net.cn/mui/window/#closewindow
*/
/**
* 监听子窗口对象是否可后退
* http://www.html5plus.org/doc/zh_cn/webview.html#plus.webview.WebviewObject.canBack
*/
//下面是安卓返回键
plus.key.addEventListener("backbutton",function(){ //监听返回按键
youhuixWV.canBack(function(event) {
var canBack = event.canBack;
if(canBack) {
youhuixWV.back();
} else {
alert("到头了,不能后退了!");
}
});
});
//上面是安卓返回键
});
</script>
</div>
</body>
</html>
B页面代码
<!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" />
<link rel="stylesheet" type="text/css" href="css/style.css"/>
<script src="js/mui.min.js"></script>
</head>
<body>
<header class="mui-bar mui-bar-nav heaber-bg">
<h1 class="mui-title">创客优选</h1>
</header>
<div class="mui-content">
<script type="text/javascript" src="js/castapp.js" ></script>
<script type="text/javascript">
mui.init();
mui.plusReady(function() {
var self = plus.webview.currentWebview();
var cesWV = plus.webview.create("http://www.baidu.com", "ces", {
top: "0px",
bottom: 0,
titleNView:{
progress:{
color:'#0000FF' //进度条的颜色
},
titleColor:'#FAFAFA', //标题栏文字颜色为透明
autoBackButton:"true",
titleText:" "
}
});
self.append(cesWV);
/**
* 重写mui.back()方法
* http://dev.dcloud.net.cn/mui/window/#closewindow
*/
/**
* 监听子窗口对象是否可后退
* http://www.html5plus.org/doc/zh_cn/webview.html#plus.webview.WebviewObject.canBack
*/
//下面是安卓返回键
plus.key.addEventListener("backbutton",function(){ //监听返回按键
cesWV.canBack(function(event) {
var canBack = event.canBack;
if(canBack) {
cesWV.back();
} else {
alert("到头了,不能后退了!");
}
});
},false);
//上面是安卓返回键
});
</script>
</div>
</body>
</html>
以上是代码,求大神指点!万分感谢~!
0 个回复