iframe显示错误页面 您所在的位置:网站首页 iframe地址显示报错内容 iframe显示错误页面

iframe显示错误页面

2024-03-25 04:32| 来源: 网络整理| 查看: 265

当系统出现异常时,ifrme中显示的内容为错也页面,而不是罪顶层的框架显示错误内容,此时的解决办法是在错误页面或相关的登录页面中加入

错误页面加载的JS如下 1 2 3 onload = function () { 4 /// 当显示错误页面时,首先判断iframe和最顶层的top相关的location是否为同一个对象,如果不是同一对象, 5 /// 让系统定位到最顶层的框架top,且让top刷新(有可能系统重新登录的,此时需要获取最新的用户数据) 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

 

 

  给iframe定位使用的参考脚本 1 /// iframe页面跳转 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 /// 提供给子页面的返回函数 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 子页面调用返回iframe的返回操作代码参考 1 function ViewBack() { 2 var bodyparent = parent.GoBack; 3 if (bodyparent != undefined) { 4 bodyparent(); 5 } 6 }

 

 



【本文地址】

公司简介

联系我们

今日新闻

    推荐新闻

    专题文章
      CopyRight 2018-2019 实验室设备网 版权所有