Created
July 3, 2012 05:20
-
-
Save dhavaln/3037838 to your computer and use it in GitHub Desktop.
Cordova 1.9 Backbutton Override
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html> | |
<head> | |
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"> | |
<title>Insert title here</title> | |
<link rel="stylesheet" | |
href="http://code.jquery.com/mobile/1.1.0/jquery.mobile-1.1.0.css" /> | |
<script src="http://code.jquery.com/jquery-1.7.1.min.js"></script> | |
<script | |
src="http://code.jquery.com/mobile/1.1.0/jquery.mobile-1.1.0.min.js"></script> | |
<script type="text/javascript" charset="utf-8" src="cordova-1.9.0.js"></script> | |
<script type="text/javascript"> | |
document.addEventListener("deviceready", onDeviceReady, false); | |
function onDeviceReady() { | |
document.addEventListener("backbutton", handleBackButton, true); | |
} | |
function handleBackButton() { | |
console.log("back clicked"); | |
window.history.back(); | |
} | |
</script> | |
</head> | |
<body> | |
<div data-role="page" id="page1"> | |
<div data-role="header"> | |
<h1>Page 1</h1> | |
</div> | |
<div data-role="content"> | |
<a href="#page2" data-role="button">Goto Page2</a> | |
</div> | |
</div> | |
<div data-role="page" id="page2"> | |
<div data-role="header"> | |
<h1>Page 2</h1> | |
</div> | |
<div data-role="content"> | |
<a data-rel="back" data-role="button">Rel Back</a> | |
<a id="forceBack" data-role="button">Force Back</a> | |
</div> | |
</div> | |
</body> | |
<script type="text/javascript"> | |
$("#forceBack").click(function(){ | |
history.back(); | |
}); | |
</script> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment