Back Action example


The index.html file containing JavaScript that makes use of the Back Action API functionality is listed below.

<!DOCTYPE html>
<html manifest="manifest.appcache">
  <head>
    <title>BackAction API usage example</title>
    <link rel="stylesheet" href="../assets/style.css" type="text/css" media="all"/>

    <script type="text/javascript">
    var loaded = false;
    window.onLaunchboxLoaded = function () { //execute the setUp() function once the launchbox is ready
      loaded = true;
      setUp();
    }
    function setUp() {
      if(!loaded) {//check if launchbox is loaded
        alert("launchbox is not loaded yet");
        return;
      }
      window.launchbox.BackAction.addListener({
        "onBackButtonPressed": function () {
          if (window.switch) {alert("SWITCH=TRUE");}
          else {
            alert("SWITCH=FALSE");
            window.launchbox.BackAction.fireDefaultBackButtonAction();
          }
        }
      });
    }
    </script>
  </head>
  <body>
    <header>
      <h3><span>BackAction API Usage Example</span>
      </h3>
    </header>
    <div class="white_box_content" style="height: auto;">
      <div>
        <input type="button" onclick="javascript: window.switch = true;" value="switch=true
        - prevent default back action"/>
      </div>
      <div>
        <input type="button" onclick="javascript: window.switch = false;" value="switch=false
        - default back action" />
      </div>
    </div>
  </body>
</html>

Related topics

Public API reference
BackAction
Legal notice | Copyright © 2018 and Confidential to Pegasystems Inc. All rights reserved
PDN | Feedback
Advanced...