获取浏览器的各种属性

xiaoxiao2021-02-28  95

<!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <title></title> <script type="text/javascript"> window.onload = function() { var aa = document.getElementById("aa"); var width = document.documentElement.clientWidth; //抓取浏览器显示的宽度和高度 和dom一样 var height = document.documentElement.clientHeight; aa.onmousemove = function() { var t = Math.floor(Math.random()*(height-100-0+1)+0); var l = Math.floor(Math.random()*(height-100-0+1)+0); aa.style.left = t + 'px'; aa.style.top = l + 'px'; } } </script> </head> <body> <img src='img/1.jpg' width="100px" height="100px" id="aa" style="position: absolute; left: 0; top: 0;"/> </body> </html>
转载请注明原文地址: https://www.6miu.com/read-34561.html

最新回复(0)