Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Load an external page within framework7 wrapper

I'm having a framework7 app and I have a requirement to load an external page into the app. It means the navigation bar and all should remain in the top but I should be able to show the content of the external url within the body. More like inapp browser.

I tried with iFrame but it doesn't work properly for https based urls. Is there any way of doing it?

Also note that if I add the external class into the anchor tag then the page opens in new window. Not inside the app.

like image 259
Reshan Kumarasingam Avatar asked Jul 14 '26 09:07

Reshan Kumarasingam


2 Answers

Use AJAX to insert html into your page. Using Javascript you can load an 'external' page (EXTERNALPAGE.php) into a <div> of you choosing (PAGEPlaceholder).

Below is a summary of suggested code, this is NOT a working example...

Your HTML could look something like this:

<div data-page="PAGENAME" class="page navbar-through toolbar-through">

<div class="navbar ">
    <div class="navbar-inner">              
         <div class="left"></div>
        <div class="center sliding">Page Title</div>
        <div class="right"></div>
    </div>
</div>  


<div class="page-content ">         
    <div id="PAGEPlaceHolder"></div>                                                    
</div>
...

And the JS could look something like this:

myApp.onPageInit('PAGENAME', function (page) {  

$$.get('EXTERNALPAGE.php', {}, function (data) {        
        $$('#PAGEPlaceHolder').html(data);          
    });     
});
like image 94
Tim V Avatar answered Jul 16 '26 05:07

Tim V


I tried using $$.get but it was including their css which messed up my stuff so I ended up using an iframe to isolate it in a popup.

$$(document).on('click', '.open-popup', function (e) {
    var link = this.data("url");
    var iframe = '<iframe width="100%" style="height: 100em;" src="http://cors.io/?u=' + link + '" frameborder="0"></iframe>';
    $$('.popup-body').html("Loading...");
    $$('.popup-body').html(iframe);
    app.popup('.popup');
});
like image 41
Adam Lane Avatar answered Jul 16 '26 06:07

Adam Lane



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!