Android 2.x webview兼容注意事项

477 查看

不可使用 javascript 方法列表:

  1. Element.prototype.classList 只能通过正则低效的操作 className Can I use

  2. Element.prototype.dataset 只能通过 getAttributesetAttribute 获取设置 data-*属性 Can I use

  3. Function.prototype.bind 可通过添加 polyfill 方式使用 MDN

  4. html5 history API 包括 history.pushStatehistory.replaceStatpopstate 都能使用

有问题的 css 声明列表

  1. position: fixed 某些 webview 上元素会跟着手势滚动后再弹回到固定位置,如果是body直接子节点则没有此问题,建议是不用 position:fixed

  2. overflow: autooverflow: scroll, 不会实现可滚动元素,建议是只让body去滚动,万不得已使用 iscroll

  3. animation-fill-mode 在 android 2.3之前不被支持

需要 sdk 设置开启才能使用的方法

  1. localStorage API

  2. alert confirm