HBuilder synthetic APP, monitor the back button to return to the previous page

  return to previous page

document.addEventListener ( 'plusready', function () {
   var Webview = plus.webview.currentWebview () 
  plus.key.addEventListener ( 'BackButton', function () { 
    webview.canBack ( function (E) {
       IF (e.canBack ) { 
        webview.back () 
      } the else {
         // webview.close hide () //, quit 
        // plus.runtime.quit () 
        // Home key processing returns 
        @ processing logic: 1 second, twice press return key, exit application; 
        var First = null 
        plus.key.addEventListener (
           'BackButton' ,
          function () {
             // first button, suggesting 'press to exit the application' 
            IF (! First) { 
              First = new new a Date (). getTime () 
              console.log ( 'press again to exit the application') // here can with custom prompts 
              the setTimeout ( function () { 
                First = null 
              }, 1000 ) 
            } the else {
               IF ( new new a Date () the getTime () -. First <1500 ) { 
                plus.runtime.quit () 
              } 
            } 
          },
          false
        )
      }
    })
  })
})

 

Guess you like

Origin www.cnblogs.com/chaojimali/p/11304970.html