EJLD
Posts: 0
Joined: Sun Jun 08, 2014 11:03 pm

back button android

hi there, looked at that link
http://docs.phonegap.com/en/2.0.0/cor...
which i found in a closed topic on this forum
I placed the code in my page. however, does not work as expected. the listener fires something when backbutton is pressed. but, that "something" is not the code I inserted. in fact, it keeps showing the spinning circle as it was stuck executing something in loop.
anybody has ever succeeded at overriding that backbutton default event ?
thk you very much for any advice in advance
Eric

Serhii Kulibaba
Posts: 150
Joined: Tue Aug 27, 2013 1:47 pm

back button android

Hello,

Have you set 'backbutton' event for that page? What exactly have you used there?

EJLD
Posts: 0
Joined: Sun Jun 08, 2014 11:03 pm

back button android

thks for your prompt reply Sergiy
I would like to fire the onbeforeunload popup when pressing the device backbutton.
I have tried several ways :
a/ code as per phonegap link in msg above: didn't fire anything
b/ set the backbutton event from the appery UI panel : didn't fire anything
c/ code the js listener window.onbeforeunload=myf(); but quite inconsistent. the popup shows up or doesn't show ... strange behavior on pressing backbutton and reaching the previous page opened in the same window (even though this event listener is consistent when unloading the page from the url bar using a new url address).

not too sure, all that is clear enough for you to help me.

just ask you to give me some direction on how can I get the backbutton event within a HTML site (not a built up hybrid app). any clue ?

thks again
Eric

Alena Prykhodko
Posts: 0
Joined: Tue Apr 09, 2013 7:36 am

back button android

Hello,

Use this code instead:

prewindow.addEventListener("hashchange", onHashChanged, false);

function onHashChanged(event) {
var msg = "Navigating from: " + event.oldURL +
"\nNavigating to: " + event.newURL;
alert(msg);
}
/pre

You can track when you navigate to another page and check it when executing custom logic.

Return to “Issues”