언어 설정

Menu
Sites
Language
Detect tizen web app going to background?

I need detect when my app moved to background by home pressed.

I try the next code:

document.addEventListener("pause", function(){
    console.log("pause");
}, false);

$("#main-page").focusout(function (){
    console.log("received focus Out Event") ;
});

$("#main-page").on("pagehide", function() {
    console.log("main-pagehide");
});

$("#main-page").on("pageremove", function() {
    console.log("main-pageremove");
});

$("#main-page").on("pagebeforehide", function() {
    console.log("main-pagebeforehide");
});

but when I pressed home nothing happens.

Responses

3 댓글
Alex Dem

Hi,
Approach with 'focusout' should works, but maybe you should set focus on page at once.

here is my main.js:
var init = function () {
    // TODO:: Do your initialization job
    console.log("init() called");
    $("#main-page").focusout(function (){
    console.log("received focus Out Event") ;
    })
    $("#main-page").focus();
};
$(document).ready(init);

Also please check that you have include 'jquery' before you javascript.
Here is similar topic:
https://developer.tizen.org/forums/web-application-development/how-check-home-button-press
Alexey.

Alex Dem

Or just use window.onblur=function (){};  better.

Alexey.

Alexander AVSukhov