WebTimer

From Xojo Documentation


For desktop applications, see Timer.

Class (inherits from WebControl)

Creates a client-side (browser) timer that executes code based on the time set. This control has no visual user interface but it appears on the Shelf in the Web Page Layout Editor.

Events
Action DropObject Shown
Close Hidden
ContextualMenuAction Open


Properties
ContextualMenu LockBottom Parent fa-lock-32.png
ControlID fa-lock-32.png LockHorizontal Period
Cursor LockLeft Style
DragOverStyle LockRight Top
Enabled LockTop VerticalCenter
Height LockVertical Visible
HelpTag Mode Width
HorizontalCenter Name fa-lock-32.png Zindex
Left Page fa-lock-32.png


Methods
AcceptPictureDrop AllowTextDrag Reset
AcceptRawDataDrop Close SetFocus
AcceptTextDrop ExecuteJavaScript ShowURL
AllowPictureDrag MsgBox
AllowRawDataDrag PresentContextualMenu

Notes

The WebTimer is very similar to the desktop Timer control. The important difference is that the WebTimer is part of the page. As a result, it is controlled from the page, which is on the client side.

A WebTimer can be used to update controls on the page, for example. A regular Timer control will only execute server-side, so it cannot contact the client.

Example

The WebTimer provides the same functionality as the Desktop Timer control. This example updates the value on a label (SecondsPassedLabel) on the web page using the WebTimer. This code in the WebTimer updates the label:

SecondsPassedLabel.Text = Str(Val(SecondsPassedLabel.Text) + 1)

You can also add a button to start and stop the timer. This code is in the Button Action event:

If Me.Caption = "Start" Then
Timer1.Mode = Timer.ModeMultiple
Me.Caption = "Stop" // button caption
Else
SecondsPassedLabel.Text = "0"
Timer1.Mode = Timer.ModeOff // Turn off the timer
Me.Caption = "Start"
End If

See Also

Timer, WebView