Discussion Board

Results 1 to 2 of 2
  1. #1
    Registered User VituchoInfonor's Avatar
    Join Date
    Jul 2011
    Posts
    20
    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 isalento's Avatar
    Join Date
    Jun 2008
    Location
    Tampere
    Posts
    831
    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 Web Runtime
    Replies: 1
    Last Post: 2010-05-30, 07:41
  3. Problem in javascript innerHTML refresh in e52
    By saritco in forum Mobile Web Site Development
    Replies: 1
    Last Post: 2009-12-27, 08:03
  4. 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
  5. 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
  •  
Nokia Developer aims to help you create apps and publish them so you can connect with users around the world.

京ICP备05048969号  © Copyright Nokia 2013 All rights reserved