×

Discussion Board

Results 1 to 2 of 2

Hybrid View

  1. #1
    Registered User
    Join Date
    Jul 2011
    Posts
    20

    Activating the javascript code require refresh widget

    Hello again!.
    I am having some troubles trying to use some javascript code inside my app.
    I made a widget that is working properly for retrieve data over the web and storing them in the preferences storage record. (But the persistent storage only works in the device, not in the simulator, see my other post for further details).
    Now i get another trouble about activating the javascript code without refresh the widget. At the beggining the widget is launched but the styles and the javascript code isn't executing properly, there is an example below to see what i am talking about. WHen i refresh, magically the javascript run ok along with the css load.
    This problem is happening only on a device (c3-00 in my case), not in the emulator.
    Simila

    As always, hope anyone can help me.
    Grettins and thanks for advance!.
    Víctor.

    P.D.:Similarly this is happening in an app named "NewsReader.wgt", i can not get it to work unless i refresh.

    HTML Code:
        <body onload="javascript:init();">
    	<p id ="name"></p>
    	<p id = "version"> </p>
        <div>
        	<input type="button" onclick="getJSON();" value="Get JSON"/><br/>
    		<input type="button" onclick="getIt();" value="Get data from preferences"/>
        </div>
    	<div id="test">
    	</div>
      </body>
    Code:
    var URL_1 = "http://www.geonames.org/postalCodeLookupJSON?postalcode=10504&country=US";
    
    var URL = URL_1;
    
    
    function init()
    {
    	var nameElem    = document.getElementById("name"); 
    	var versionElem = document.getElementById("version");
    	
    	nameElem.innerHTML    = 'The widgets name is "' + widget.name + 
    	                        '". <br>Escaped, the value of name is "' +
    	                        escape(widget.name) + '".'; 
    	
    	versionElem.innerHTML = 'The widget\'s version is "' + widget.version + 
    	                        '". <br> Escaped, the value of version is "' +
    	                        escape(widget.version) +'".';
    }
    
    
    function getJSON()
    {
    	var xhr;
    	xhr = new XMLHttpRequest();
    	xhr.open("GET",URL, false);
    	xhr.onreadystatechange = function()
    	{
    		if (xhr.readyState == 4) 
    		{
    			if (xhr.status == 200) 
    			{
    				//document.getElementById('test').innerHTML= "<b>"+ xhr.responseText + "</b><br/>";;
    				widget.preferences.setItem("REG001",xhr.responseText);
    				document.getElementById('test').innerHTML= "<b> GUARDADO </b><br/>";
    			}
    			else
    			{
    				document.getElementById('test').innerHTML= "Error code " + xhr.status;
    			}
    		}
    	}
        xhr.send(null);
    }
    
    
    
    function getIt ()
    {
    	document.getElementById('test').innerHTML = widget.preferences.getItem("REG001");
    }

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

    Re: Activating the javascript code require refresh widget

    Hi,

    What is the version of Nokia Browser you have on your C3-00?

    -Ilkka

Similar Threads

  1. Replies: 5
    Last Post: 2010-08-11, 10:01
  2. does javascript tcp connection work in widget?
    By waiman1114 in forum Symbian
    Replies: 1
    Last Post: 2010-05-30, 07:41
  3. Sorce Code Require
    By M imran Shafiq in forum PC Suite API and PC Connectivity SDK
    Replies: 2
    Last Post: 2007-05-03, 17:24
  4. Sorce Code Require
    By M imran Shafiq in forum Mobile Java General
    Replies: 1
    Last Post: 2007-04-24, 07:49

Posting Permissions

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