【问题标题】:How to go back to previous page using javascript in phonegap如何在phonegap中使用javascript返回上一页
【发布时间】:2015-10-27 13:05:42
【问题描述】:
<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) 但它们都不起作用。
在此先感谢:)

【问题讨论】:

  • 他们怎么不工作了?发生了什么?控制台中有任何错误消息吗?另外,您能否删除与您的问题没有直接关系的所有代码。请阅读minimal reproducible example
  • 它给出错误文件无法打开先生
  • 请将该信息与错误消息的确切措辞一起添加到您的问题中。此外,您可能希望包含有关上一页是什么类型的文件的一些信息,因为它似乎是问题的根源。当previos页面是普通页面时,您应该检查它是否有效。
  • 我已经写在下面了,先生

标签: javascript html cordova phonegap-plugins


【解决方案1】:

试试这个应该可以的

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

}

【讨论】:

  • 不工作@Soorapadman 先生。它的文件不是网页先生
  • 您使用的是哪个浏览器?
  • 我正在使用 android phonegap 检查模拟器 .its
  • 你能改变类型提交到按钮并检查吗?
  • 我猜你应该看到这个链接:stackoverflow.com/questions/16542118/…
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2022-01-13
  • 2016-05-28
  • 2011-12-25
  • 2019-01-19
相关资源
最近更新 更多