且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何在android phonegap中将一个页面导航到另一个页面?

更新时间:2023-01-08 15:54:47

导航到另一个 html 页面的代码.

Code to navigate to another html page.

<!DOCTYPE HTML>
<html>
  <head>
    <title>PhoneGap</title>

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

             function onLoad()
             {
                  document.addEventListener("deviceready", onDeviceReady, true);
             }

             function onDeviceReady()
             {
                  // navigator.notification.alert("PhoneGap is working");
             }

             function callAnothePage()
             {
                window.location = "test.html";
             }

          </script>

  </head>

  <body onload="onLoad();">
        <h1>Welcome to PhoneGap</h1>
        <h2>Edit assets/www/index.html</h2>
        <button name="buttonClick" onclick="callAnothePage()">Click Me!</button>
  </body>

返回事件的代码.

<script type="text/javascript" charset="utf-8">

             document.addEventListener("deviceready", onDeviceReady, true);

             function onDeviceReady()
             {     
                   document.addEventListener("backbutton", BackKeyDown, true);
             }

             function BackKeyDown()
             {
                 navigator.notification.alert();
                 //navigator.app.exitApp();  // For Exit Application
             }
        </script>