Second Edited Version
***** Works in PhoneGap (as well as Safari) *******
- Starts on one page (index.html)
- User clicks on a button which sends her to another page "secondLinkPageVerK.html" using a hardcoded local URL
- On that page, user can click on another button which returns her to the previous page ..... Using a choice of two buttons
- one button is a hardcoded partial url for index.html
- the other button choice is a more elegant way, using history
**** Using ideas from Matthais responses below ****
I still don't have the "navigator.notification.alert" technique (found in )
How to navigate one page to another page in android phonegap? working, because I think that's a PhoneGap function and I don't yet understand how to download or link to those
libraries (searching wrong somehow)
****** index.html is the page that - with a button - links out to secondLinkPageVerK.html, which links back - with a button -to this page *******
<!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 - The second page to link to ********
<!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>
tags as well!
– LaurelS Jun 29 '16 at 22:46