简体   繁体   English

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

[英]How to go back to previous page using javascript in phonegap

<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>

Above is my code for redirecting to first page which is not working .以上是我重定向到第一页的代码,它不起作用。
Please help me for redirecting on first page.请帮我重定向第一页。
I went through many options like window.location=-window.history.back();我经历了很多选项,比如 window.location=-window.history.back(); ,window.history.back(1/-1) but none of them working. ,window.history.back(1/-1) 但他们都没有工作。
Thanks in advance :)提前致谢 :)

Try this it should work试试这个它应该工作

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

} }

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM