Short Version
Trying to access the document.documentElement.offsetHeight on IEMobile 7.11 throws an unspecified error. Why?
Long Version
I'm working on fixing some Javascript meant to be run on handheld devices (not phones, the kind delivery guys use). The devices have a few different OSes and browser versions, though, so compatibility is a concern.
The problem code is in a method called during the body element's onLoad and onResize events. I was able to fix the problem on one device using the document.documentElement.offsetHeight property, but when I try to use it on the other device, it gives an error.
Now, I was expecting to have to do all sorts of quirky compatibility checks, but this particular error is interesting because I have no idea why it's happening. All of the following cause an error:
var str = document.documentElement.offsetHeight
var str = String(document.documentElement.offsetHeight)
alert(document.documentElement.offsetHeight)
So it appears that simply trying to access the property at all throws the error. I checked that the documentElement object exists, and it does, so it's not a case of calling properties on a null. I thought it might be because offsetHeight isn't defined, even though that should just return null, so I checked the documentElement's properties with the following loop to be sure:
var str = "";
for (var prop in document.documentElement) {
str += prop + "\n";
}
But the offsetHeight property is definitely there on the object, although I have no idea what value it is.
I tried catching the error, and it didn't give me anything helpful; both the error.description and error.message were empty, so I looked up the error number (-2147467259) and found it means "Unspecified Error", short for "you're on your own".
As far as my own knowledge goes, this error is completely inexplicable. So I come to Stack Overflow seeking wisdom.
Miscellaneous Info
- OS: Windows Mobile 6.1 Professional
- Browser: IEMobile 7.11