对于某些网页,我们使用iPhone的左右滑动功能来拉取菜单.现在使用iOS7,他们已经引入了在向左和向右滑动的情况下返回到前一页和下一页浏览器历史记录的功能.
但有没有办法为特定页面禁用它,以便在滑动操作上没有冲突的行为?
Tom*_*son 12
您不能直接禁用它,但只有在浏览器历史记录中有某些内容时才会发生本机滑动.
它不适用于所有情况,但如果您在新标签页中打开了单页网页应用,则可以阻止它通过使用添加到历史记录中
window.history.replaceState(null, null, "#" + url)
Run Code Online (Sandbox Code Playgroud)
而不是pushState或
document.location.hash = url
Run Code Online (Sandbox Code Playgroud)
我不得不使用2种方法:
1)CSS仅适用于Chrome / Firefox
html, body {
overscroll-behavior-x: none;
}
Run Code Online (Sandbox Code Playgroud)
2)Safari的JavaScript修复
if (window.safari) {
history.pushState(null, null, location.href);
window.onpopstate = function(event) {
history.go(1);
};
}
Run Code Online (Sandbox Code Playgroud)
随着时间的推移,Safari将实现overscroll-behavior-x,我们将能够删除JS hack
| 归档时间: |
|
| 查看次数: |
44807 次 |
| 最近记录: |