viernes, 9 de junio de 2023

X Y pointer position on Chrome

 // Create the rectangle element
var rectangle = document.createElement("div");
rectangle.style.position = "fixed";
rectangle.style.top = "50px";
rectangle.style.left = "50px";
rectangle.style.width = "200px";
rectangle.style.height = "100px";
rectangle.style.backgroundColor = "rgba(0, 0, 0, 0.5)";
rectangle.style.color = "#fff";
rectangle.style.padding = "10px";
rectangle.style.fontFamily = "Arial";
rectangle.style.fontSize = "16px";
rectangle.style.zIndex = "9999";

// Append the rectangle to the document body
document.body.appendChild(rectangle);

// Update the mouse position values in the rectangle
document.onmousemove = function(e) {
    var position = {
        x: e.clientX,
        y: e.clientY
    };
    rectangle.innerHTML = "Mouse Position: X = " + position.x + ", Y = " + position.y;
};


No hay comentarios:

Publicar un comentario