phonegap + framework7如何编程设置起始页面? [英] phonegap + framework7 how to programmtacally set starting page?

查看:79
本文介绍了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文件中:

//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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆