-1
<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.history.back(1/-1) but none of them working.
Thanks in advance :)

jahller
  • 2,705
  • 1
  • 28
  • 30
himmatwala
  • 19
  • 1
  • 8
  • How are they not working? What happends? Any error messages in the console? Also, could you please remove all code not directly related to your question. Please read [MCVE]. – Anders Oct 27 '15 at 13:26
  • it gives error file cannot be opened sir – himmatwala Oct 27 '15 at 13:27
  • Please add that information, with the exact wording of the error message, to you question. Also you might want to include some information on what kind of file the previous page is, since it seems to be the source of the problem. And you should check if it works when the previos page is an ordinary one. – Anders Oct 27 '15 at 13:32
  • i have wrote below sir – himmatwala Oct 27 '15 at 15:16

1 Answers1

1

Try this it should work

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

}

soorapadman
  • 4,451
  • 7
  • 35
  • 47