父级页面动态适应iframe高度变化
来源:互联网 发布:珠宝设计软件 编辑:程序博客网 时间:2024/06/16 15:05
实现原理:
iframe通过修改父级url地址来提醒父级页面,iframe高度有变化。
父级页面中定义的iframe:
<iframe id="iframe" name="iframe" align="middle" style="min-width:1280px;width:100%;margin:0 auto" height="1000px" min-height="1000px" frameborder="0" scrolling="no" onLoad="loadIframe()" src=""></iframe>
父级页面js:
每隔200ms获取页面url的锚点高度,刷新iframe高度
$(document).ready(function() { setInterval(iframeHeight, 200);});var iframe = document.getElementById("iframe");//高度自适应var iframeHeight = function() { var hash = window.location.hash.slice(1); if (hash && /height=/.test(hash)) { iframe.height = hash.replace("height=", ""); }};
iframe动态高度的dom:
<sysconf id="sysconfdom" style=" clear:both;float:left; width:100%;">
iframe的js:
获取动态高度,改变父页面的地址
var hurl =getParentUrl();var hostUrl = hurl.split("#")[0];if(!/height=/.test(hostUrl)){ hostUrl += "#height=" + $('#sysconfdom').height(); window.top.location = hostUrl;}function getParentUrl() { var url = null; if (parent != window) { try { url = parent.location.href; } catch (e) { url = document.referrer; } } return url;}
0 0
- 父级页面动态适应iframe高度变化
- 父页面iframe高度自动适应子页面iframe高度
- iframe 自动适应页面高度
- iframe页面高度自动适应
- Iframe 自动适应页面的高度
- iframe 自动适应子页面高度宽度
- iframe自动适应高度及iframe中含有页签的高度动态适应方法
- [导入]创建高度动态变化的Iframe
- iframe高度自动适应
- iframe自动适应高度
- iframe 高度自动适应
- Iframe自动适应高度
- iframe高度自动适应
- IFRAME 自动适应高度
- Iframe自动适应高度
- iframe自动适应高度
- iframe自动适应高度
- iframe 自动适应高度
- Unity3d热更新全书-资源加载(一):从AssetBundle说起
- iOS学习之—— NSDateComponents
- android 自定义控件全系列导航
- HBase1.1.2 row lock
- svn代码量统计工具StatSVN的使用
- 父级页面动态适应iframe高度变化
- iOS 开发- 键盘类型
- rpc的go 和 call
- LeetCode:Merge Sorted Array
- LeetCode 035: Search Insert Position
- GoAhead2.5源代码分析之1-用户管理(um.c)
- 关于Ubuntu 系统 常用操作命令以备不时之需~~
- delete 和 delete []的真正区别
- Net::FTP