如果使用iframe将包含Three.js的文件嵌入网页中
< iframe id = viewer src = document-with-threejs.html>< / iframe>
然后,当在Mobile Safari中查看页面时,iframe的大小会无限增长.在今天发布的iOS 9中,此行为尚未得到纠正.发布此问题和答案,以便Web搜索轻松访问这些信息.
解决方法
此行为的修复程序可在
http://threejs.org/examples/index.html中找到.截至2016年7月3日的新版本和改进版本:
@H_404_10@var viewer = document.getElementById( 'viewer' );
// iOS iframe auto-resize workaround
if ( /(iPad|iPhone|iPod)/g.test( navigator.userAgent ) ) {
viewer.style.width = getComputedStyle( viewer ).width;
viewer.style.height = getComputedStyle( viewer ).height;
viewer.setAttribute( 'scrolling','no' );
}