美文网首页Web前端之路Web 前端开发
ios的qq webview中不支持onhashchange事件

ios的qq webview中不支持onhashchange事件

作者: stois | 来源:发表于2017-03-06 11:40 被阅读396次

问题背景:
写了个插件,需要根据url里#的变化进行动态加载。因为道理很简单所以直接使用了原生,window.onhashchange.

测试后出了ios的qq之外,都能正常进行动态加载,于是开始排查原因,找到了题目中的坑。

因为上线时间比较紧,所以没过大脑直接用了jquery的$(window).bind('hashchange', ...), 另外看过jquery实现hashchange的方式如下:
<blockquote>
How does the plugin work?
When a browser-native window.onhashchange event is detected, that event is used for the hashchange event automatically. However, when that event isn’t detected, at the first attempt to bind to the event, a polling loop is started to monitor location.hash for changes, firing the event whenever appropriate.
</blockquote>

相关链接点这里

相关文章

网友评论

    本文标题:ios的qq webview中不支持onhashchange事件

    本文链接:https://www.haomeiwen.com/subject/omgygttx.html