javascript - Navigating between 2 html pages in phonegap -


i working on phonegap application. facing 1 issue.

i have 4 html pages in application. every page contains widgets button or list view on click of button move next page. when want come on first page can't. when try come using button of device closes app.

i using device's button , not user defined, need handle that. same onbackpressed(); in android.

i know because of webview widget. unable find solution.

i new javascript, css, ajax, jquery , html5.

how handle press in phonegap?

you can make workaround solve problem.

you can define function triggered when button pressed , verify page user in, , depending on each page run different action. example, if in page3 go page 2, if page 2 go page 1 , if in page1 can close application.

wrote example you:

    <script type="text/javascript" charset="utf-8" src="phonegap-1.0.0.js"></script>     <script type="text/javascript" charset="utf-8">      document.addeventlistener("deviceready", ondeviceready, false);      // phonegap loaded , safe make calls phonegap methods     function ondeviceready() {         // register event listener         document.addeventlistener("backbutton", onbackkeydown, false);     }      // handle button     function onbackkeydown() {         var whichpage = functiontodetectcurrentpage(); //create function or detect somehow         switch(whichpage){             case "page1":               //works in android, ios not quite sure, heard it's not possible               //to programatically               navigator.app.exitapp();               break;             case "page2":               window.location = "page1.html";               break;             case "page3":               window.location = "page2.html";               break;             case "page4":               window.location = "page2.html";               break;         }     } 

take @ phonegap documention. http://docs.phonegap.com/en/1.0.0/phonegap_events_events.md.html#backbutton

let know whether helps you!


Comments

Popular posts from this blog

html - How to style widget with post count different than without post count -

How to remove text and logo OR add Overflow on Android ActionBar using AppCompat on API 8? -

IIS->Tomcat Redirect: multiple worker with default -