我构建了一个Phonegap应用程序。我有7-8页,我需要使用Javascript在它们之间导航。我试过使用window.open和window.location,但它们都不起作用。
如何使用Javascript更改页面?
发布于 2013-08-01 15:02:25
尝尝这个。我想这会对你有帮助的。
<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(/\/[^\/]*$/, '');
}发布于 2021-10-22 11:30:28
如果是同一个主机名,只需使用路径名更改页面:
例如,如果您有文件名:
index.html login.html
您可以使用以下内容访问login.html:
window.location.pathname = "login.html";https://stackoverflow.com/questions/15312158
复制相似问题