<script type="text/javascript">
newWindow=window.open ('http://www.baidu.com', "name", "") ;
window.opener=null;
window.open("","_self");
window.close();
</script>
在ff中父窗口不能关闭。在地址栏里输入about:confit找到dom.allow_scripts_to_close_windows这一项,并把这项改为true就可能了
说明:Window对象的opener属性与打开这个窗口的父窗口相联系,当访问子窗口中的opener属性时,返回的是父窗口。通过这个属性,可以使用父窗口对象中的方法和属性。
解决思路:把父窗口的父窗口声明为null(window.opener=null),在让父窗口自己把自己声明为子窗口 (window.open("","_self")),这样父窗口自己也变成“子窗口”了,当用window.close()关闭时,就不会出现提示框 了。
window.open()函数说明:
函数原型:window.open(URL,name,param)
URL:要弹出的新的网页
name:弹出新网页的名字(不是文件名),可为空。
param:
height:窗口的像素高度。为与先前版本相兼容,这个参数仍然存在。但在JavaScript1.2中被innerHeight取代。
width:窗口的像素宽度。为与先前版本相兼容,这个参数仍然存在。但在JavaScript1.2中被innerWidth取代。
location: 是否显示地址栏
menubar:是否显示菜单栏
titlebar: 是否显示标题栏
toolbar: 是否显示工具栏
resizable:指明窗口大小是否可以调整
top=0 窗口距离屏幕上方的象素值
left=0 窗口距离屏幕左侧的象素值
status: 是否显示状态栏完整示例:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Frameset//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-frameset.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>无标题文档</title>
</head>
<body onload="openwin('http://www.baidu.com')">top
<script>
function openwin(url) {
//alert(screen.width+"*"+screen.height) ;
//openwin('left.html')
var w = screen.width -10;
var h = screen.height -85;
window.open (url, '全屏窗口测试', 'height='+ h + ', width=' + w + ', top=0,left=0 , toolbar =no, menubar=no, scrollbars=no, resizeable=no, location=no, status=yes')
window.opener=null;
window.open("","_self");
window.close();
}
</script>
</body>
</noframes></html>