如何用JS获取文档的绝对坐标?

deb*_*bay 3 html javascript jquery

我怎样才能获得html/body的绝对屏幕坐标?我找到了所有那些window.screenTop,screenLeft,outerheight/innerHeight - 但那不是解决方案.

编辑:我更新了图像,以澄清我需要的东西!

在此输入图像描述

Pab*_*ano 5

你可以这样做(做一些假设):

//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;
Run Code Online (Sandbox Code Playgroud)