屏幕宽度检测在 Internet Explorer 中不起作用

Screen width detection is not working in internet explorer

我使用以下脚本来确定访问页面的设备的屏幕宽度。这适用于所有浏览器,除了 ie 有没有人有任何想法如何或为什么这不起作用?

function view() {
    var isMobile = window.matchMedia("only screen and (max-width: 760px)");

   if (isMobile.matches) {
        //Do Nothing
    }
    else
    {
    horizontalview();
    }
}

轻松 jQuery

$(document).ready(function() {

  var isMobile = false;
  if ($(window).width() < 768) {
    isMobile = true;
  }

});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>