phonegap + framework7 如何以编程方式设置起始页? [英] phonegap + framework7 how to programmtacally set starting page?
本文介绍了phonegap + framework7 如何以编程方式设置起始页?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个应用程序,一开始让你选择 - 如果你是贡献者或用户.之后,我希望始终为贡献者或用户加载起始页面.我知道您可以将 <content src="index.html"/>
设置为在开始时执行一次,但是我如何动态执行此操作?
I have application which on start lets you pick - if are you contributor or user. After that I want always load the starting page for a contributor or the user. I know you can set <content src="index.html" />
to do it once on start, but how can I do it dynamically?
推荐答案
@proofzy 答案是对的,但你仍然可以只使用 DOM7 而不是 Jquery
@proofzy answer is right, but you could still do it using only DOM7 instead of Jquery
在你的 JS 文件中:
Inside your JS file:
//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"
}
}
}
还有很多其他方法可以做到这一点,甚至更好,但这是最简单的.
There are many other ways to do it, even better, but this one is simplest.
这篇关于phonegap + framework7 如何以编程方式设置起始页?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文