Chrome访问服务器端HTML文件呈现的结果
Chrome访问本地HTML文件呈现的结果
本地访问的HTML文件Iframe没有根据Iframe里面的页面类容自适应高度
2.Iframe自适应高度代码
在index.html文件中间中添加Iframe页面,页面加载时,加载src指定的文件路径
JS脚本自适应调整Iframe高度
function iFrameHeight(id) { var ifm = document.getElementById(id); var subWeb = document.frames ? document.frames[id].document : ifm.contentDocument; if (ifm != null && subWeb != null) { ifm.height = subWeb.body.scrollHeight; } }
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协议不熟悉,请大家不吝赐教。
查看更多关于【HTML】iframe跨域访问问题_html/css_WEB-ITnose的详细内容...
声明:本文来自网络,不代表【好得很程序员自学网】立场,转载请注明出处:http://haodehen.cn/did107645