From 18fa1fd9da12fd6a259b422f91b663d9fbdb181e Mon Sep 17 00:00:00 2001 From: scottjehl Date: Wed, 22 Dec 2010 15:24:07 -0500 Subject: [PATCH 1/3] Getting window dimensions currently fails in Nokia browsers, causing JS error (and consequently making jQuery Mobile fail to render the page). Based on a tip from Ben Nolan, this fix returns window.screen[width|height] if the other attempts at getting window dimensions fail. On mobile at least, it seems to make sense, and on desktop (assuming this issue would ever show up on desktop), this might be better than returning false or undefined. --- src/dimensions.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/dimensions.js b/src/dimensions.js index f35b0acf..b4dae83c 100644 --- a/src/dimensions.js +++ b/src/dimensions.js @@ -36,7 +36,7 @@ jQuery.each([ "Height", "Width" ], function( i, name ) { if ( jQuery.isWindow( elem ) ) { // Everyone else use document.documentElement or document.body depending on Quirks vs Standards mode return elem.document.compatMode === "CSS1Compat" && elem.document.documentElement[ "client" + name ] || - elem.document.body[ "client" + name ]; + elem.document.body[ "client" + name ] || window.screen && window.screen[ name ]; // Get document width or height } else if ( elem.nodeType === 9 ) { From 73d060b522ccf72847e67f56fea0e9b129ff273e Mon Sep 17 00:00:00 2001 From: scottjehl Date: Thu, 13 Jan 2011 14:20:00 -0500 Subject: [PATCH 2/3] set name to lowercase, since it's passed as initial caps --- src/dimensions.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/dimensions.js b/src/dimensions.js index a292899b..9d8c3545 100644 --- a/src/dimensions.js +++ b/src/dimensions.js @@ -36,7 +36,7 @@ jQuery.each([ "Height", "Width" ], function( i, name ) { if ( jQuery.isWindow( elem ) ) { // Everyone else use document.documentElement or document.body depending on Quirks vs Standards mode return elem.document.compatMode === "CSS1Compat" && elem.document.documentElement[ "client" + name ] || - elem.document.body[ "client" + name ] || window.screen && window.screen[ name ]; + elem.document.body[ "client" + name ] || window.screen && window.screen[ name.toLowerCase() ]; // Get document width or height } else if ( elem.nodeType === 9 ) { From 2b64b1db6877f52ea2958c6aafb0e4644fbcfe13 Mon Sep 17 00:00:00 2001 From: scottjehl Date: Wed, 19 Jan 2011 12:40:32 -0500 Subject: [PATCH 3/3] Revised the Nokia support fallback. It turns out that Nokia supports the documentElement property but does not define document.compatMode. Adding this third fallback allows Nokia to run jQuery error-free and return proper values for window width and height. --- src/dimensions.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/dimensions.js b/src/dimensions.js index 9d8c3545..e2d411dd 100644 --- a/src/dimensions.js +++ b/src/dimensions.js @@ -35,8 +35,10 @@ jQuery.each([ "Height", "Width" ], function( i, name ) { if ( jQuery.isWindow( elem ) ) { // Everyone else use document.documentElement or document.body depending on Quirks vs Standards mode - return elem.document.compatMode === "CSS1Compat" && elem.document.documentElement[ "client" + name ] || - elem.document.body[ "client" + name ] || window.screen && window.screen[ name.toLowerCase() ]; + // 3rd condition allows Nokia support, as it supports the docElem prop but not CSS1Compat + var docElemProp = elem.document.documentElement[ "client" + name ]; + return elem.document.compatMode === "CSS1Compat" && docElemProp || + elem.document.body[ "client" + name ] || docElemProp; // Get document width or height } else if ( elem.nodeType === 9 ) {