iframe 直接在ios APP中运行,可能有问题,解决办法可以参考如下代码
案例一
<div id="iframe-box"> <iframe id="ifram" src="https://www.baidu.com" width="100%"></iframe> </div> <style>
#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源码
<iframe xid="iframe" width="100%" height="100%" style=" border: 0; width: 1px;min-width: 100%;*width: 100%;"/>
评一波