On Jan 12, 5:50 pm, Balázs Galambosi <[email protected]> wrote:
> Greetings to all!
>
> Why is it that in Chrome both standards and quirks mode uses
> document.body for scroll values?

Due to a Chrome bug described here:

http://code.google.com/p/chromium/issues/detail?id=2891

it is a very old bug and the suggested solutions found there do not
solve the problem.

--
Diego

> According to Browser Detection FAQ (Example 2: Scroll Values) [1] this
> shouldn't be the case:
>
> |       if((typeof document.compatMode == 'string')&&
> |                (document.compatMode.indexOf('CSS') >= 0)&&
> |                (document.documentElement)&&
> |                (typeof document.documentElement.scrollLeft=='number')){
> |                       /* The - readScrollX - and - readScrollY - variables
> |                                are already defaulted to the required 
> strings so it
> |                                is only necessary to assign a reference to 
> the -
> |                                document.documentElement - to the - 
> readScroll -
> |                                variable:
> |                       */
> |                       readScroll =  document.documentElement;
> |       /* If the browser is not in the appropriate mode the scroll
> |                values should be read from the document.body - element,
> |                assuming it exists on this browser and that the
> |                - scrollLeft - property is a number:
> |       */
> |       }else if((document.body)&&
> |                                        (typeof document.body.scrollLeft == 
> 'number')){
> |                       /* The - readScrollX - and - readScrollY - variables
> |                                are already defaulted to the required 
> strings so it
> |                                is only necessary to assign a reference to 
> the -
> |                                document.body - to the - readScroll - 
> variable:
> |                       */
> |                       readScroll =  document.body;
> |       }
>
> Of course the full example in the article will work, because
> pageYOffset exists, but
> I'm curious as to why it is different in Chrome (scroll values are
> only active on body).
>
> Now I'm not sure if body is acting as root element, or it's just for
> scrolling, but still
> very confusing.
>
> I've created a test page:http://jsbin.com/itofe3/
>
> [1]http://www.jibbering.com/faq/notes/detect-browser/#bdScroll
>
> - Balázs

-- 
To view archived discussions from the original JSMentors Mailman list: 
http://www.mail-archive.com/[email protected]/

To search via a non-Google archive, visit here: 
http://www.mail-archive.com/[email protected]/

To unsubscribe from this group, send email to
[email protected]

Reply via email to