在framework7包装器中加载外部页面

Res*_*gam 3 javascript safari iframe ios html-framework-7

我有一个framework7应用程序,并且需要将一个外部页面加载到该应用程序中。这意味着导航栏和所有内容都应保留在顶部,但我应该能够显示正文中外部URL的内容。更像inapp浏览器。

我尝试使用iFrame,但是它不适用于基于https的网址。有什么办法吗?

还要注意,如果我将external类添加到锚标记中,则页面将在新窗口中打开。不在应用内。

小智 5

使用AJAX将html插入页面。您可以使用Javascript将“外部”页面(EXTERNALPAGE.php)加载到<div>您选择的页面(PAGEPlaceholder)中。

以下是建议代码的摘要,这不是一个可行的示例...

您的HTML可能看起来像这样:

<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>
...
Run Code Online (Sandbox Code Playgroud)

JS可能看起来像这样:

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

$$.get('EXTERNALPAGE.php', {}, function (data) {        
        $$('#PAGEPlaceHolder').html(data);          
    });     
});
Run Code Online (Sandbox Code Playgroud)


Ada*_*ane 5

我尝试使用,$$.get但它包含了他们的css,这弄乱了我的东西,所以我最终使用iframe将其隔离在弹出窗口中

$$(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');
});
Run Code Online (Sandbox Code Playgroud)