【发布时间】:2016-06-28 21:32:04
【问题描述】:
第二版编辑
***** 适用于 PhoneGap(以及 Safari)*******
- 从一页开始 (index.html)
- 用户单击一个按钮,该按钮使用硬编码的本地 URL 将她发送到另一个页面“secondLinkPageVerK.html”
- 在该页面上,用户可以单击另一个按钮返回到上一页 ..... 使用两个按钮进行选择
- 一个按钮是 index.html 的硬编码部分 url
- 另一个按钮选择是一种更优雅的方式,使用历史记录
**** 使用以下 Matthais 回复中的想法 **** 我仍然没有“navigator.notification.alert”技术(在 中找到) How to navigate one page to another page in android phonegap? 工作,因为我认为这是一个 PhoneGap 功能,我还不明白如何下载或链接到那些 图书馆(以某种方式搜索错误)
****** index.html 是通过按钮链接到 secondLinkPageVerK.html 的页面,该页面通过按钮链接回此页面 *******
<!DOCTYPE HTML>
<html>
<head>
<title>FIRST PhoneGap Page 1</title>
<script type="text/javascript" charset="utf-8">
</script>
<script type="text/javascript" charset="utf-8">
function onLoad()
{
document.addEventListener("deviceready", onDeviceReady, true);
}
function onDeviceReady()
{
// navigator.notification.alert("PhoneGap is working");
}
function callAnothePage()
{
window.location = "secondLinkPageVerK.html";
}
</script>
</head>
<body onload="onLoad();">
<h1>Welcome to Page 1</h1>
<h2> Version K </h2>
<button name="buttonClick" onclick="callAnothePage()">Click Me To Move to Second Page</button>
******secondLinkPageVerK.html - 链接到 ******** 的第二个页面
<!DOCTYPE HTML>
<html>
<head>
<title>SECOND PhoneGap Page 2</title>
<script>
function onLoad()
{
document.addEventListener("deviceready", onDeviceReady, true);
// document.addEventListener("backbutton", BackKeyDown, true);
}
// using it this way causes confusion, so moving to onLoad
function onDeviceReady()
{
// navigator.notification.alert("PhoneGap is working");
}
function callAnothePage()
{
window.location = "index.html";
}
// for the back button
/*
document.addEventListener("deviceready", onDeviceReady, true);
*/
function onDeviceReady()
{
document.addEventListener("backbutton", BackKeyDown, true);
}
function BackKeyDown()
{
navigator.notification.alert();
//navigator.app.exitApp(); // For Exit Application
}
function historyBack(){
history.go(-1);
navigator.app.backHistory();
}
</script>
</head>
<body onload="onLoad();">
<h1>Welcome to Page 2</h1>
<h2> Version K </h2>
<h2>Link Back and Forth</h2>
<button name="buttonClick" onclick="callAnothePage()">RETURN to Page 1 - hardcoding local URL</button>
<center> .* .* . </center>
<center> . . . </center>
<center> .* .* . </center>
<button onclick="historyBack()">Return - history.go technique - cleaner technique</button>
</body>
</html>
【问题讨论】:
-
看起来我还需要最后关闭
标签: javascript android html cordova