       CoreScroller.scroll element, direction, elementAmount, continuous
 
   scrollTo: (direction, pos) ->
-    activatedElement ||= (document.body and firstScrollableElement()) or document.body
+    activatedElement ||= (document.scrollingElement and firstScrollableElement()) or document.scrollingElement
     return unless activatedElement
 
     element = findScrollableElement activatedElement, direction, pos, 1


# From element and its parents, find the first which we should scroll and which does scroll.
findScrollableElement = (element, direction, amount, factor) ->
  while element != document.body and not isScrollableElement element, direction, amount, factor
    element = DomUtils.getContainingElement(element) ? document.body
  element

# On some pages, document.body is not scrollable.  Here, we search the document for the largest visible
# element which does scroll vertically. This is used to initialize activatedElement. See #1358.
firstScrollableElement = (element=document.body) ->
  if doesScroll(element, "y", 1, 1) or doesScroll(element, "y", -1, 1)
    element
  else

# input elements. This mechanism allows us to decide whether to scroll a div or to scroll the whole document.
#
activatedElement = null

if !('scrollingElement' of document)
  Object.defineProperty(document, 'scrollingElement', { get: () -> document.body })

# Return 0, -1 or 1: the sign of the argument.
# NOTE(smblott; 2014/12/17) We would like to use Math.sign().  However, according to this site
