android phonegap在第二次发布时跳过主页



我正在用phonegap开发一个android移动应用程序。在主菜单上,我有4个图像,当点击一个图像时,它会将用户重定向到另一个页面。我想让应用程序记住用户第一次打开应用程序时选择了什么,所以当他第二次使用该应用程序时,该应用程序应该直接打开到他第一次选择的页面。

我想在应用程序的第二次午餐时跳过的第一个页面是这样的:

<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="width=device-width, initial-scale=1">
<script src="res/jquery.js"></script>
<script>
$(document).ready(function() {
$("img.imgnavbar").animate({
opacity: 1.0,
}, 800 );
});
</script>
<style type="text/css">
body{background-color:black; background-repeat:no-repeat; position:absolute;}
img.imgnavbar{height:auto; width:48%;   opacity: 0.0;}
.menu{padding-top:55%;}  
img.shadow{height:auto; width:100%; bottom:0px; position:fixed; left:0%; z-index:-1;}
img.choose{height:auto; width:100%; top:0px; position:absolute; z-index:-1;}
</style>
</head>
<body>
<div  align="center" class="menu">
<img  src='img/cosmote4.png' id="cosmote"  class="imgnavbar" value="1"/>
<img  src='img/germanos2.png' id="germanos" class="imgnavbar" value="2"/>
<img  src='img/zapp2.png' id="zapp"  class="imgnavbar" value="3"/>
<img  src='img/sunlight4.png' id="sunlight" class="imgnavbar" value="4"/>
</div>
<img  src='img/choose.png' id="choose" class="choose"/>
<img  src='img/shadow.png' id="shadow" class="shadow"/>

<script>
$("img.imgnavbar").click(function(){
if (confirm('Are you sure you choose this company?')) {
$("img.imgnavbar").animate({
opacity: 0.0,
}, 800 );
switch ($(this).attr('src')) { 
case "img/cosmote4.png":
$("img.choose").animate({"top": "-=60%"}, "slow");
$("img.shadow").animate({"bottom": "-=100%"}, "slow");
setInterval(function(){window.location.replace("cosmote.html");
},800);
break; 
case "img/germanos2.png":
$("img.choose").animate({"top": "-=60%"}, "slow");
$("img.shadow").animate({"bottom": "-=100%"}, "slow");
setInterval(function(){window.location.replace("germanos.html");
},800);
break; 
case "img/zapp2.png":
$("img.choose").animate({"top": "-=60%"}, "slow");
$("img.shadow").animate({"bottom": "-=100%"}, "slow");
setInterval(function(){window.location.replace("zapp.html");
},800);
break;
case "img/sunlight4.png":
$("img.choose").animate({"top": "-=60%"}, "slow");
$("img.shadow").animate({"bottom": "-=100%"}, "slow");
setInterval(function(){window.location.replace("sunlight.html");
},800);
break; 
}
}
else{}
});
</script>

</body>
</html>
Thanks!

您可以使用PG中的本地存储来保存首选项。

http://docs.phonegap.com/en/2.2.0/cordova_storage_storage.md.html#localStorage

因此,当加载所选页面时,请将信息保存到本地存储器中。当加载主页时,对本地存储进行javascript检查,以检查是否存在该键的现有值,如果存在,则相应地重定向,如果没有,则这是第一次启动;什么也不做。

最新更新