cordova - backbutton event is not been fired in phongap -


i developing mobile app using phonegap, have problem in handling backbutton event. code is,

i have device ready in index.js

var app = {     // application constructor     initialize: function() {         this.bindevents();     },      bindevents: function() {         document.addeventlistener('deviceready', this.ondeviceready, false);     },      ondeviceready: function() {         parseplugin.initialize("xxxxxxx", "xxxxxxx", function(){             //nothing required         }, function(e){             alert('unable initialize parse!');         });         parseplugin.getinstallationid(function(id) {             window.localstorage.setitem("devicetoken", id);         }, function(e) {             alert('unable devicetoken!');         });          app.receivedevent('deviceready');         window.location = "main.html"     },     // update dom on received event     receivedevent: function(id) {      } };  app.initialize(); 

my index.js redirects me page main.html, have code,

<script type="text/javascript">         document.addeventlistener("backbutton", onbackkeydown, false);          function onbackkeydown(e) {              alert('back button triggered');              console.log(e);              e.preventdefault();              return false;              }     </script> 

please guide me mistake, why not getting backbutton event.

listen event first:

    document.addeventlistener("deviceready", ondeviceready, false); 

looks this:

<script type="text/javascript">     document.addeventlistener("deviceready", ondeviceready, false);      function ondeviceready{         document.addeventlistener("backbutton", onbackkeydown, false);         function onbackkeydown(e) {              alert('back button triggered');              console.log(e);              e.preventdefault();              return false;              }         }     </script> 

Comments

Popular posts from this blog

qt - Using float or double for own QML classes -

Create Outlook appointment via C# .Net -

ios - Swift Array Resetting Itself -