如何在phonegap应用程序中使用android的后退按钮功能

时间:2014-05-08 14:40:11

标签: javascript android jquery mobile cordova

如何使用手机缺口使用后退按钮功能。

我看到很多医生,但我不知道该怎么做。我希望每当我点击后退按钮时,它都会进入之前的状态。

1 个答案:

答案 0 :(得分:0)

HERE您有关于不同移动平台的后退按钮的文档。

活动 - >返回按钮

示例:

<!DOCTYPE html>
<html>
  <head>
    <title>Cordova Back Button 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 call Cordova methods
    //
    function onDeviceReady() {
        // Register the event listener
        document.addEventListener("backbutton", onBackKeyDown, false);
    }

    // Handle the back button
    //
    function onBackKeyDown() {
    }

    </script>
  </head>
  <body onload="onLoad()">
  </body>
</html>