pauloabmiranda
2/25/2014 - 12:21 PM

Element to use to make scrollTo

Element to use to make scrollTo

//Este não funciona
//var elemToScroll = document.documentElement.scrollTop ? document.documentElement : document.body;

//Este funciona
var isIos = false;
if( (navigator.userAgent.match(/iPad/i) != null) || (navigator.platform.indexOf("iPhone") != -1) || (navigator.platform.indexOf("iPod") != -1) ){
    isIos = true;
}

if (!isIos && window.navigator.userAgent.search('Chrome/') !== -1) {
    //elemToScroll = parseInt( window.navigator.userAgent.split('Chrome/')[1].substr(0, 2) ) < 36 ? 'body' : 'html';
    elemToScroll = document.body;
} else if (isIos && (window.navigator.userAgent.search('Safari/') !== -1 || window.navigator.userAgent.search('Chrome/') !== -1)) {
    elemToScroll = document.body;
} else if (window.navigator.userAgent.search('Safari/') !== -1) {
    elemToScroll = document.body;
} else {
    elemToScroll = document.documentElement;
}