asyraf9/jquery-mobile — Issue #86: JS error in IE7/8
Author: christanto
Created: 2011-12-29 04:07:10+00:00
State: open

Steps:
1. open http://asyraf9.github.com/jquery-mobile/ in IE7/8
2. JS error occur

This is due to document.body is not yet available during mobileinit event. Splitview is trying to do $(document).width().

So the quick workaround is to replicate jquery width() functionality without the body calculation.

var min480 = false;
if ($.mobile.media("screen and (min-width:480px)")) {
min480 = true;
} else if ($.mobile.browser.ie && $.mobile.browser.ie < 9) {
// in ie 7/8 document.body is not available yet
min480 = Math.max(
this.documentElement["clientWidth"],
this.documentElement["scrollWidth"],
this.documentElement["offsetWidth"]
);
} else if ($.mobile.browser.ie) {
min480 = $(this).width() >= 480;
}

if (min480) {
//if ($.mobile.media("screen and (min-width:480px)")||($.mobile.browser.ie && $(this).width() >= 480)) {
//...