Skip to content

浏览器兼容性

定义

浏览器兼容性问题又被称为网页兼容性或网站兼容性问题,指网页在各种浏览器上的显示效果可能不一致而产生浏览器和网页间的兼容问题。百度百科

CSS 方面

  • 浏览器自带的默认样式,清除默认样式normalize

JS 方面

  • 阻止默认行为的兼容

    js
    if (e.preventDefault) {
      e.preventDefault();
    } else {
      e.returnValue = false;
    }
  • 阻止冒泡的兼容

    js
    if (e.stopPropagation) {
      e.stopPropagation();
    } else {
      e.cancelBubble = true;
    }

工具

参考资料

Released under the MIT License.