技术要点可以利用windows的open和closed来对子窗口的控制,需要父窗口和子窗口之间进行互动。
测试的时候,注意当前目录中,有代码中的html文件。
复制代码 代码如下:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> 
<html xmlns="http://www.w3.org/1999/xhtml"> 
<head> 
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" /> 
<title>Windows窗口打开</title> 
<script language="javascript"> 
var winID = null; 
//打开窗口 
function openWindow() 
{ 
winID = window.open("windowTime.html","JavaScript"); 
} 
//关闭窗口 
function closeWindow() 
{ 
if(winID && winID.open && !winID.closed) 
{ 
winID.close(); 
} 
} 
//更改URL网址 
function changeURL(newURL) 
{ 
if(winID && winID.open && !winID.closed) 
winID.location.href = newURL; 
} 
</script> 
</head> 
<body onunload="closeWindow()"> 
<h2>窗口的打开与关闭 
<hr /> 
<form> 
<input type="button" value="打开窗口" /> 
<input type="button" value="关闭窗口" /> 
<input type="button" value="显示性的url" /> 
<input type="button" value="重新新窗口的URL" /> 
</body> 
</html> 
您可能感兴趣的文章:
