javascript - 当用户在触摸屏上向下滚动时,如何防止页面重新加载
问题描述
当用户从页面顶部向下滚动以获取更多内容时,页面会重新加载。当没有其他内容可以向下滚动时,就会发生这种情况。 这是 Chrome 和 opera 移动浏览器的问题。这个网站上显示的例子正是发生的事情,这就是我试图阻止的事情。这是我的代码:
<style id="compiled-css" type="text/css">
body {
overscroll-behavior: contain;
width: 100%;
}
#scroller {
overflow-y:auto;
padding:0;
margin:0
border:1px solid #eee;
width:100%;
height:500px;
bottom:23px;
}
.btn{
height:4.2em;
border-radius:10px;
color: #E5787A;
float:right;
background: #78E5E3;
}
blockquote {
background: #B9DFF1;
padding: 10px 10px 10px 10px;
text-align: justify;
color:#333;
border-radius:15px;
font-size: 1.0em;
font-family:'Josefin Slab Thin';
line-height: 1.6em;
align-text:center;
max-height: 350px;
box-shadow: 4px 4px 10px #78E5E3;
-ms-word-break: break-all;
word-break: break-all;
word-break: break-word;
-ms-hyphens: auto;
-moz-hyphens: auto;
hyphens: auto;
-webkit-hyphens: auto;
overflow-wrap: break-word;
word-wrap: break-word;
overflow: hidden;
}
.container-margin {
margin-left: -15px;
margin-right: -15px;
}
html {
overflow: scroll;
overflow-x: hidden;
}
::-webkit-scrollbar {
width: 0px; /* Remove scrollbar space */
background: transparent; /* Optional: just make scrollbar invisible */
}
/* Optional: show position indicator in red */
::-webkit-scrollbar-thumb {
background: white;
}
</style>
</head>
<body id="content">
<div id="scroller" class="scroller col-lg-12 col-md-6 col-sm-3 col-xs-6" style="height:450px;width:100%;background-color: white;">
<div class="col-lg-12">
<div class="message right appeared">
<blockquote>
{{=message}}
</blockquote>
</div>
</div>
<div class="col-lg-12">
<div class="message left appeared">
<blockquote>
{{=answer}}
</div>
</div>
</div>
</body>
我已经这样做了,但似乎没有帮助:
<script>
$("#home").click(function()
{
$("#content").load("home.html");
return false;
});
</script>
body {
/* Disables pull-to-refresh but allows overscroll glow effects. */
overscroll-behavior-y: contain;
}
解决方案
推荐阅读
- ruby - 我如何在 ruby slim 中渲染 css 内联,因为输出 css 没有插入到样式标签中
- mysql - 如何从数据库中导出单个表
- amazon-web-services - 如何修复 aws lambda 中的 ssl 证书错误
- javascript - 如何在 Expo 中设置上传文件大小以修复“有效负载太大”
- symfony - 类“1\HomeController”不存在
- r - 使用 separate() 和 str_c() 函数分隔日期时的额外空间
- r - 尝试使用 ggplot2 在同一图表上制作 2 个箱线图
- go - 通过指定路径从函数内部获取 Go 文件
- reactjs - Typescript 和 React 中的嵌套映射返回错误,此表达式不可调用
- flutter - FutureBuilder 显示加载指示器,尽管结果已缓存