Created
December 16, 2011 09:41
-
-
Save dongyuwei/1485360 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
dongyuwei
commented
Dec 16, 2011
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment