how can i get the absolute screen coordinates of the html/body? I found all those window.screenTop, screenLeft, outerheight/innerHeight - but thats not the solution.
EDIT: I updated the image to clarify what I need!
how can i get the absolute screen coordinates of the html/body? I found all those window.screenTop, screenLeft, outerheight/innerHeight - but thats not the solution.
EDIT: I updated the image to clarify what I need!
You can do this (taking some assumptions):
//this is the border width of the OS window.
var border= (window.outerWidth-window.innerWidth)/2;
//Assuming the window border is homogeneous and there is nothing in
// the bottom of the window (firebug or something like that)
var menuHeight=(window.outerHeight-window.innerHeight)-border*2;
var absX=window.screenX + border;
var absY=window.screenY+border+menuHeight;
Try:
window.screenX
and
window.screenY
Note that screenY does not take into account address bar bookmarks bar etc at the top of the browser
Edit:
You may be able to use (window.outerHeight - window.innerHeight) to get the additional offset:
window.screenY + window.outerHeight - window.innerHeight
But this assumes you do not have any toolbars at the bottom of the browser (will break if you have docked devtools open)
Just get body element:
var $body = $(this.ie6 ? document.body : document);
And use this properties: $body.width(), $body.height()
Also to get the window dimensions
var $window = $(window);
var wWidth = $window.width();
var wHeight = $window.height();
UPDATED Try to use this: Element.getBoundingClientRect()
var rect = element.getBoundingClientRect();
console.log(rect.top, rect.right, rect.bottom, rect.left);