概述
本地同一浏览器访问本地html文件和访问服务器端html文件,本地iframe没有自适应高度,而服务器端的ifrane自适应了高度。
1.问题重现: chrome 版本 41.0.2272.101 (64-bit)
os:win8.1
chrome访问服务器端html文件呈现的结果
chrome访问本地html文件呈现的结果
本地访问的html文件iframe没有根据iframe里面的页面类容自适应高度
2.iframe自适应高度代码 在index.html文件中间中添加iframe页面,页面加载时,加载src指定的文件路径
js脚本自适应调整iframe高度
3.调试代码
uncaught securityerror: failed to read the 'contentdocument' property from 'htmliframeelement': blocked a frame with origin null from accessing a frame with origin null. protocols, domains, and ports must match.
在这里,我猜测是访问本地文件是file协议(file:///),html代码和js代码存在跨域问题。小弟对file协议不熟悉,请大家不吝赐教。