例如,我想在上午 10.00.00.00 调用一个 js 函数,我该怎么办?
<script type="text/javascript">
var now = new Date();
var millisTill10 = new Date(now.getFullYear(), now.getMonth(), now.getDate(), 0, 30, 0, 0) - now;
setTimeout(function{openAPage(), setInterval(openAPage, 60*1000)}, millisTill10)
function openAPage() {
var startTime = new Date().getTime();
var myWin = window.open("http://google.com","_blank")
var endTime = new Date().getTime();
var timeTaken = endTime-startTime;
document.write("<br>button pressed@</br>")
document.write(new Date(startTime));
document.write("<br>page loaded@</br>")
document.write(new Date(endTime));
document.write("<br>time taken</br>")
document.write(timeTaken);
myWin.close()
}
</script>
我希望从这个代码在 00.30 开始它会打开谷歌,然后每 1 分钟后它会再做一次?那个代码有什么问题?