简体   繁体   中英

How to find Cordinates of document.DocumentElement.Client

I am able to get the width and height of a browser page using document.documentElement.clientWidth and document.documentElement.clientHeight.

Now, I want to know the top left and top right cordinates of the client viewport. Are there any scripts to find this?

在此输入图像描述

I need to find (X,Y) and b - Any scripts for this?

Note - (m,n) and (X,Y) are with respect to the main Window Screen.

To get the client area position relative to the window:

var client_left = (window.outerWidth - window.innerWidth) / 2;
var client_top = (window.outerHeight - window.innerHeight - client_left);

And to get the absolute position:

var x = window.screenLeft + client_left;
var y = window.screenTop + client_top;

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM