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

Javascript android phonegap在第二次发布时跳过主页,javascript,android,cordova,Javascript,Android,Cordova,我正在用phonegap开发一个android手机应用程序。 在主菜单上,我有4个图像,当单击一个图像时,它会将用户重定向到另一个页面。 我想让应用程序记住用户第一次打开应用程序时选择的内容,因此当他第二次使用应用程序时,应用程序应该直接打开到他第一次选择的页面 我想在应用程序的第二次午餐时跳过的第一页如下所示: <!DOCTYPE html> <html> <head> <meta name="viewport" content="width=de

我正在用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!

$(文档).ready(函数(){
$(“img.imgnavbar”).animate({
不透明度:1.0,
}, 800 );
});
正文{背景颜色:黑色;背景重复:无重复;位置:绝对;}
img.imgnavbar{高度:自动;宽度:48%;不透明度:0.0;}
.菜单{填充顶部:55%;}
阴影{高度:自动;宽度:100%;底部:0px;位置:固定;左侧:0%;z索引:-1;}
img.选择{高度:自动;宽度:100%;顶部:0px;位置:绝对;z索引:-1;}
$(“img.imgnavbar”)。单击(函数(){
如果(确认('您确定选择该公司吗?')){
$(“img.imgnavbar”).animate({
不透明度:0.0,
}, 800 );
开关($(this.attr('src')){
案例“img/cosmote4.png”:
$(“img.choose”).animate({“top”:“-=60%”,},“slow”);
$(“img.shadow”).animate({“bottom”:“-=100%”},“slow”);
setInterval(function(){window.location.replace(“cosmote.html”);
},800);
打破
案例“img/germanos2.png”:
$(“img.choose”).animate({“top”:“-=60%”,},“slow”);
$(“img.shadow”).animate({“bottom”:“-=100%”},“slow”);
setInterval(function(){window.location.replace(“germanos.html”);
},800);
打破
案例“img/zapp2.png”:
$(“img.choose”).animate({“top”:“-=60%”,},“slow”);
$(“img.shadow”).animate({“bottom”:“-=100%”},“slow”);
setInterval(function(){window.location.replace(“zapp.html”);
},800);
打破
案例“img/sunlight4.png”:
$(“img.choose”).animate({“top”:“-=60%”,},“slow”);
$(“img.shadow”).animate({“bottom”:“-=100%”},“slow”);
setInterval(function(){window.location.replace(“sunlight.html”);
},800);
打破
}
}
else{}
});
谢谢

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

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