Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

I want to give a pop up whenever the back button is clicked. Using my code now back button is disable but it is not giving alert message.It is still not working. My work..

function load()
{
document.addEventListener("backbutton", backKeyDown, false);
function backKeyDown() {console.log("PhoneGap Ready!");}
}

<body onLoad="load()">
</body>
See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
156 views
Welcome To Ask or Share your Answers For Others

1 Answer

Just try to Call this document addEventListener inside the pageshow function. you have to check the backbutton event in the every page show.

This example will help you,

$(document).bind ('pageshow', function (e, data) {
            document.addEventListener("backbutton", function () { 
                setTimeout( function() {console.log("PhoneGap Ready!");}, 100 );
            }, true);
        }
    });

Just call this bind method in the onDeviceReady method. Body onLoad Event does not work in some cases of phonegap. Use with phonegap events.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...