Mobile phonegap+;框架7如何以编程方式设置起始页?
我有一个应用程序,一开始可以让你选择-如果你是贡献者或用户。之后,我希望始终加载参与者或用户的起始页。我知道您可以将Mobile phonegap+;框架7如何以编程方式设置起始页?,mobile,phonegap,html-framework-7,Mobile,Phonegap,Html Framework 7,我有一个应用程序,一开始可以让你选择-如果你是贡献者或用户。之后,我希望始终加载参与者或用户的起始页。我知道您可以将设置为在启动时执行一次,但如何动态执行呢?您必须使用 本地存储 如果用户在首次启动后选择“参与者”或“用户”按钮,则保存数据。 简单使用jQuery脚本: <script> $("#contributor").click( function() { //alert('button clicked'); localStor
设置为在启动时执行一次,但如何动态执行呢?您必须使用
本地存储
如果用户在首次启动后选择“参与者”或“用户”按钮,则保存数据。
简单使用jQuery脚本:
<script>
$("#contributor").click( function()
{
//alert('button clicked');
localStorage.setItem("contributor", "contributor");
}
);
</script>
祝你好运 您必须使用
本地存储
如果用户在首次启动后选择“参与者”或“用户”按钮,则保存数据。
简单使用jQuery脚本:
<script>
$("#contributor").click( function()
{
//alert('button clicked');
localStorage.setItem("contributor", "contributor");
}
);
</script>
祝你好运 @proofzy的答案是正确的,但您仍然可以只使用DOM7而不是Jquery来完成 在JS文件中:
//to save data if user pick contributor or user button after first start.
$$("#contributor").on('click', function(){
localStorage.setItem("whois", "contributor");
});
//And call this same script but for user:
$$("#user").on('click', function(){
localStorage.setItem("whois", "user");
});
//So call this function on the end of page index.html and it will redirect programmatically
function check(){
if (localStorage.getItem("whois") !== null) { //if whois exists on localStorage
if (localStorage.getItem("whois") == "user"){ // if is USER send to User Page
window.location.href = "userIndex.html"
}else if (localStorage.getItem("whois") == "contributor"){ // if is USER send to contributor Page
window.location.href = "contributorIndex.html"
}
}
}
有很多其他方法可以做到这一点,甚至更好,但这一种是最简单的。@proofzy的答案是正确的,但您仍然可以只使用DOM7而不是Jquery 在JS文件中:
//to save data if user pick contributor or user button after first start.
$$("#contributor").on('click', function(){
localStorage.setItem("whois", "contributor");
});
//And call this same script but for user:
$$("#user").on('click', function(){
localStorage.setItem("whois", "user");
});
//So call this function on the end of page index.html and it will redirect programmatically
function check(){
if (localStorage.getItem("whois") !== null) { //if whois exists on localStorage
if (localStorage.getItem("whois") == "user"){ // if is USER send to User Page
window.location.href = "userIndex.html"
}else if (localStorage.getItem("whois") == "contributor"){ // if is USER send to contributor Page
window.location.href = "contributorIndex.html"
}
}
}
有许多其他方法可以做到这一点,甚至更好,但这一种是最简单的。这也是一个很好很简单的例子。这也是一个很好很简单的例子。