如何在Tizen中在多页Webapp中实现后退硬件密钥 [英] How to implement back hardware key in multipage webapp in tizen
本文介绍了如何在Tizen中在多页Webapp中实现后退硬件密钥的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我对tizen应用程序开发非常陌生.我正在使用Tizen Web UI Builder开发多页应用程序.如何实现返回上一页的硬件后退键? 我已经尝试过使用它.
I am pretty new to tizen app development .I am developing a multipage app using Tizen Web UI Builder. How can I implement hardware back key for going back to previous page? I have already tried using this.
document.addEventListener('tizenhwkey', function(e) {
var activePage = $.mobile.activePage().attr('id'); // read current page
switch(e.keyName)
{
case 'back':
switch(activePage)
{
case 'page1':
tizen.application.getCurrentApplication().exit();
break;
default:
parent.history.back();
break;
}
break;
case 'menu':
switch(activePage)
{
case 'page2':
console.log('you are on '+activePage);
break;
default:
//TODO: Do something
break;
}`enter code here`
break;
}});`
推荐答案
请尝试以下代码,它将起作用:
Please try out the below code , it will work :
window.addEventListener('tizenhwkey', function(e) {
var activePage = $.mobile.activePage.attr('id');
switch (e.keyName) {
case 'back':
switch (activePage) {
case 'page1': // use your first page or another page where the application should close if the use press back
tizen.application.getCurrentApplication().exit();
//tizen.application.getCurrentApplication().exit();
break;
case 'page2':
window.history.back(history);
break;
case 'page3':
window.history.back(history);
default: // if no case available, the back button returns back to previous page
console.log("Do something");
//$.mobile.back();
}
break;
}
});
这篇关于如何在Tizen中在多页Webapp中实现后退硬件密钥的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文