当系统出现异常时,ifrme中显示的内容为错也页面,而不是罪顶层的框架显示错误内容,此时的解决办法是在错误页面或相关的登录页面中加入
错误页面加载的JS如下
<script type="text/javascript" language="javascript"> onload = function () {
/// 当显示错误页面时,首先判断iframe和最顶层的top相关的location是否为同一个对象,如果不是同一对象,
/// 让系统定位到最顶层的框架top,且让top刷新(有可能系统重新登录的,此时需要获取最新的用户数据)
if (window != top) {
top.location.href = top.location.href;
} //
//if (this.location != this.parent.location) {
// alert("this.location != this.parent.location");
// this.location = this.parent.location;
//}
} </script>
给iframe定位使用的参考脚本
/// iframe页面跳转
function NationDir(path, title) {
var heigth = $(window).height() - 57 - 55;
var width = $("div.orderMain").width() + 20;
alert(path);
$("#frameCheckIn").attr("src", path).css({ "height": heigth, "width": width }).show();
document.title = title;
$("div.orderMain").hide();
} /// 提供给子页面的返回函数
function GoBack() {
if (window != top) {
top.location.href = location.href;
} if (this.location != this.parent.location) {
this.location = this.parent.location;
}
SearchData(); var pageNew = document.getElementById("frameCheckIn");
$(pageNew).attr("src", "").hide(); //clear frame content
if (pageNew.contentDocument && pageNew.contentDocument.document) {
pageNew.contentDocument.document.body.innerHTML = "";
}
else if (pageNew.contentWindow && pageNew.contentWindow.document) {
pageNew.contentWindow.document.innerHTML = "";
}
document.title = "出入库检查";
$("div.orderMain").show(0);
}
子页面调用返回iframe的返回操作代码参考
function ViewBack() {
var bodyparent = parent.GoBack;
if (bodyparent != undefined) {
bodyparent();
}
}