在移动设备上使用 window.location.hash 和锚标记
Using window.location.hash and anchor tag on mobile
我有一个javascript函数,点击后,它会链接到页面上的id。
$(document).on('click', '.quiz-modal-close-label', function() {
window.location.hash = '#more-quizzes';
});
我的 HTML 看起来像这样:
<aside id='more-quizzes' class='col-xs-12 col-md-3 more-quizzes-container'> ...
在桌面上它可以工作。在Chrome移动检查器中,它可以工作。但在移动设备上,#more-quizzes
不会附加到网址中。原因可能是什么?
您使用的移动浏览器版本是否可能不支持此功能?
尝试检查 MDN 兼容性矩阵:
[https://developer.mozilla.org/en-US/docs/Web/API/Window/location]
和
[https://developer.mozilla.org/en-US/docs/Web/Events/hashchange]
另外,您是否验证过当您触摸移动设备上的按钮时您的活动是否被触发?
相关文章:
- IE中不支持JQuery window.location.hash
- 历史推送状态不在独立的 location.hash 或 location.href 中,而是在 Location 对象本
- window.location.hash = “”;强制在Chrome和Safari上重新加载框架集
- location.hash总是空的
- 正在尝试将变量传递到window.location.hash
- 从(window.location.hash)中删除哈希
- 根据location.hash传递的数据重新呈现ReactJS嵌套的子组件
- AngularJS location.hash animation
- window.location.hash始终显示为空
- Routing.navigate vs document.location.hash
- window.location.hash,IE,Back and Forward:地址栏中的值更改,但不在DOM中更改
- 在 window.location.hash 中使用斜杠
- 在 Location.hash 上从 URL 中删除 #
- 在移动设备上使用 window.location.hash 和锚标记
- jQuery + window.location.hash 和同页锚点 - 不一致的行为
- 从Chrome 47开始,设置window.location.hash不适用于后退按钮
- “window.location.href”和“window.location.hash”有什么区别
- Firefox 中的 window.location.hash 问题
- 如何使用(location.hash)和(.trigger)进行导航
- Chrome:设置window.location.hash会导致“在页面中查找”搜索框消失