IT忍者神龟之 js 父窗口控制子窗口的行为

来源:互联网 发布:广州创联软件 编辑:程序博客网 时间:2024/04/28 12:51
<!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("vipyhd.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="打开窗口" onclick="openWindow()" /> 
<input type="button" value="关闭窗口" onclick="closeWindow()" /> 
<input type="button" value="显示性的url" onclick="changeURL('yes.html')" /> 
<input type="button" value="重新新窗口的URL" onclick="changeURL('displayClock.html')" /> 
</body> 

</html> 

注意:代码里面涉及的其他页面自己编写填补上即可。

0 0
原创粉丝点击