Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8361279
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T11:39:45+00:00 2026-06-09T11:39:45+00:00

The scrollLeft property of a div seems to return different values in different browsers

  • 0

The scrollLeft property of a div seems to return different values in different browsers when the body direction is rtl.

An example can be seen here – http://jsfiddle.net/auVLZ/2/

body { direction: rtl; }
div.Container { border: 5px solid #F00; width: 500px; height: 400px; overflow: auto; }    
div.Content { background-color: #00F; width: 900px; height: 380px; }​

<div id="divContainer" class="Container">
    <div class="Content"></div>
</div>
<br />
<input id="showScrollLeft" type="button" value="Show ScrollLeft" />​

$(document).ready(function()
{
    $("#showScrollLeft").click(function(e)
    {
        alert($("div.Container").scrollLeft());
    });
});​

Chrome – the initial value is 400, and when moving the scrollbar to the left it is 0.

IE8 – 0 and 400.

Firefox – 0 and -400.

What is causing this difference and how can it be handled?

Edit: note that this is happening with the “regular” scrollLeft as well – document.getElementById("divContainer").scrollLeft returns the same results.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-09T11:39:46+00:00Added an answer on June 9, 2026 at 11:39 am

    Although I was hoping to avoid that, I ended up using browser detection:

    function GetScrollLeft(elem)
    {
        var scrollLeft = elem.scrollLeft();
        if ($("body").css("direction").toLowerCase() == "rtl")
        {
            // Absolute value - gets IE and FF to return the same values
            var scrollLeft = Math.abs(scrollLeft);
    
            // Get Chrome and Safari to return the same value as well
            if ($.browser.webkit)
            {
                scrollLeft = elem[0].scrollWidth - elem[0].clientWidth - scrollLeft;
            }
        }
        return scrollLeft;
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have seen this example: http://jsfiddle.net/UwEe2/306/ that is implemented with scrollleft . Now I
I tried using webBrowser1.Document.Body.ScrollTop and webBrowser1.Document.Body.ScrollLeft , but they don't work. They always return
I am setting scrollTop and scrollLeft for a div that I am working with.
var mouse = function(e){ var x = e.pageX || (e.clientX + document.body.scrollLeft); var y
How can I get a div exactly in the center of my viewable area,
Why doesn't it fire the alert? var $anchor = $(this); $('.hide').val($(this).attr('href')); $('html, body').animate({ scrollLeft:
I want the scrollLeft function to scroll a div each time when I click
e.pageX = e.clientX + (html && html.scrollLeft || body && body.scrollLeft || 0) -
i want to animate my scrollLeft = value using XUI (note that I can't
I have a function that animates when a div is hovered on: $('.left_scroll_button').hover(function(){ $(.scrolling_list).stop().animate({scrollLeft:

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.