window.scrollTo(0,0); 在H5+ 中无效吗?
现在滚动条是用 div overflow-y: scroll; 实现的,
求教,如何实现点击按钮回到顶部?
window.scrollTo(0,0); 在H5+ 中无效吗?
现在滚动条是用 div overflow-y: scroll; 实现的,
求教,如何实现点击按钮回到顶部?
在 ios 上 获取document.documentElement.scrollTop 、 document.body.scrollTop 、window.pageYOffset都是0,郁闷。现在返回顶部,做不了,而且在ios上,<a href="#"></a>也没效果。
但在android都正常
页面整个代码贴一下
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>专业清尾货</title>
<meta name="viewport" content="width=device-width, initial-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="../css/mui.min.css">
<link rel="stylesheet" href="../css/app.css">
<script src="../js/mui.min.js"></script>
<script src="../js/handlebars-v2.0.0.js" type="text/javascript" charset="utf-8"></script>
<script src="../js/app.js"></script>
<style>
html,
body {
background-color: #efeff4;
}
.title {
margin: 20px 15px 10px;
color: #6d6d72;
font-size: 15px;
}
.mui-search input{
background: none;
border: 1px solid #fff;
color: #fff;
text-align: left;
}
</style>
</head>
<body>
<div class="tool-bar search-bar mui-clearfix">
<div class="tool-bar-wrapper mui-pull-left">
<a class="byg_iconfont icon-filter mui-pull-left filter-btn" id="filter-btn"></a>
<!--<a class="mui-btn mui-btn-link mui-pull-right" id="search-btn">搜索</a>-->
</div>
<div class="mui-content-padded" id="search-btn">
<div class="mui-input-row mui-search">
<input type="button" class="mui-btn mui-btn-block mui-btn-outlined">
<span class="mui-placeholder"><span class="mui-icon mui-icon-search"></span>寻找商品</span>
</div>
</div>
</div>
<div id="pullrefresh" class="mui-scroll-wrapper">
<div class="mui-scroll">
<ul class="mui-table-view mui-grid-view mui-grid-9" id="item-wrapper">
<li class="mui-table-view-cell mui-media mui-col-xs-6"></li>
<li class="mui-table-view-cell mui-media mui-col-xs-6"></li>
</ul>
</div>
</div>
</div>
<a id="scrollTo" class="top mui-btn byg_iconfont"></a>
<p class="content-none"></p>
<div class="content-offline">
<h3>亲,您的手机网络不太顺畅喔~</h3>
<p class="tips">请检查您的手机是否联网</p>
<p><button class="mui-btn" id="reload">重新加载</button></p>
</div>
<script id="list-tpl" type="text/x-handlebars-template">
{{#each this}}
<div class="item-box">
<a id="{{leftoverId}}" class="mui-navigate-right pic-box" href="template/leftoverDetail.html">
<img src="{{host}}/getImg-index-{{imgId}}-200-0.png" alt="" />
</a>
<p>
<span class="shopName">{{shopName}}</span>
<span class="mui-badge"><samp class="byg_iconfont byg-icon-s fav">󰀄</samp><samp class="num">(10)</samp></span>
</p>
<p class="call"><a class="mui-icon mui-icon-phone" href="tel:{{telephone}}">{{telephone}}</a>
</p>
</div>
{{/each}}
</script>
</body>
</html>
2015-01-20 17:55
在ios里边,我们的下拉刷新是区域滚动,你需要调用mui('#pullrefresh').pullRefresh().scrollTo(0,0);来滚动到顶部
2015-01-20 18:02
sf
document.body.scrollTop = 0;
2015-01-05 17:54
木头 (作者)
回复 sf:测试了,无效!
2015-01-05 18:38