Blackberry Web Works, how to trigger an event every time the application starts

<html>
  <head>
    <meta name="viewport" id="viewport" content="height=device-height,width=device-width,user-scalable=no"/>
    <script type="text/javascript">
    function helloWorld() {
     alert("Hello World");
    }
    </script>
  </head>
  <body onload="helloWorld();">
   <h1>Hello World</h1>
  </body>
</html>

I have an application built using Blackberry WebWorks similar to the one above. I need the aforementioned helloWorld () function to run every time a user opens an application.

The problem is that the “onload” function only starts when the application is first launched or when the user exits the application by clicking the “freeze on mobile device” button, and not by pressing the “Back on mobile device” button.

Any suggestion?

+2
source share
1 answer

, , , ( , , , ).

( Phonegap) "" . , , - :

<html>
<head>
  <title>Cordova Resume Example</title>

  <script type="text/javascript" charset="utf-8" src="cordova-1.7.0.js"></script>
  <script type="text/javascript" charset="utf-8">

  // Call onDeviceReady when Cordova is loaded.
  // At this point, the document has loaded but cordova-1.7.0.js has not.
  // When Cordova is loaded and talking with the native device,
  // it will call the event `deviceready`.
  function onLoad() {
    document.addEventListener("deviceready", onDeviceReady, false);
  }

  // Cordova is loaded and it is now safe to make calls Cordova methods
  function onDeviceReady() {
      document.addEventListener("resume", onResume, false);
      // Call the function you are interested in.
      helloWorld();
  }

  // Handle the resume event
  function onResume() {
    helloWorld();
  }

  function helloWorld(){
    alert('Hello World');
  }
  </script>
</head>
<body onload="onLoad()">

</body>
</html>

, . . , .

+1

All Articles