简体   繁体   中英

when I use iframe in ion-content, the ion-content scroll is not working

<ion-view view-title="title">
  <ion-content scroll="true">
    <iframe src="{{link}}"></iframe>
  </ion-content>
</ion-view>

look at the code above.

as the title says,when I use a iframe in the ion-content the scroll does't work.

How to solve this problem.

Use overflow-scroll to enable scrolling

<ion-view view-title="title">
    <ion-content overflow-scroll="true">
         <iframe src="{{link}}"></iframe>
    </ion-content>
</ion-view>

It's a bug on ios. I have resolved this problem. Refer to the following

Iframe scrolling iOS 8

Add the following css to the parent div of iframe

-webkit-overflow-scrolling: touch !important;
overflow: scroll !important;

Exmaple:

HTML

<ion-content class="iframe-fix">
  <iframe [src]="pageUrl" frameborder="0"></iframe>
</ion-content>

SCSS

.platform-ios{
    .iframe-fix{
      -webkit-overflow-scrolling: touch !important;
      overflow: scroll !important;
    }
}
<ion-view title="sample page">
 <ion-content>
 <iframe src="http://www.w3schools.com">
       <p>Your browser does not support iframes.</p>
</iframe>
</ion-content>
<ion-view>

it will work scroll option is default true.no need to add specifically

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