Home > Web Front-end > HTML Tutorial > iframe跨域高度自适应_html/css_WEB-ITnose

iframe跨域高度自适应_html/css_WEB-ITnose

WBOY
Release: 2016-06-24 11:24:34
Original
1074 people have browsed it

前提:我们可以改动两个域下面的页面代码。...域A域B...比如我们想实现,域A上通过iframe显示域B的页面内容,同时让域A的页面自适应域B的页面高度。...1、在域A的页面,iframe域B的页面<iframe height='200px' id='iframeA' src="http://域B/B.html"></iframe>  ...2、域B的页面B.html写一个窗口加载事件: window.onload = function(){}...  -1、创建一个iframe,设置其高宽为0px(这是为了不占空间);  -2、获取本页面的完整高度,  -3、设置iframe.src为:域A/set_DomainA_Height.html#接“完整高度”  -4、然后把iframe给append到本页面----document.body.appendChild(iframe)...3、在域A下创建set_DomainA_Height.html...因为本页面跟域A处于同一域,所以就不存在跨域了,可以直接设置域A的Iframe的高度,以此实现高度自适应。...  -1、获取域A的iframe parent.parent.document.getElementById("iframe1"); ...  -2、获取锚点参数--高度值window.location.hash.split("#"); ...  -3、设置域A的高度为得到的值...Done
Copy after login

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template