Using timers in Nokia Asha web apps
Article Metadata
Code Example
Tested with
Compatibility
Article
Contents |
Overview
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.
Description
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.
Solution
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...
}
</script>
</head> <body onload="mwl.timer
('timer1', 5000, 0, 'callFunc()');">


(no comments yet)