#27 JS: Timing Events - Part 1

What is timing event?

"JavaScript can be executed in time-intervals. This is called timing events.
The window object allows execution of code at specified time intervals.
These time intervals are called timing events.
The two key methods to use with JavaScript are:

  • setTimeout(function, milliseconds)
    Executes a function, after waiting a specified number of milliseconds.

  • setInterval(function, milliseconds)
    Same as setTimeout(), but repeats the execution of the function continuously."
    by W3C School

Basic timing event

<script type="text/javascript">
function init(){ 
    window.setTimeout(countdown, 1000);
}
function countdown (){
    alert("Hi there!");
}
</script>

The unit is milliseconds, so 1000 milliseconds = 1 second.

The window will popup in 1 second.
https://ithelp.ithome.com.tw/upload/images/20210927/20130362zOIVAoMv11.png


Music of Today: Strangers In A Dream by Phum Viphurit


Like/Share/Follow

Feel free to comment and share your ideas below to learn together!
If you guys find this article helpful, please kindly do the writer a favor — LIKE this article./images/emoticon/emoticon12.gif


<<:  下拉式选单更新 Day 23

>>:  Day12 - [丰收款] 为BackendURL中收到PayToken铺路,Django来了。

前端工程师也能开发全端网页:挑战 30 天用 React 加上 Firebase 打造社群网站|Day12 文章列表

连续 30 天不中断每天上传一支教学影片,教你如何用 React 加上 Firebase 打造社群...

#18 No-code 之旅 — 读取资料库来实作部落格 ft. Notion SDK

嗨大家~ 像昨天文章里提的,这专案会采用 Notion 来当 CMS (包含资料库),意思是部落格文...

【把玩Azure DevOps】Day7 CI/CD从这里:设定第一个Pipeline(范本与编辑介面介绍)

前一篇介绍了要用来作为建立Pipeline的材料,这篇就要开始来建立第一个Build Pipelin...

第23车厢-在网页中预览pdf—pdf.js简易版应用篇

本篇介绍JS插件pdf.js简易应用篇 今天介绍透过插件pdf.js在网页中直接浏览pdf 官网:...

活动分享|高品质数据用Tableau活起来!

2021年很快已经倒数2个月了 这一年变动很大很快 不管是你所属的企业还是我任职的企业,很明显的,在...