iPhone Mobile Safari seems to be missing element.getBoundingClientRect. What is the equivalent method on iPhone Mobile Safari? This method exists on the iPad.
What is the equivalent of getBoundingClientRect on iPhone Mobile Safari 3?
11.9k Views Asked by newtonapple At
2
There are 2 best solutions below
1

For anyone looking for the ele.getBoundingClientRect().width method on iOS 3, you can use ele.offsetWidth
if("getBoundingClientRect" in this.container) {
this.width = this.container.getBoundingClientRect().width ;
}else {
this.width = this.container.offsetWidth; //http://help.dottoro.com/ljvmcrrn.php
}
Edit 1: This code (webkitConvertPointFromNodeToPage) is only required for very old and out-of-date phones... see these comments.
EDIT 2: I wouldn't recommend you use this code... I recall changing it to deal with some problem with IE10 with touch zoom. I will try to remember to update the code with the fix.
Was: I think the following works on IE6+, FF3+, Safari 2+ (Desktop & Mobile), Chrome (Desktop & Android), Opera:
where the following is a child of the body:
Method does need some error checking (e.g. element must be in document). Scale makes it work when page zoomed, but may not be required (I did need it when testing webkitConvertPointFromNodeToPage in Windows Safari).