网站推广的心得,滨州网站建设hskj360,智慧团建网页版登录入口,免费h5场景制作软件页面中用到iframe不能完全显示的解决方案 如果在页面中用到了iframe标签#xff0c;有时在浏览器中并不能完全显示iframe#xff0c;导致有些iframe内的内容不能被显示#xff0c;如果遇到这种情况#xff0c;使用以下js可以解决大多数问题。 这是iframe标签#xff1a; 有时在浏览器中并不能完全显示iframe导致有些iframe内的内容不能被显示如果遇到这种情况使用以下js可以解决大多数问题。 这是iframe标签 iframe marginwidth0 src marginheight0 width100% namei idurlIframe frameborder0 scrollingno onloadreinitIframe() /iframe 在加载时执行reinitIframe()函数以下是函数内容 代码 function reinitIframe() { var iframe document.getElementById(urlIframe); try { var bHeight iframe.contentWindow.document.body.scrollHeight; /* var dHeight iframe.contentWindow.document.documentElement.scrollHeight; var height Math.max(bHeight, dHeight); iframe.height height; */ iframe.height bHeight; } catch (ex) { } } 实际中使用变量bHeight可以正好得到完整的高度如有需要可以使用dHeight并得到两者的最大值但实际应用中使用dHeight只是记录每一次得到的最大值会带来一些问题。具体应用还是看需求吧。 posted on 2010-10-27 14:51 Johnny_Z 阅读(...) 评论(...) 编辑 收藏 转载于:https://www.cnblogs.com/Johnny_Z/archive/2010/10/27/1862623.html