我正在使用cordova状态栏插件,在我打开一个不显示浏览器或打开一个摄像头之后,它会与应用程序重叠,效果很好。
我尝试了以下方法:
<preference name="fullscreen" value="false" />
Add 20px margin, but that only works when the above scenario is encountered, else it shows blank 20px space (Used with cordova plugin)
Run Code Online (Sandbox Code Playgroud) 我是手机的初学者,想通过提供为我的网站制作应用程序
window.location的= "http://www.example.com"
而不是我的网站索引页面的所有HTML代码.但我仍然希望在我的应用程序中使用isMobile或isMobileApp等cordova功能.有什么方法可以继续这种情况,或者我必须通过我的索引页面.
另外,有没有办法通过javascript动态更改我的应用程序的index.html.
如果有人能帮助我,我将非常感激
我使用cordova和angular.js为我的移动应用程序提供了以下逻辑
处理我在index.html中包含的mobile.js中的逻辑,比如在sdcard上保存文件,然后使用用户将用户重定向到第二个html页面
window.location.href="main.html";
Run Code Online (Sandbox Code Playgroud)
这将使用mobile.js放入sdcard的文件
我面临的问题是,当我在main.html的主页上并且用户按下后退按钮时,它会返回到index.html文件,然后在处理之后返回到main.html而不是App关闭.
我尝试将history.length对象与"backbutton"eventListener一起使用
document.addEventListener('deviceready',function(){
document.addEventListener('backbutton',function(e){
console.log("history is "+history.length);
if(history.length==1){
e.preventDefault();
navigator.app.exitApp();
}
else{
navigator.app.backHistory();
}
},false);
},false);
Run Code Online (Sandbox Code Playgroud)
但它不会减少返回时的长度,只会增加它,所以应用程序返回到index.html.(history.length总是大于1)
我看过可用的解决方案,比如
document.addEventListener("backbutton", function(e){
if($.mobile.activePage.is('#homepage')){
/*
Event preventDefault/stopPropagation not required as adding backbutton
listener itself override the default behaviour. Refer below PhoneGap link.
*/
//e.preventDefault();
navigator.app.exitApp();
}
else {
navigator.app.backHistory()
}
}, false);
Run Code Online (Sandbox Code Playgroud)
但使用它的问题是,如果用户去
second-page->homepage->third-page->homepage
Run Code Online (Sandbox Code Playgroud)
应用程序将退出,但应转到第三页.