Scripts may close only the windows that were opened by it

关闭当前窗体报如下js错误:ajax

Scripts may close only the windows that were opened by itwindows

(脚本只能关闭由它打开的窗口)post


 

使用场景,在js中关闭页面的js,以下:url

window.opener = null;
window.open('', '_self');
window.close();

未能经过。spa

关闭页面的代码写在一个ajax返回的结果中的,以下:code

$.ajax({
                type: 'post',
                url: "url",
                success: function (data) {
                    if (data.isOut) {
                        window.opener = null;
                        window.open('', '_self'); window.close();
                    }
                    else {
                        alert(data.msg);
                    }
                },
                error: function (err) {
                    alert("异常:" + err);
                }
            })

解决办法:blog

window.location.href="about:blank";
window.close();

成功关闭。ip

相关文章
相关标签/搜索