I am trying to find a script that detects if a device places position: fixed elements relative to the ViewPort and not to the entire document.
Currently, standard desktop browsers and Mobile Safari (for iOS 5) do so, whereas Android devices place the fixed elements relative to the entire document.
I have found a couple of tests to detect this, but none of the seem to work:
- http://kangax.github.com/cft/ Gives me a false positive when I pass it from an Android device.
- https://gist.github.com/1221602 Gives me a false negative when I pass it in an iPhone with iOS 5.
Does anybody know where to find / how to write a test that actually detects that? I don’t want to rely on browser sniffing.
According to the contributors at Modernizr, you cannot do this without detecting the browser in use. The contributors are quite well-established in the field.
Testing for
position: fixedon iOS and Android devices is listed under the Undetectables wiki page in the Modernizr project.The MobileHTML5 website lists the support for
position:fixed. http://mobilehtml5.org/