使用Javascript更改页面

时间:2013-03-09 15:04:44

标签: javascript cordova navigation

我正在构建一个Phonegap应用程序。我有7-8页,我需要使用Javascript在它们之间导航。我尝试过使用window.openwindow.location,但这些都无效。

如何使用Javascript更改页面?

2 个答案:

答案 0 :(得分:5)

以下代码为我工作。

window.location =“success.html”;

登录成功后我调用上面的代码。它正在重定向到android phonegap中的成功页面。

答案 1 :(得分:3)

试试这个。我认为它会对你有帮助。

<强> HTML

<a href="#" onClick="goPage1();">Go to Page1</a>

<强> JavaScript的:

function goPage1()
{
   var dirPath = dirname(location.href);
   fullPath = dirPath + "/page1.html";
   window.location=fullPath;
}
function dirname(path)
{
   return path.replace(/\\/g,'/').replace(/\/[^\/]*$/, '');
}