zoukankan      html  css  js  c++  java
  • iframe显示错误页面

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

    错误页面加载的JS如下
     1 <script type="text/javascript" language="javascript">
     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 </script>
     
    给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 }
    搏击长空
  • 相关阅读:
    浅析嵌入式程序设计中的优化问题
    TCP粘包问题
    使用python 批量 配对t检验 医学 基础研究 数据分析
    Ubuntu误删系统文件修复办法
    飞思卡尔powerpc交叉编译环境的
    ubuntu packege下载网址
    数组对象里面对日期进行排序
    c# 字符串以逗号分割属性加上单引号
    Vue mysql 变量赋值, 获取数组
    Element vue Select 下拉框默认
  • 原文地址:https://www.cnblogs.com/yitong/p/5709959.html
Copyright © 2011-2022 走看看