测试手机是三星S6,SM-G9208, android5.1.1
问题代码:document.location.href="#show_year";
整页代码如下:
<!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" />
<meta name="apple-mobile-web-app-capable" content="yes">
<meta name="apple-mobile-web-app-status-bar-style" content="black">
<link rel="stylesheet" href="http://ask.dcloud.net.cn/../../css/mui.min.css">
<link href="http://ask.dcloud.net.cn/../../css/mui.picker.css" rel="stylesheet" />
<link href="http://ask.dcloud.net.cn/../../css/mui.poppicker.css" rel="stylesheet" />
<!--<link href="http://ask.dcloud.net.cn/css/mui.listpicker.css" rel="stylesheet" />
<link href="http://ask.dcloud.net.cn/css/mui.dtpicker.css" rel="stylesheet" />-->
</head>
<body >
<header class="mui-bar mui-bar-nav" style="background-image:url(../../common_title_bg.png)">
<button type="button" class="mui-left mui-action-back mui-btn mui-btn-link mui-btn-nav mui-pull-left">
<span style="color:white;" class="mui-icon mui-icon-left-nav"></span>
</button>
<h1 style="color:white;" class="mui-title">所有课程</h1>
<a style="color:white;" id="search" class="mui-icon mui-icon-search mui-pull-right" ></a>
</header>
<footer class="mui-bar mui-bar-footer">
<a id="select_year" class="mui-btn mui-btn-link mui-pull-right">选择年份</a>
</footer>
<div class="mui-content" style="background-color: rgb(236,248,253);">
<div style="padding: 10px 15px;" >
<div id="show_year">2015</div>
</div>
<div id="month_list" class="mui-card">
<ul class="mui-table-view mui-table-view-chevron">
<li id="month_1" class="mui-table-view-cell mui-collapse"><a class="mui-navigate-right" value="1">一月</a>
</li>
<li id="month_2" class="mui-table-view-cell mui-collapse"><a class="mui-navigate-right" value="2">二月</a>
</li>
<li id="month_3" class="mui-table-view-cell mui-collapse"><a class="mui-navigate-right" value="3">三月</a>
</li>
<li id="month_4" class="mui-table-view-cell mui-collapse"><a class="mui-navigate-right" value="4">四月</a>
</li>
<li id="month_5" class="mui-table-view-cell mui-collapse"><a class="mui-navigate-right" value="5">五月</a>
</li>
<li id="month_6" class="mui-table-view-cell mui-collapse"><a class="mui-navigate-right" value="6">六月</a>
</li>
<li id="month_7" class="mui-table-view-cell mui-collapse"><a class="mui-navigate-right" value="7">七月</a>
</li>
<li id="month_8" class="mui-table-view-cell mui-collapse"><a class="mui-navigate-right" value="8">八月</a>
</li>
<li id="month_9" class="mui-table-view-cell mui-collapse"><a class="mui-navigate-right" value="9">九月</a>
</li>
<li id="month_10" class="mui-table-view-cell mui-collapse"><a class="mui-navigate-right" value="10">十月</a>
</li>
<li id="month_11" class="mui-table-view-cell mui-collapse"><a class="mui-navigate-right" value="11">十一月</a>
</li>
<li id="month_12" class="mui-table-view-cell mui-collapse"><a class="mui-navigate-right" value="12">十二月</a>
</li>
</ul>
</div>
</div>
<script src="../../js/update.js" type="text/javascript" charset="utf-8"></script>
<script src="../../js/mui.min.js" type="text/javascript" charset="utf-8"></script>
<script src="../../js/mui.picker.js"></script>
<script src="../../js/mui.poppicker.js"></script>
<script src="../../js/app.js"></script>
<!--<script src="js/mui.listpicker.js" type="text/javascript" charset="utf-8"></script>
<script src="js/mui.dtpicker.js" type="text/javascript" charset="utf-8"></script>-->
<script type="text/javascript" charset="utf-8">
var tmp_data = [{"CourseID":"01122","timeSegment":"08:00~10:00","OrgID":"0000001","OrgName":"海豚教育","CourseName":"高二物理1","bSubmited":1,"bConfirmed":1},{"CourseID":"01123","timeSegment":"10:00~12:00","OrgID":"0000002","OrgName":"优学教育","CourseName":"一对一王思聪","bSubmited":0,"bConfirmed":0}];
mui.init();
mui.plusReady(function() {
plus.webview.currentWebview().setStyle({
scrollIndicator: 'none'
});
(function($, doc) {
$.init();
$.ready(function() {
//普通示例
var userPicker = new $.PopPicker();
userPicker.setData([{
value: '2015',
text: '2015年'
}, {
value: '2016',
text: '2016年'
}, {
value: '2017',
text: '2017年'
}, {
value: '2018',
text: '2018年'
}, {
value: '2019',
text: '2019年'
}, {
value: '2020',
text: '2020年'
}]);
var showUserPickerButton = doc.getElementById('select_year');
//var userResult = doc.getElementById('userResult');
showUserPickerButton.addEventListener('tap', function(event) {
userPicker.show(function(items) {
//userResult.innerText = JSON.stringify(items[0]);
doc.getElementById('show_year').innerText = items[0].value;
document.location.href="#show_year";
//返回 false 可以阻止选择框的关闭
//return false;
});
}, false);
});
})(mui, document);
});
function saveData(date_str, server_data){
var myDate = new Date();
app.setStorageValue(date_str,'');
app.setStorageValue(date_str,JSON.stringify(server_data));
//记录最后的访问时间,以此判断是否需要从服务器重新获取数据
app.setStorageValue(date_str "_lastVisit",'');
app.setStorageValue(date_str "_lastVisit",myDate.getTime().toString());
};
// <ul class="mui-table-view mui-table-view-chevron">
// <li class="mui-table-view-cell">
// <a class="mui-navigate-right" href="http://ask.dcloud.net.cn/un_submit.html">08:00~10:00 海豚教育物理</a>
// </li>
// <li class="mui-table-view-cell"><a class="mui-navigate-right" href="http://ask.dcloud.net.cn/submit.html">10:00~12:00 优学教育英语</a>
// </li>
// <li class="mui-table-view-cell"><a class="mui-navigate-right" href="http://ask.dcloud.net.cn/submit.html">13:00~15:00 学大教育语文</a>
// </li>
// </ul>
function appendDate(value, content, data, obj){
//apend data
obj.innerHTML = '<a class="mui-navigate-right" value="' value '">' content '</a>';
var ul='<ul class="mui-table-view mui-table-view-chevron">';
for(var o in data) {
ul = '<li class="sub_li mui-table-view-cell"><a class="mui-navigate-right"';//onclick="
ul = ' value="';
if(data[o].bSubmited == 1) {
ul = data[o].CourseID '|1">';
} else {
ul = data[o].CourseID '|0">';
}
ul = data[o].timeSegment " " data[o].OrgName data[o].CourseName;
ul = '</a></li>';
// alert(o ":" ul);
}
ul = '</ul>';
// alert(ul);
// alert("brefor:" obj.innerHTML);
obj.innerHTML = ul;
// alert(obj.innerHTML);
};
var bSub_li = false;
mui("#month_list").on('tap','ul>li>ul>li a',function(){
bSub_li = true;
var value = this.getAttribute("value");
//传值给详情页面,通知加载新数据
var detailPage = null;
var index = value.indexOf("|1");
if(index > 0) {
var value_rel = value.substr(0,index);
detailPage = plus.webview.getWebviewById('submit');
//mui.fire(detailPage,'getDetail',{id:id});
mui.fire(detailPage,'courseID',{
id:value_rel
});
mui.openWindow({
id:'submit',
url:'submit.html',
show:{
aniShow:'none'
},
waiting:{
autoShow:false
}
});
} else {
index = value.indexOf("|0");
var value_rel = value.substr(0,index);
detailPage = plus.webview.getWebviewById('un_submit');
//mui.fire(detailPage,'getDetail',{id:id});
mui.fire(detailPage,'courseID',{
id:value_rel
});
mui.openWindow({
id:'un_submit',
url:'un_submit.html',
show:{
aniShow:'none'
},
waiting:{
autoShow:false
}
});
}
});
mui("#month_list").on('tap','ul>li a',function(){
if(bSub_li == true) {
bSub_li = false;
return;
}
var value = this.getAttribute("value");
var content = this.innerHTML;
var myDate = new Date();
//alert(document.getElementById("show_year").innerText);
var key_lastVisit = document.getElementById('show_year').innerText "_" value "_lastVisit";
var key = document.getElementById('show_year').innerText "_" value;
if(myDate.getTime() - app.getStorageValue(key_lastVisit)*1 > 5*50*1000) {
saveData(document.getElementById('show_year').innerText "_" value, tmp_data);
}
//alert(this.parentElement.innerHTML);
appendDate(value, content, JSON.parse(app.getStorageValue(key)), this.parentElement);
});
document.getElementById("search").addEventListener('tap',function(){
mui.openWindow({
url: '../consume/search.html',
id: 'search',
show: {
aniShow: 'pop-in'
},
waiting: {
autoShow: false
}
});
});
</script>
</body>
</html>
3 个回复
Chirs_Evans
你好,不设置href 要设置什么呢?
开心就好 (作者)
找到原因了,都是href害的,谨慎使用
全球公敌
具体描述一下呢?
2015-11-27 00:25
开心就好 (作者)
document.location.href="#show_year"
就是这一句
反正所有的a标签,尽量都不要用href
2015-11-27 22:47
1***@qq.com
同样的问题,怎样解决的