如何仅为IE11禁用嵌入式脚本?

时间:2018-11-03 16:17:57

标签: internet-explorer-11

我注意到在IE11上,此脚本确实使滚动变得混乱。其他浏览器也可以。所以我想知道如何仅在IE11上排除它。

  var $t            = $(this),
      $w            = $(window),
      viewTop       = $w.scrollTop(),
      viewBottom    = viewTop + $w.height(),
      _top          = $t.offset().top,
      _bottom       = _top + $t.height(),
      compareTop    = partial === true ? _bottom : _top,
      compareBottom = partial === true ? _top : _bottom;

return ((compareBottom <= viewBottom) && (compareTop >= viewTop));

1 个答案:

答案 0 :(得分:0)

您可以参考以下代码来检查浏览器是IE还是其他浏览器:

<script type="text/javascript">
    function msieversion() {

        var ua = window.navigator.userAgent;
        var msie = ua.indexOf("MSIE ");

        if (msie > 0 || !!navigator.userAgent.match(/Trident.*rv\:11\./))  // If Internet Explorer, return version number
        {
            alert("IE ");
        }
        else  // If another browser, return 0
        {
            alert('otherbrowser');
        }

        return false;
    }
</script>

来自this thread的代码

相关问题