javascript间隔 [英] javascript interval
本文介绍了javascript间隔的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如何在js中使用区间?例如,我想每隔5秒调用一次函数?
How can I use interval in js? For example I want to call a function every 5 seconds?
<script type="text/javascript">
setInterval(openAPage(), 5000);
function openAPage() {
var startTime = new Date().getTime();
var myWin = window.open("http://www.sabah.com.tr","_blank")
var endTime = new Date().getTime();
var timeTaken = endTime-startTime;
</script>
这个脚本不起作用,有人知道为什么吗?
This script doesn't work, anyone know why?
推荐答案
这些答案是彻底和良好的;我只是想特别修复你的。查看HOW / WHY的其他答案。
These answers are thorough and good; I just want to specifically fix yours. See the other answers for HOW/WHY.
setInterval(openAPage, 5000);
注意缺少()
。
此外,您在openAPage()函数上缺少结束}
。
Also, you're missing the closing }
on the openAPage() function.
这篇关于javascript间隔的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文