如何在phonegap中使用javascript返回上一页

How to go back to previous page using javascript in phonegap

本文关键字:javascript 返回上一页 phonegap      更新时间:2023-09-26
<html>
  <head>
    <title>Quiz Application</title>
    <script type="text/javascript" charset="utf-8" src="cordova-1.9.0.js"></script>
    <link rel="stylesheet" href="http://code.jquery.com/mobile/1.4.5/jquery.mobile-1.4.5.min.css" />
    <script src="http://code.jquery.com/jquery-2.1.4.min.js"></script>
    <script src="http://code.jquery.com/mobile/1.4.5/jquery.mobile-1.4.5.min.js"></script>
    <script type="text/javascript" charset="utf-8">
      function ready() {
        if (document.getElementById("rb1").checked) {
          alert("correct");
        } else if (document.getElementById("rb2").checked) {
          alert("incorrect");
        } else {
          alert("incorrect");
        }
        function prevpage() {
          document.location=document.history.back();
        }
      }
    </script>
  </head>
  <body id="body2">
  <form method="post">
    <center><h1>Quiz Application</h1></center><br><br>
    <center>Is JAVA Object Oriented Language ?<br><br>
    <radiogroup>
      <input type="radio"  id="rb1"/>Yes<br>
      <input type="radio"  id="rb2"/>No<br>
      <input type="radio"  id="rb3"/>May Be<br>
      <input type="submit" id="sub" value="Freeze" onclick="ready();"/><br>
      <input type="submit" id="next" value="Previous Question" onclick="prevpage();"/></center>
    </radiogroup>
  </form>
  </body>
</html>

以上是我重定向到第一页的代码,该页面不起作用。
请帮助我在第一页上重定向。
我经历了许多选项,例如 window.location=-window.history.back((;,window.history.back(1/-1( 但它们都不起作用。
提前致谢:)

试试这个应该可以工作

function prevPage() {
history.go(-1);
navigator.app.backHistory();

}