【问题标题】:wrong jQuery window/screen width/height above 1600x900错误的 jQuery 窗口/屏幕宽度/高度高于 1600x900
【发布时间】:2014-03-19 01:23:33
【问题描述】:

我得到这样的窗口和屏幕尺寸:

$(window).load(function() {
var width = 0;
var height = 0;
var screen_width = 0;
var screen_height = 0;
width = $(window).width();
height = $(window).height();
screen_width = screen.width;
screen_height = screen.height;
});

在 Chrome 中一切正常。 在 Firefox 和 IE11 中,尺寸最大只能达到 1600x900! 屏幕宽度和高度都达到最大值,不会显示 1920x1080 屏幕的正确值。

例如: 实际窗口和屏幕尺寸 = 1920x979 - 1920x1080

我的脚本在 FF 和 IE11 中显示:931x165 - 1600x900 (只有 Chrome 工作正常)

【问题讨论】:

  • 你有什么问题?
  • 我在 FF 和 IE 中得到了错误的值。我用一个例子编辑了我的帖子。
  • 问题解决了吗?
  • @Will:非常感谢您抽出宝贵时间。我不能在其他环境中重复错误。所以它与我非常古老的 HTML4 和 CSS1 模板有关。我现在需要坚持使用这个模板。几个月后将发布一个新的 html5 布局。在那之前我会忽略这个错误。特别是因为没有那么多> 1600px的电脑屏幕。

标签: javascript jquery screen-resolution


【解决方案1】:

确定您的浏览器已最大化?

width = $(window).width();
height = $(window).height();

输出浏览器窗口的大小

screen_width = screen.width;
screen_height = screen.height;

输出实际显示器的大小。

我在我的 1680x1050 显示器上的 FF 和 Chrome 控制台中运行了这个,同时最大化了两个窗口:

$(document).ready(function() {
    var width = 0;
    var height = 0;
    var screen_width = 0;
    var screen_height = 0;
    width = $(window).width();
    height = $(window).height();
    screen_width = screen.width;
    screen_height = screen.height;
    console.log('width', width);
    console.log('height', height);
    console.log('screen_width', screen_width);
    console.log('screen_height', screen_height);
});

铬:
宽度 1665
身高 952
屏幕宽度 1680
屏幕高度 1050

火狐:
宽度 1665
身高 908
屏幕宽度 1680
屏幕高度 1050

由于浏览器 chrome,jquery 检查的值永远不会达到屏幕分辨率。

【讨论】:

    猜你喜欢
    • 2011-09-09
    • 2012-06-15
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-03-08
    • 2012-11-01
    • 2016-06-21
    • 1970-01-01
    相关资源
    最近更新 更多