iframe 直接在ios APP中运行,可能有问题,解决办法可以参考如下代码

案例一

#ifram {

border: 0;

width: 1px;

min-width: 100%;

*width: 100%;

}

let ifram = document.getElementById('ifram');

if (navigator.userAgent.match(/iPad|iPhone/i)) {

let iframe_box = document.getElementById('iframe-box');

iframe_box.style.width = 100 + '%';

iframe_box.style.overflowX = 'hidden';

iframe_box.style.overflowY = 'scroll';

iframe_box.style.webkitOverflowScrolling = 'touch';

ifram.setAttribute('scrolling', 'no');

iframe_box.appendChild(ifram)

}

案例二(可以直接在x5中使用)

//js中

var ifram = this.getElementByXid('iframe');

if (navigator.userAgent.match(/iPad|iPhone/i)) {

var cntent = this.getElementByXid("contents1");

cntent.style.width = 100 + '%';

cntent.style.overflowX = 'hidden';

cntent.style.overflowY = 'scroll';

cntent.style.webkitOverflowScrolling = 'touch';

ifram.setAttribute('scrolling', 'no');

cntent.appendChild(ifram)

}

ifram.src=url;

html源码

Logo

为开发者提供学习成长、分享交流、生态实践、资源工具等服务,帮助开发者快速成长。

更多推荐