iframe显示错误页面
生活随笔
收集整理的這篇文章主要介紹了
iframe显示错误页面
小編覺得挺不錯的,現(xiàn)在分享給大家,幫大家做個參考.
當(dāng)系統(tǒng)出現(xiàn)異常時,ifrme中顯示的內(nèi)容為錯也頁面,而不是罪頂層的框架顯示錯誤內(nèi)容,此時的解決辦法是在錯誤頁面或相關(guān)的登錄頁面中加入
錯誤頁面加載的JS如下 1 <script type="text/javascript" language="javascript"> 2 3 onload = function () { 4 /// 當(dāng)顯示錯誤頁面時,首先判斷iframe和最頂層的top相關(guān)的location是否為同一個對象,如果不是同一對象, 5 /// 讓系統(tǒng)定位到最頂層的框架top,且讓top刷新(有可能系統(tǒng)重新登錄的,此時需要獲取最新的用戶數(shù)據(jù)) 6 if (window != top) { 7 top.location.href = top.location.href; 8 } 9 10 // 11 //if (this.location != this.parent.location) { 12 // alert("this.location != this.parent.location"); 13 // this.location = this.parent.location; 14 //} 15 } 16 17 </script>?
?
給iframe定位使用的參考腳本 1 /// iframe頁面跳轉(zhuǎn) 2 function NationDir(path, title) { 3 var heigth = $(window).height() - 57 - 55; 4 var width = $("div.orderMain").width() + 20; 5 alert(path); 6 $("#frameCheckIn").attr("src", path).css({ "height": heigth, "width": width }).show(); 7 document.title = title; 8 $("div.orderMain").hide(); 9 } 10 11 /// 提供給子頁面的返回函數(shù) 12 function GoBack() { 13 if (window != top) { 14 top.location.href = location.href; 15 } 16 17 if (this.location != this.parent.location) { 18 this.location = this.parent.location; 19 } 20 SearchData(); 21 22 var pageNew = document.getElementById("frameCheckIn"); 23 $(pageNew).attr("src", "").hide(); 24 25 //clear frame content 26 if (pageNew.contentDocument && pageNew.contentDocument.document) { 27 pageNew.contentDocument.document.body.innerHTML = ""; 28 } 29 else if (pageNew.contentWindow && pageNew.contentWindow.document) { 30 pageNew.contentWindow.document.innerHTML = ""; 31 } 32 document.title = "出入庫檢查"; 33 $("div.orderMain").show(0); 34 }?
1 子頁面調(diào)用返回iframe的返回操作代碼參考 1 function ViewBack() { 2 var bodyparent = parent.GoBack; 3 if (bodyparent != undefined) { 4 bodyparent(); 5 } 6 }?
?
轉(zhuǎn)載于:https://www.cnblogs.com/yitong/p/5709959.html
總結(jié)
以上是生活随笔為你收集整理的iframe显示错误页面的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 使用jQuery的hover事件在IE中
- 下一篇: 彻底弄懂css3的flex弹性盒模型