×
Namespaces

Variants
Actions
Revision as of 13:43, 9 May 2013 by hamishwillee (Talk | contribs)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

Using timers in Nokia Asha web apps

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

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()');"
>


Reference

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 13:43.
120 page views in the last 30 days.
×