×

Discussion Board

Results 1 to 7 of 7
  1. #1
    Registered User
    Join Date
    Sep 2009
    Posts
    3

    JavaScript timer in a homepage widget stops when screen saver starts

    Hello,

    I have a WRT with an interval timer (window.setInterval) every 60 seconds.
    When ever the screen saver kicks in or when I lock the keys, the interval code is not executed.
    When I activate / unlock the phone the interval code is executed at the interval.
    If I keep the phone active (for example by playing with menues) the interval works as expected.

    The interval code sends an HTTP request and display data on the screen. If the data changed from last time it plays a sound using an embed element - that is the reason I want the code to keep running even when the phone is on standby.

    I am using Nokia N97 v22.0.110.C01.01

    How can I keep my widget timer alive?

  2. #2
    Regular Contributor
    Join Date
    Mar 2006
    Posts
    83

    Re: JavaScript timer in a homepage widget stops when screen saver starts

    have you tried with widget.onhide and widget.onshow?
    Best regards,
    Dusan

  3. #3
    Registered User
    Join Date
    Sep 2009
    Posts
    3

    Re: JavaScript timer in a homepage widget stops when screen saver starts

    I started the timer in the body.onload method.
    Why do I need to use widget.onhide or widget.onshow?

    This is an example index.html of a WRT that shows my problem:

    Code:
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
        <head>
            <title>Timer Demo</title>
    		<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />		
            <META NAME="Generator" CONTENT="Nokia WRT plug-in for Aptana Studio 2.0.0" />
    
            <script type="text/javascript">
                function addContent() {
                    var contentDiv = document.getElementById("contentDiv");
                    contentDiv.innerHTML = contentDiv.innerHTML + "<br/>" + new Date();
                }
    
                function bodyOnLoad() {
                    setInterval("addContent();", 10000);
                    addContent();
                }
            </script>
        </head>
        <body onload="bodyOnLoad();" >
            <!--A div that is displayed in full screen mode and mini view mode-->
            <div id="contentDiv">            
            </div>
    	</body>
    </html>

    When the phone is active (not with key lock or screen saver) the content is added a line every 10 seconds as expected - both in mini view (homepage) and in full view mode.

    When I lock the phone keys and opens them after a minute or so a line with current is added immediately to the content and I can see there are no lines added from the moment I locked the phone to the moment I unlocked it - both in mini view (homepage) and in full view mode.
    Once the phone is active again the page is refreshed every 10 seconds as expected.

    Anyone?
    Last edited by ElishaMoshe; 2010-10-04 at 10:11.

  4. #4
    Nokia Developer Moderator
    Join Date
    Jun 2008
    Location
    Tampere
    Posts
    833

    Re: JavaScript timer in a homepage widget stops when screen saver starts

    Hello Elisha and welcome to the Forums.

    Stopping the timer of background widgets is intended behavior for N97, when there is at least one widget on the home screen.
    Maybe the following article clears this a bit. http://wiki.forum.nokia.com/index.ph..._BrowserNG/7.1

    -Ilkka

  5. #5
    Registered User
    Join Date
    Sep 2009
    Posts
    3

    Re: JavaScript timer in a homepage widget stops when screen saver starts

    Ilkka - Thanks for the correct reply.

    I tried maybe working around it using setTimeout instead of setInterval but the setTimeout was also halted.

    Is there a workaround?
    It is important for me that there will be a sound on change and I would also want to see the data in my homepage. I don't want to open another application just for the sound.

  6. #6
    Nokia Developer Moderator
    Join Date
    Jun 2008
    Location
    Tampere
    Posts
    833

    Re: JavaScript timer in a homepage widget stops when screen saver starts

    Unfortunately no As long as there are widgets in HS JavaScript timers are halted.

    Br,
    Ilkka

  7. #7
    Regular Contributor
    Join Date
    Jun 2010
    Posts
    161

    Re: JavaScript timer in a homepage widget stops when screen saver starts

    I have not the time to try it by myself, but does this restriction also applies to the timed location requests from ILocation.Trace()?

Similar Threads

  1. Will a Midlet pause exectution when screen saver starts running?
    By KevinBoyd in forum Mobile Java General
    Replies: 0
    Last Post: 2010-01-10, 00:21
  2. Replies: 8
    Last Post: 2009-10-21, 08:55
  3. Replies: 14
    Last Post: 2009-07-27, 14:26
  4. Timer stops when process goes background
    By slayv in forum Symbian C++
    Replies: 4
    Last Post: 2009-02-02, 12:42
  5. Timer task stops
    By tramos25 in forum Mobile Java General
    Replies: 0
    Last Post: 2005-02-26, 00:04

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •