2

This is probably a vague question, so I apologize in advance. I'm just wondering if there's any method (Javascript, server side or otherwise) that could somehow detect if any portion of a browser window is not visible on the screen.

For example, perhaps I almost maximize my browser window, then grab it and drag it with some of it off the screen...can that fire any Javascript / ajax event to find out how much of the viewport is "not visible," enabling me to add a class to the document or something that would adjust the styling, or is that an OS level event/variable that can't be communicated to a web app?

David Savage
  • 1,562
  • 2
  • 18
  • 35
  • 1
    http://stackoverflow.com/questions/4319487/detecting-if-the-browser-window-is-moved-with-javascript – dfsq Mar 10 '13 at 08:58
  • http://andylangton.co.uk/articles/javascript/get-viewport-size-javascript/ http://stackoverflow.com/questions/3111298/determine-actual-viewing-size-in-browser http://stackoverflow.com/questions/1248081/get-the-browser-viewport-dimensions-with-javascript – Birla Mar 10 '13 at 09:02
  • @dfsq:it looks like that will tell when the browser window is moved, but not where it has moved to. Doesn't appear to be a way to do that from the linked question. – David Savage Mar 21 '13 at 20:26
  • What I'm wanting to do is see if the browser window is partially not within the viewable portion of the screen. – David Savage Mar 21 '13 at 20:33
  • `window.innerWidth + screen.screenX > screen.width` - to test if it's partially not within the viewport (horisontally) `window.innerHeight + screen.screenY > screen.height` to test vertically. – dfsq Mar 21 '13 at 20:35

1 Answers1

0

jQuery Waypoints plugin http://imakewebthings.github.com/jquery-waypoints/

You can detect when an element is in the viewport using that plugin.

Another tutorial I found useful (no idea if it's relevant to you) is http://www.9lessons.info/2009/07/load-data-while-scroll-with-jquery-php.html

This is one method of loading content via AJAX which can speed up initial load times and improve UX.

It depends on what exactly you want to achieve :)

Barney
  • 1,820
  • 5
  • 29
  • 50