using back from external pages into inline pages (framework7)

448 Views Asked by At

at my page home.html

<li><a href="#testpage" class="item-link">
<div class="item-content">
<div class="item-inner"> 
<div class="item-title">Tespage</div>
</div>
 </div></a>
 </li>

and at inlinepage of #testpage

      <div data-page="testpage" class="page cached">
        <div class="page-content">
          <div class="content-block">

            <p>Lorem ipsum dolor sit amet   </p>

          </div>
        </div>
      </div>

and my question is .. how i can go back from EXTERNAL page , into #testpage .. i've tried back from external page with url home.html#testpage . but not work..

1

There are 1 best solutions below

3
On

Did you enable pushState in the app initialization function?

var myApp = new Framework7({
    pushState: true,
    // ... other parameters
});

EDIT:

To get back from external page to a specific tab, first add this function to the js file:

function getUrlParameter(sParam) {
    var sPageURL = decodeURIComponent(window.location.search.substring(1)),
        sURLVariables = sPageURL.split('&'),
        sParameterName,
        i;

    for (i = 0; i < sURLVariables.length; i++) {
        sParameterName = sURLVariables[i].split('=');

        if (sParameterName[0] === sParam) {
            return sParameterName[1] === undefined ? true : sParameterName[1];
        }
    }
};

Then after initializing your Framework7 app, check for a parameter that contains the tab name:

if (getUrlParameter("tab")) {
   myApp.showTab("#" + getUrlParameter("tab"));
}

Now, from your external page, you can link to your tab like this:

http://myf7app/tabs-page.html?tab=tab2