Please note that as of October 24, 2014, the Nokia Developer Wiki will no longer be accepting user contributions, including new entries, edits and comments, as we begin transitioning to our new home, in the Windows Phone Development Wiki. We plan to move over the majority of the existing entries. Thanks for all your past and future contributions.

Using timers in Nokia Asha web apps

From Wiki
Jump to: navigation, search
Article Metadata
Code Example
Installation file: File:CarouselSlideshow.wgt
Tested with
Devices(s): Nokia X3-02
Keywords: web apps, timers, timer, stopTimer, MWL, JavaScript
Created: rebloor (24 Nov 2011)
Last edited: hamishwillee (09 May 2013)



It can be useful to have web apps take action on the expiry of a timer. In a Series 40 web app standard web timers would be executed on the Nokia Browser for Series 40 Proxy server, as a result using standard timers can be unreliable. To overcome this limitation the Mobile Web Library (MWL) provides timer methods that execute on the phone. However, these timers may not correctly trigger if placed within subroutines of the web app. This article explains how to correctly use the timer methods by coding inline.


MWL provides two timer related methods: timer() and stopTimer(). Depending on the method by which timers are added to your web app's code, it may appear that the timers are not functioning - typically the event you expect to fire on the completion of a timer doesn't fire. This situation occurs when the timer() or stopTimer() methods are included in a subroutine called by the triggering event. In such cases the timer will never expire and fire the associated event. An example of this incorrect use of timers is provided in File:Imageswap.wgt.

For the timer methods to function correctly, to expire and fire an event or cancel an existing timer, both methods should be coded inline to ensure the expected results.


When using the timer() and stopTimer() methods inline coding should be employed. Typically this means your code should be similar to:

function callFunc() {
// Process event here...
</head> <body onload="mwl.timer
('timer1', 5000, 0, 'callFunc()');"


Nokia Asha Web Apps Developer’s Guide and API Reference

Nokia Asha Web Apps Best Practices Guide

This page was last modified on 9 May 2013, at 10:43.
121 page views in the last 30 days.