Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8230089
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T17:01:14+00:00 2026-06-07T17:01:14+00:00

I just started to study Phonegap + jQuery Mobile and HTML5,, so don’t loose

  • 0

I just started to study Phonegap + jQuery Mobile and HTML5,, so don’t loose your nerve with my idiocy!

Could somebody tell me why this is not working? When I am using a variable from localStorage, I just get an empty screen when pressing the button, but when using a variable temperature=”100″, it is working fine. Android 4.1.

<script type="text/javascript" charset="utf-8">
document.addEventListener("deviceready", onDeviceReady, false);
function onDeviceReady() {
  window.localStorage.setItem("temperature", "100");
  var temperature = window.localStorage.getItem("temperature");
}
</script>
<div data-role="content">
  <p>Working or not?</p>
  <button onclick="myFunction()">Try it</button>
  <p id="testi"></p>
<script type="text/javascript">
  function myFunction() {
    //var temperature = "100";----> This is working!
    document.getElementById("testi").innerHTML = temperature;
  }
 </script>
</div>

Another question: How to handle variables between pages in Windows Phone? They are not supporting localStorage, so is there another way to handle this if you haven’t got db-connection?

Thanks!

Sami

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-07T17:01:15+00:00Added an answer on June 7, 2026 at 5:01 pm

    temperature is local to the scope of the onDeviceReady function. That is, once the function is over, it’s gone.

    You have two options:

    // Make it global
    var temperature;
    document.addEventListener("deviceready", onDeviceReady, false);
    function onDeviceReady() {
      window.localStorage.setItem("temperature", "100");
      temperature = window.localStorage.getItem("temperature");
    }
    

    or:

    // Retrieve it in myFunction
    function myFunction() {
      var temperature = localStorage.getItem("temperature");
      document.getElementById("testi").innerHTML = temperature;
    }
    

    For a good list of examples of function scope, try this answer.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

This is the code, (don't kill me, i've just started to study javascript)...Firefox'errors console
I have just started to study jQuery and it seems to be full of
I've just started to study Rails. When I try rake db:migrate, the following error
Just started with JQuery and I've managed to pass a parameter using POST, firebug
Just started working with Mercurial a few days ago and there's something I don't
I just started study of class and object in php. I have a very
I just started to study the android so im asking such a simple question.
I'm very new to Android development and just started to study. What I'm trying
I am new to C# and .NET and I just started to study LINQ
I have just started a feasibility study on Django for my company and I

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.