The main thing I want to do is to see if an object is or is not
outside the screen.

I need to see if a popup is getting out of the screen or not.
For this reason I want to find out where it is and if it's too near to
the edge/margin/border/what you want to call it,
I want to make it back off a bit so that it won't go out of the
I am subtracting the scrollX and scrollY from the page to get the
relative position of the object to the screen.
Now I want to see if it's outside the dimensions of the screen or not.
(I do that by comparing to oh and ow which are defined below)

var dpoffset = $("#popup",window.content.document).offset();
var relX = dpoffset.left -
window.content.document.defaultView.scrollX ;
var relY = - window.content.document.defaultView.scrollY;

var oh = window.innerHeight;
var ow = window.innerWidth;

This doesn't work as expected , on some pages I get strange values for
oh/ow , for example on , so this doesn't help very much.

Any ideas on how I can find out if an object is outside the viewport ?