js iframe 整理
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/Jquery獲取iframe中的元素JSjQuery
- js獲取iframe和父級之間元素,方法、屬,獲取iframe的高度自適應iframe高度JS
- js 整理JS
- js如何從iframe子頁面中跳出JS
- iframe下重新整理頁面無法重新整理當前頁面的解決辦法
- js父頁面使用iframe中的函式JS函式
- js獲取操作iframe子頁面中元素JS
- 通過iframe呼叫天氣預報&jsonpJSON
- AngularJS整理(1.0.0)AngularJS
- 常用JS方法整理JS
- js常用方法整理JS
- nodejs模組整理NodeJS
- js實現的iframe呼叫父頁面函式JS函式
- jQuery操作iframe中js函式的方法小結jQueryJS函式
- js 部分學習整理JS
- Js方法整理自用(未完)JS
- js陣列排序整理JS陣列排序
- 鴻蒙JS 開發整理鴻蒙JS
- JSON資料整理JSON
- javascript--iframe的JS方法,用法!contentWindow 、parent、top、onloadJavaScriptJS
- html之iframe,aHTML
- laravel+iframeLaravel
- jquey操作Iframe
- js排序演算法整理JS排序演算法
- 個人JS常用類庫整理JS
- 原生js的常用方法整理JS
- 原生JS知識點整理JS
- Vue.js 面試題整理Vue.js面試題
- JS基礎知識整理JS
- JS易混淆的方法整理JS
- JS陣列字串方法整理JS陣列字串
- js正則斷言整理JS
- JS-實用方法整理JS
- 年前整理的Js規範JS
- JS跨域知識整理JS跨域
- js重新整理頁面JS
- Vue嵌入iframe,iframe如何跨域呼叫vue內路由Vue跨域路由