当你的才华不能撑起你的野心时,就是你该选择学习的时候了!

window.open关闭窗体后刷新

var strurl = "Upload.aspx" + "?r=" + Math.random();
            //window.showModalDialog(strurl, this, "location=no;scroll=no;dialogHeight=480px;dialogWidth=950px;center;");
            window.open(strurl, "_blank", "location=no,scroll=yes,resizable=yes,dialogHeight=480px,dialogWidth=950px");
window.onbeforeunload = function () {
    window.opener.location.reload();
}

 上边reload();会弹确认刷新按钮,不友好。所以使用下边的脚本:

            window.onbeforeunload = function () {

                window.opener.location.href = window.opener.location.href;
            }

html弹出窗体head里再加上下边标签:

<base target="_self" />

 

window.showModalDialog刷新,需要使用window.returnValue给父窗口传值,然后根据值判断是否刷新。

 window.onbeforeunload = function () {

                window.returnValue=1;
            }
            var strurl = "Upload.aspx" + "?r=" + Math.random();
            var retObj = window.showModalDialog(strurl, window, "location=no;scroll=no;dialogHeight=480px;dialogWidth=950px;center;");
            if (typeof (retObj) != "undefined") {
                if (retObj == 1) {
                    DoQuery();
                }
            }

 

posted @ 2020-08-07 11:33  hofmann  阅读(648)  评论(0)    收藏  举报