The forums ran from 2008-2020 and are now closed and viewable here as an archive.

Home Forums JavaScript [Solved] $(document).width() giving wrong value on refresh in Chrome

  • This topic is empty.
Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
  • #40918

    $(document).width() gives the proper width when I load the page. But when I refresh in Chome, it includes the width for the scrollbar and I’m not sure why. I’ve tried writing it a couple different ways but it keeps happening. Any ideas?


    Not at the current moment. Perhaps is has to do with a couple divs just inside the body with a width of 100%.


    Ooooooh, very good idea. That worked.

    I’m thinking what happened was the 100% elements was tricking my js to calculating the width before the scrollbars appear.

    This made me realize the real issue. I had forgot to wrap my js in $(document).ready() so it was grabbing it before it was loaded (and before the scrollbars existed)

    Thanks for the help

    EDIT: $(document).ready() didn’t stop the issue, so I guess I use overflow then. Unfavorable, but it’s okay.


    Interesting. Definitely keep it inside of doc.ready(), but maybe try using `$(document.body)` to calculate your width?

Viewing 4 posts - 1 through 4 (of 4 total)
  • The forum ‘JavaScript’ is closed to new topics and replies.