ios的qq webview中不支持onhashchange事件

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

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

因为上线时间比较紧,所以没过大脑直接用了jquery的$(window).bind('hashchange', ...), 另外看过jquery实现hashchange的方式如下:


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.

相关链接点这里

你可能感兴趣的:(ios的qq webview中不支持onhashchange事件)