用时间差,来测试整个网页的加载速度
<!DOCTYPE html> <html> <head> <title> new document </title> <meta http-equiv="content-type" content="text/html;charset=utf-8" /> <meta name="viewport" content="width=device-width, initial-scale=1"> <style> div{text-align:center;}img{max-width:100%;} </style> <script type="text/JavaScript"> var startTime; var now1 = new Date(); startTime = now1.getTime(); var stopTime; function StopFun() { var now = new Date(); stopTime = now.setTime(now.getTime() - startTime) / 1000; console.log(stopTime); } </script> </head> <body > <div> <img src="images/panda.jpg"/> </div> </body>
时间: 2024-10-26 03:14:00