请问一下如何通过动态修正的方法解决setTimeout()定时不准的问题,下面的代码是复制别人的,不知道具体功能怎么实现,比如说10分钟后输出hello

function timer() {
var speed = 500,
counter = 1,
start = new Date().getTime();

function instance()
{
var ideal = (counter * speed),
real = (new Date().getTime() - start);

counter++;
  1. var diff = (real - ideal);
    form.diff.value = diff;

    window.setTimeout(function() { instance(); }, (speed - diff)); // 通过系统时间进行修复

    };

    window.setTimeout(function() { instance(); }, speed);
    }