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.

相关链接点这里

IT文库 » ios的qq webview中不支持onhashchange事件
分享到: 更多 (0)

评论 抢沙发

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址