Onclick重定向到下一页不工作在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>

上面是我的代码重定向我的页面到下一页后点击事件。
但它并没有重定向到下一页。我也在stackoverflow上问了很多问题,但都没有成功。
请帮帮我。

你在那里做什么?如果你用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对你的网站很重要。对于您的移动应用程序,您需要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>

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

在你的头文件中添加了这个之后,你就可以访问一大堆函数了。所有的特性都可以在一个演示环境中测试,可以在这里找到:jQuery移动演示(1.4.5)。

当你完成了,你要把我的代码从我的笔复制到你的<body></body>,它应该工作。对于通过javascript更改页面,您可以使用我之前已经发布的function changePage()

我希望这对你有帮助,如果没有,请告诉我具体在哪里我可以帮助你。

我找到了我的查询的解决方案。我刚刚写了下面的函数onClick的按钮(输入类型应该是按钮,不提交,然后只有它会工作)


全心全意地()函数{

document.location = " nextpage.html";//代替window.location

}

相关内容

最新更新