2014-03-19 72 views
0

我得到了窗口和屏幕尺寸是這樣的:錯誤jQuery的窗口/屏幕寬度/高度以上1600x900的

$(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 - 1920×1080

我的腳本顯示了我在FF和IE11:931x165 - 1600×900 (僅適用於Chrome瀏覽器工作正常)

+0

你的問題是什麼? –

+0

我在FF和IE中得到錯誤的值。我用一個例子編輯我的帖子。 –

+0

你解決了這個問題嗎? – Will

回答

0

確保您的瀏覽最大化?

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

輸出的瀏覽器窗口

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

輸出的實際顯示器的大小的大小。

我在FF和Chrome的我的1680×1050顯示器上的控制檯跑這與兩個窗口最大化:

$(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
SCREEN_WIDTH 1680
SCREEN_HEIGHT 1050

Firefox:
寬度1665
高度908
SCREEN_WIDTH 1680
SCREEN_HEIGHT 1050

jquery的檢查值永遠不會碰到屏幕分辨率由於chrome瀏覽器。