handling back button in android from jquery

前端 未结 2 1058
既然无缘
既然无缘 2021-01-25 08:51

We have developed an application in jQuery integrated with android (which has only one activity). From this activity we are loading an HTML file, on this file we are showing and

2条回答
  •  余生分开走
    2021-01-25 09:18

    Try this:

    function onDeviceReady() {
        // Add this line to the on onDeviceReady() function
        document.addEventListener("backbutton", onBackKeyDown, false);
    }
    
    // Handle back button hardware
    function onBackKeyDown(e) {
        e.preventDefault(); // the default action of the event e should not be triggered. 
        history.back(1); // load the previous window.location
    }
    

提交回复
热议问题