我正在构建一个Phonegap应用程序。我有7-8页,我需要使用Javascript在它们之间导航。我尝试过使用window.open
和window.location
,但这些都无效。
如何使用Javascript更改页面?
答案 0 :(得分:5)
以下代码为我工作。
登录成功后我调用上面的代码。它正在重定向到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(/\/[^\/]*$/, '');
}