Skip to content Skip to sidebar Skip to footer

Show Location Of The Coordinates On The Page

I want to enter X and Y to two inputs then show me the location of the coordinates on the page I tried hard but failed My page size is large when I enter the coordinates the page s

Solution 1:

I made you a small example that takes you to the coordinates X and Y you specified through the prompt().

Method scrollTo() is used for scrolling. This is a simple example, but you can improve and refine it.

let x = prompt("Enter X");
let y = prompt("Enter Y");
let coordinate_x = parseInt(x);
let coordinate_y = parseInt(y);

window.scrollTo(coordinate_x, coordinate_y);
body {
 width: 5000px;
 height: 6000px; 
 background-color: green;
}

Post a Comment for "Show Location Of The Coordinates On The Page"