JAVASCRIPT - HOW TO Get Center X/Y of Screen/Viewport - Javascript Source Code

JAVASCRIPT - HOW TO Get the EXACT Center X and Center Y Position of Where the Website Visitor is on the Web Page or Document Which is the Center of Their Web Browser or Viewport

Home Short:

To get the dead center x and y position of the viewers screen in Javascript we need to know ...

This gives us the exact center X and the exact center Y of the part of the web page the visitor is at right now.

The function to get the center X and center Y of the visitors current place on the web page is return from a function as an array.

Use window.onscroll Function to Update Center Screen X/Y

If you want the exact center X and center Y to update as the visitor navigates around the webpage, call the Javascript window.onscroll function.

Feel free to right click this page and view the source code. This function to find the exact center X and center Y of the website visitors browser viewport is what is keep the red + in the exact center of the screen.

+
S
H
A
R
E