Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
459 views
in Technique[技术] by (71.8m points)

mobile - phonegap + framework7 how to programmtacally set starting page?

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?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

@proofzy answer is right, but you could still do it using only DOM7 instead of Jquery

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.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...