如何处理使用PhoneGap的一个HTML页面的web应用Android的后退按钮点击? [英] How to handle Android's Back Button click in a single HTML page webapp using PhoneGap?
问题描述
我从我们可以使用下面的code处理后退按钮点击文档阅读:
I read from the documentation that we can handle the back button click using the following code:
document.addEventListener("backbutton", backKeyDown, true);
function backKeyDown() {
// Call my back key code here.
alert('go back!');
}
我担心的是,我有一个HTML5网页中,我有我的动画使用jQuery按照从用户选择的导航选项多个 DIV
标签菜单选项。
我怎样才能在这个单页Web应用程序,使用PhoneGap的处理后退按钮点击显示previously动画用户 DIV
。再次点击返回按钮将再次带他到previous DIV
当前previous DIV
: - )
How can I, in this single page webapp, handle the back button click using PhoneGap and show the user the previously animated div
. Clicking on the back button again would again take him to the previous div
of the current previous div
:-)
感谢。
推荐答案
我通过创建一个全局数组变量为
I solved the problem by creating a global array variable as
VAR myStack =新的Array();
然后,每当我点击了 DIV
标签,我插入里面的参数以及函数原型的 myStack
变量。对于例如:
Then whenever I clicked on the div
tag, I inserted the function prototype along with the arguments inside the myStack
variable. For eg:
myStack.push(\\MyFunction的(args1,args2); \\);
然后,使用code,我张贴在我的问题上,后退按钮
处理程序中,我写了下面code:
Then, using the code which I posted in my question, inside the BackButton
handler, I wrote the following code:
var divToShow = myStack.pop();
eval(divToShow);
希望这会帮助别人。
Hope this helps others.
这篇关于如何处理使用PhoneGap的一个HTML页面的web应用Android的后退按钮点击?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!