Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
document.body.scrollTop for Safari, Chrome
/*
* Tested
* MacOS [Safari, 11.0 (12604.1.38.1.7)]
* > console.log(window.pageYOffset || document.documentElement.scrollTop || document.body.scrollTop || 0)
* [Log] 1173
* < undefined
* MacOS [Chrome, 61.0.3163.100, (64 bit)]
* console.log(window.pageYOffset || document.documentElement.scrollTop || document.body.scrollTop || 0)
* VM23823:1 5283
* undefined
*/
window.pageYOffset || document.documentElement.scrollTop || document.body.scrollTop || 0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment