js iframe 整理
来源:互联网 发布:图库软件下载 编辑:程序博客网 时间:2024/05/22 06:07
1.iframe子页面刷新父页面,或者将父页面重定向到指定页面
window.parent.location.href='url'
response.write("<script>window.parent.location.href='';</script>"); 这样写后台也可以。
2.子页面高度与iframe 高度相匹配(下面是转载的。没有试过,需要以后亲自尝试)
a.子页面
子页面加入ajax全局方法:
<script language="javascript" type="text/javascript"> $(document).ready(function () {//异步请求加载完成 $.ajaxSetup({ 'complete': function () { //修改iframe高度 reSizeParentIframe(); } }); }); </script>修改iframe高度:
//子页面重新修改父页面iframe高度function reSizeParentIframe() { var realHeight = 0; if (navigator.userAgent.indexOf("Firefox") > 0 || navigator.userAgent.indexOf("Mozilla") > 0 || navigator.userAgent.indexOf("Safari") > 0 || navigator.userAgent.indexOf("Chrome") > 0) { // Mozilla, Safari,Chrome, ... realHeight = window.document.documentElement.offsetHeight + 35; } else if (navigator.userAgent.indexOf("MSIE") > 0) { // IE var bodyScrollHeight = window.document.body.scrollHeight + 21; //取得body的scrollHeight var elementScrollHeight = window.document.documentElement.scrollHeight + 1; //取得documentElement的scrollHeight realHeight = Math.max(bodyScrollHeight, elementScrollHeight); //取当中比较大的一个 } else {//其他浏览器 realHeight = window.document.body.scrollHeight + window.document.body.clientHeight + 1; } if (realHeight < 400) { realHeight = 400; } if ($("#ifm", window.parent.document).is("iframe")) { $("#ifm", window.parent.document).height(realHeight); }}
3.太监一下 跳转页面各种集合 原文:http://blog.csdn.net/yuling59520/article/details/5630766
一、背景
A,B,C,D都是jsp,D是C的iframe,C是B的iframe,B是A的iframe,在D中跳转页面的写法区别如下。
二、JS跳转
window.location.href、location.href 本页面跳转,D页面跳转
parent.location.href 上一层页面跳转,C页面跳转
top.location.href 最外层页面跳转,A页面跳转
三、链接或者form
D页面中有form
<form>: form提交后D页面跳转
<form target="_blank">: form提交后弹出新页面
<form target="_parent">: form提交后C页面跳转
<form target="_top"> : form提交后A页面跳转
四、刷新
parent.location.reload():C页面刷新
window.opener.document.location.reload():C页面刷新(使用子窗口的opener对象来获得父窗口对象)
top.location.reload():A页面刷新
- js iframe 整理
- js iframe
- js iframe
- iframe.js
- iframe自学整理
- jquery、js调用iframe父窗口与子窗口元素的方法整理
- jquery、js调用iframe父窗口与子窗口元素的方法整理
- iframe高度相关知识点整理
- JS动态控制iframe高度
- iframe自适应大小(js)
- js 操作 iframe
- js 操作 iframe
- JS IFRAME传参
- js iframe ExtJs tree
- iframe 自适应高度js
- js 操作iframe元素
- JS操作iframe
- JS操作iframe 对象
- 为ArrayList去重
- 当浏览器页面放缩时......
- JavaScript学习(四)
- LNK1123: 转换到 COFF 期间失败: 文件无效或损坏
- 连接数据库的头文件设置
- js iframe 整理
- 社説 20150129 アウシュビッツ 解放70年から得る教訓の重さ
- rman 备份策略及恢复测试
- Java array[][] .clone() 二维数组和一维数组不同
- 提高Java架构师和程序员效率的10个工具
- 译文 日经春秋 20150129
- SSH的简易理解
- 分布式缓存系统Memcached(十四)——总结
- Nodejs重新学习