Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to write the code for HTML5 to implement timer

2025-01-17 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/01 Report--

This article mainly introduces the HTML5 implementation of timer code how to write the relevant knowledge, the content is detailed and easy to understand, the operation is simple and fast, has a certain reference value, I believe that everyone after reading this HTML5 implementation timer code how to write the article will have a harvest, let's take a look.

The code is as follows:

HTML5 timer for relaxing work balance

CountDownSeconds = 60

Var handle = null

/ / window loading

Function onLoadWindow () {

ACanvas = document.getElementById ("countdownCanvas")

Context = aCanvas.getContext ("2d")

Var canvasText = "Press start."

Var xPos = aCanvas.width / 2

Var yPos = aCanvas.height / 2

Context.font = "12pt Century Gothic"

Context.fillStyle = "# 008000;"

Context.textAlign = "Center"

Context.textBaseline = "middle"

Context.fillText (canvasText,xPos,yPos)

ClearInterval (handle)

Handle = null

Alert ("Hey, time's up!" )

Return 0

}

MinStr = Math.floor (countDownSeconds / 60)

SecStr = countDownSeconds%60

If (minStr

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report