-
-
Save dongwq/2259810 to your computer and use it in GitHub Desktop.
解决jquerymobile用phonegap打包后后退导航失效问题
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
document.addEventListener("deviceready", function(){ | |
var initUrl = location.href; | |
if (Device.platform === 'Android') { | |
//阻止按后退按钮就退出程序 | |
navigator.app.overrideBackbutton(true); | |
} | |
/*解决jquerymobile用phonegap打包后后退导航失效问题*/ | |
document.addEventListener("backbutton", function(){ | |
//alert(location.href); | |
if(location.href === initUrl){ | |
return navigator.app.exitApp(); | |
} | |
return history.back();//这样会导致程序不能按android常规那样正常退出 | |
}, false); | |
}, false); |
Author
dongwq
commented
Mar 31, 2012
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment