检测页面元素(图片)加载完所用时间。

<html>

<head>

<title>Test sample</title>

<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;
document.getElementById('startTime').innerHTML = "图片加载时间为:" + stopTime + "s";
}

</script>

</head>

<body>
<img  alt="" src="<%= Url.Action("Image", "Attachment", new RouteValueDictionary(){{ "id", Model.PhotoObjectId }}) %>" onload="StopFun()"/>

</body>

</html>

你可能感兴趣的:(Date,image)