Element.scrollTo之IE兼容

2023-04-231578次阅读javascript
(function () {
  if ("scrollBehavior" in document.documentElement.style) {
    return;
  }
  const Element = window.HTMLElement || window.Element;

  Element.prototype.scrollTo = function () {
    let left = 0;
    let top = 0;
    if (arguments.length > 1) {
      left = arguments[0];
      top = arguments[1];
    } else {
      left = arguments[0].left;
      top = arguments[0].top;
    }
    this.scrollLeft = left;
    this.scrollTop = top;
  };
})();

 

上一篇: 必须知道的Typescript实用类型  下一篇: cmd Powercfg /requests命令行枚举应用程序和驱动程序电源请求。  

Element.scrollTo之IE兼容相关文章