Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Try the following:</p> <pre><code>&lt;!DOCTYPE html&gt; &lt;html&gt; &lt;head&gt; &lt;title&gt;gaurish's Cordova Back Button Example&lt;/title&gt; &lt;script type="text/javascript" charset="utf-8" src="cordova-2.0.0.js"&gt;&lt;/script&gt; &lt;script type="text/javascript" charset="utf-8"&gt; // Call onDeviceReady when Cordova is loaded. // // At this point, the document has loaded but cordova-2.0.0.js has not. // When Cordova is loaded and talking with the native device, // it will call the event `deviceready`. // function onLoad() { document.addEventListener("deviceready", onDeviceReady, false); } // Cordova is loaded and it is now safe to call Cordova methods // function onDeviceReady() { // Register the event listener document.addEventListener("backbutton", onBackKeyDown, false); } // Handle the back button // function onBackKeyDown() { } &lt;/script&gt; &lt;/head&gt; &lt;body onload="onLoad()"&gt; &lt;/body&gt; &lt;/html&gt; </code></pre> <p>now, to test this</p> <ol> <li><p>Add some code into <code>onBackKeyDown()</code> which you want to run, example</p> <p><code>function onBackKeyDown() { currentId = $.mobile.activePage.attr('id'); if(currentId == "#swipediv"){ $.mobile.changePage("#home", "slide", false, true); } else{ history.go(-1); } }</code></p></li> <li><p>Loadup <code>cordova-2.0.0.js</code></p></li> <li>checkout <a href="http://www.scottlogic.co.uk/blog/colin/2012/01/wp7-phonegap-backbutton-support-re-visited/" rel="nofollow">WP7 PhoneGap Backbutton Support Re-visited</a></li> <li>read the <a href="http://docs.phonegap.com/en/2.0.0/cordova_events_events.md.html#backbutton" rel="nofollow">documentation</a></li> </ol> <p>If this still doesn't work, file a <a href="https://issues.apache.org/jira/browse/CB" rel="nofollow">bug report</a>.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload