父页面:
//声明一个全局变量
var openWindow;
/**
* 简单了封装了一下window.open方法
*/
function openNewWindow(url,name){
var url=url; //转向网页的地址;
var name=name; //网页名称,可为空;
var iWidth=720; //弹出窗口的宽度;
var iHeight=600; //弹出窗口的高度;
//获得窗口的垂直位置
var iTop = (window.screen.availHeight - 30 - iHeight) / 2;
//获得窗口的水平位置
var iLeft = (window.screen.availWidth - 10 - iWidth) / 2;
openWindow=window.open(url, name, 'height=' + iHeight + ',,innerHeight=' + iHeight + ',width=' + iWidth + ',innerWidth=' + iWidth + ',top=' + iTop + ',left=' + iLeft + ',status=no,toolbar=no,menubar=no,location=no,resizable=no,scrollbars=0,titlebar=no');
}
//执行关闭方法
function Close(){
//你也可以在自己调用完window.open方法之后,在自己需要关闭window.open地方执行openWindow.close()也行
openWindow.close();
}
子页面:通过 window.opener.Close()方法关闭自己,在需要关闭的地方执行也行
function colseWin(){
window.opener.Close();
}