关于 iframe 的小问题若干

 

我们知道,iframe在传统的MVC项目里是个很常用的东西。

但这玩意用起来有时会有点烦人。

比如说:我有个一个页面套了一个iframe,iframe里面的页面通过a标签来切换。怎么做?

<li class="layui-nav-item"><a href="xxx" target="contextHomeIframe" ></a></li>
<iframe id="contextHomeIframe" name="contextHomeIframe" width="100%" scrolling="no" frameborder="0" src="xxx" style="margin-top: 10px;"></iframe>

猜猜看,target 找的是iframe的id还是name?

答案是name。

另外,父页面一般是不知道iframe的页面高度“应该是”多少的。

也就是说,你需要手动去设。

另外,在老IE和老safari上,关于iframe的DOM会和现代浏览器(chrome firefox)有些区别,需要考虑兼容性的问题。

posted on 2018-10-28 19:16  fox_charon  阅读(189)  评论(0编辑  收藏  举报

导航