简体   繁体   中英

iframe ionic3 app crash when click inside the iframe

Hey I am using flipping book url inside iframe:

<ng-container>
        <iframe 
                [src]="eUrl"
                id="flipping_book_iframe"
                frameborder="0"
                allowfullscreen="allowfullscreen"></iframe>
</ng-container>

So when I click on download button (coming from the flipping book url )inside the iframe the app crash after some seconds. But the next and previous slides are working

Ionic:

ionic (Ionic CLI) : 4.0.2

Ionic Framework : ionic-angular

3.9.2 @ionic/app-scripts : 3.2.0

Cordova:

cordova (Cordova CLI) : 8.1.2 (cordova-lib@8.1.1)

Cordova Platforms: not available

System:

Android SDK Tools : 25.2.5

NodeJS : v8.9.3

npm : 5.4.2

OS : Windows 10

I find this inside iframe : but it seems don't work on mobile: publication.pdf it works normal on website.

i find a solution : edit htlml iframe to :

<ng-container>
    <iframe 
            [src]="eUrl"
            id="flipping_book_iframe"
            #flippingBook
            (load)="onLoadFlippingBook()"
            frameborder="0"
            allowfullscreen="allowfullscreen"></iframe>
</ng-container>

.ts file :

 @ViewChild('flippingBook') flippingBookIframe: ElementRef;

onLoadFlippingBook(){
    if(this.flippingBookIframe){
      let iframe = jQuery('#flipping_book_iframe');
      let allAs = iframe.contents().find('a[target=_blank]');
      allAs.on("click",function(e){
        e.preventDefault();
        let url = this.href;
        window.open(url,"_system");
      });
    }

at least when u click on download button the pdf opened

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM