I have been working on a plugin of wordpress, in which i save the last reading position, the width and height of the browser at the time of closing the browser, I save the width and height with jquery height=$(window).height(); width=$(window).width(); and save the values in database so that when the page is loaded next time, the values are retrieved from database and the screen is scrolled to last reading position and the window get resized to the saved values.

The problem that i m getting is that the window resizes to a very less value and window gets smaller, the jquery methods height=$(window).height(); width=$(window).width(); are saving lesser values, can anybody help me out in this?

  • It appears this question is not about anything WordPress-specific, but more about jQuery in general. I think you would have more success if you re-ask this question on Stack Overflow.
    – Jan Fabry
    Commented Sep 7, 2010 at 10:29
  • @Jan Fabry I'm half-hearted with you, but jQuery is part of the wordpress stack. Don't we answer CSS questions for Themes any longer? MsManiya wrote about creating a wordpress plugin, so I think any hints should be welcome :)
    – hakre
    Commented Sep 7, 2010 at 22:04

1 Answer 1


Next to .height() and .width() there is .outerHeight() and .innerHeight() (same for width as well). You might be looking for these methods to gather the browsers size, not only the size of the windows viewport.

Keep in mind that this not always works 100% across all browsers, so you always might run into problems if you need it pixel-perfect.

  • but it says in the link that the methods .outerHeight and .outerWidth is not applicable to window and document objects; for these, use .height() instead :(
    – MsManiya
    Commented Sep 8, 2010 at 8:04
  • When I remember back the last time I wanted to achieve something similar - that was with Netscape 2.0.1 and we hadn't any javascript libraries that time, it was not possible to do so. I always needed to add some guessed amount of pixels for each windows side and menus, titles etc. to come close. So I think if the other functions in jQuery do not fit, then it's probably not possible at all. Sorry.
    – hakre
    Commented Sep 8, 2010 at 12:47

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.