屏幕宽度检测在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>
相关文章:
- 在Internet Explorer中,向所选内容添加选项不起作用
- 鼠标事件在 Internet Explorer 中不起作用
- 输入类型的图像在Internet Explorer中不起作用,但在Chrome和Firefox中起作用
- 包含jquery的Javascript在Internet Explorer中不起作用
- onClick和onClientClick事件一起使用.在Internet Explorer中不起作用
- Javascript图像动画在Firefox或Internet Explorer中不起作用
- 使用JS固定标题的表在Internet explorer中不起作用
- Angular $templateCache在 Internet Explorer 中不起作用
- 滑块图像在Internet Explorer中不起作用,但在其他浏览器中有效
- 带有 Internet Explorer 8/9 的 Editor Ace 不起作用
- Window.location 在 Internet Explorer 中不起作用
- Ajax POST 请求在 Internet Explorer 中不起作用
- 脚本在 Internet Explorer 中不起作用
- 在第二次加载时更改 iframe 样式,在 Internet Explorer 9 中不起作用
- 流体布局在 Internet Explorer 7 和 8 中不起作用
- blockUI 在 Internet Explorer 上不起作用
- Javascript在Internet Explorer上不起作用
- 屏幕键盘在 Internet Explorer 中不起作用
- jQuery 动画在 Internet Explorer 中不起作用
- 元标记中的JavaScript在Firefox和Internet Explorer上不起作用