鼠标移动的速度 JavaScript HTML
展开全部
你说的是鼠标经过的时间吧?
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<title> New Document </title>
<meta name="Generator" content="EditPlus">
<meta name="Author" content="">
<meta name="Keywords" content="">
<meta name="Description" content="">
</head>
<style>
div.ddd {
border: 1px solid blue;
position: absolute;
width: 200px;
height: 100px;
}
#d1 {
top: 100px;
left: 100px;
}
#d2 {
top: 500px;
left: 800px;
}
</style>
<body>
<div id="d1" class="ddd" onmouseout="d1()"></div>
<div id="d2" class="ddd" onmouseenter="d2()" onmouseout="d3()"></div>
</body>
</html>
<script language="JavaScript">
<!--
var _f = 1;
var _ms1 = 0, _ms2 = 0;
function d1() {
_f = 0;
var _d = new Date();
_ms1 = _d.getTime();
}
function d2() {
if (_f == 0) {
var _d = new Date();
var _ms2 = _d.getTime();
var _ms = _ms2 - _ms1;
alert("passed " + (_ms / 1000) + " seconds");
}
}
function d3() {
_f = 1;
}
//-->
</script>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<title> New Document </title>
<meta name="Generator" content="EditPlus">
<meta name="Author" content="">
<meta name="Keywords" content="">
<meta name="Description" content="">
</head>
<style>
div.ddd {
border: 1px solid blue;
position: absolute;
width: 200px;
height: 100px;
}
#d1 {
top: 100px;
left: 100px;
}
#d2 {
top: 500px;
left: 800px;
}
</style>
<body>
<div id="d1" class="ddd" onmouseout="d1()"></div>
<div id="d2" class="ddd" onmouseenter="d2()" onmouseout="d3()"></div>
</body>
</html>
<script language="JavaScript">
<!--
var _f = 1;
var _ms1 = 0, _ms2 = 0;
function d1() {
_f = 0;
var _d = new Date();
_ms1 = _d.getTime();
}
function d2() {
if (_f == 0) {
var _d = new Date();
var _ms2 = _d.getTime();
var _ms = _ms2 - _ms1;
alert("passed " + (_ms / 1000) + " seconds");
}
}
function d3() {
_f = 1;
}
//-->
</script>
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询