onclick 重定向到下一页在 phonegap 中不起作用

onclick to redirect to next page not working in phonegap

<html>
<head>
<title>Quiz Application</title>
<script type="text/javascript" charset="utf-8" src="cordova-1.9.0.js"></script>
<script type="text/javascript" charset="utf-8">
function ready()
{
if(document.getElementById("rb2").checked)
{
alert("correct");
}else if(document.getElementById("rb1").checked)
{
alert("incorrect");
}
else
{
alert("incorrect");
}
}    
function nextPage()
 {
                 window.location = "next.html";
 }
</script>
</head>
<body>
<form method="post">
<center><h1>Quiz Application</h1></center><br><br>
<center>What does JVM stands for ?<br><br>
<radiogroup>
<input type="radio"  id="rb1"/>Java Vendor Machine<br>
<input type="radio"  id="rb2"/>Java Virtual Machine<br>
<input type="radio"  id="rb3"/>Java Viral Machine<br>
<input type="submit" id="sub" value="Freeze" onclick="ready();"/><br>
<input type="submit" id="next" value="Next Question" onclick="nextPage();"/></center>
</radiogroup>
</form>
</body>
</html>

以上是我在点击事件后将我的页面重定向到下一页的代码。
但它没有重定向到下一个 page.I 也经历了很多关于 Whosebug 的问题,但没有成功。
请帮助我。
提前致谢。

你在那里做什么?如果您使用 jQuery 移动设备进行此操作,示例将如下所示:

<html>
<head>
    <meta charset="utf-8">
    <link rel="stylesheet" type="text/css" href="css/stylesheet.css">
    <script type="text/javascript" src="js/jquery-2.1.4.min.js"></script>
    <script type="text/javascript" src="js/jquery.mobile-1.4.5.min.js">    </script>
</head>
<body>
    <div data-role="page" id="page1">
        <p>This is page 1. If you want to go to Page 2 click <a href="#page2"> here</a>.
    </div>

    <div data-role="page" id="page2">
        <p>This is page 2. If you want to go back to Page 1 click <a href="#" data-rel="back" data-transition="reverse"> here</a>.
    </div>
</body>
</html>

按功能更改页面可能如下所示:

function changePage() {
    $.mobile.changePage( "#loginPAGE", { transition: "none", changeHash: true });
}

这是一支笔:http://codepen.io/anon/pen/gaeoQE


框架 - 移动应用程序开发

正如我在评论中所说,我建议您使用框架。因为我不知道,你对 JavaScript 的熟悉程度以及我认为你应该从 jQuery 开始的任何其他事情。对于移动应用程序开发,在我看来,它不是最好的框架之一,但它易于学习,这对您入门很重要。

所以jQuery is a thing for your website. For your mobile application you need jQuery mobile

你去那个网站下载两个。下载完成后,您将打开 index.html 并将脚本添加到 <head></head> 部分,如下所示:

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

这些事情很重要。包含脚本的顺序也很重要。

将此添加到您的 header 后,您可以访问一大堆功能。所有功能都可以在演示环境中进行测试,可以在此处找到:jQuery mobile Demos (1.4.5).

完成后,您可以将我的代码从我的笔中复制到您的 <body></body> 中,它应该可以工作。要通过 javascript 更改页面,您可以使用我之前发布的 function changePage()

希望这对您有所帮助,如果没有,请告诉我具体可以在哪些方面为您提供帮助。

我找到了我的查询的解决方案。我刚刚写了以下函数 onClick of a button(输入类型应该是按钮而不是提交然后才有效)

函数 nextPage()
{

document.location="nextpage.html"; //而不是window.location

}