js 实现隔5秒执行一下。

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <title></title>
    <script type="text/javascript">
        var lastClickTime = new Date();
        function doHandler() {
            var now = new Date();           
            if (now.getTime() > lastClickTime.getTime() + 5 * 1000) {
                document.getElementById("divShow").innerHTML = new Date().getSeconds();
                lastClickTime = now;
            }
        }
    </script>
</head>
<body>
    <div style="width: 500px; height: 500px; background-color: Red;" onclick="doHandler()">
    </div>
    <div id="divShow"></div>
</body>
</html>
posted @ 2009-07-06 11:38  SmartFramework@live.jp  阅读(1434)  评论(0编辑  收藏  举报