Get the App
SLTechnology News&Howtos  ›  Development  › 

How to write the code for HTML5 to implement timer

Shulou Source: shulou.com Published: 2022-06-01 06:42:22 11月14日 Update

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

Tags: Style size input content text color code font browser browse timer width button background height adjustment screen work selection important Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Linux Redmi MariaDB MySQL OPPO Reno