87,910
社区成员
发帖
与我相关
我的任务
分享
<!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=utf-8" />
<title>新窗口打开一个页面</title>
<script type="text/javascript" src="http://s.syyx.com/nycs/js/jquery-1.4.2.min.js"></script>
<script src="script/script07.js" language="javascript" type="text/javascript" </script>
</head>
<body bgcolor="#FFFFFF">
<div align="center">
<h1>Let's Play the Windows</h1>
<h2>
<a href="#" id="openWin"> open a new window </a>
<br/>
<a href="#" id="closeWin">close a new window</a>
</h2>
</div>
</body>
</html>
// JavaScript Document
window.onlaod=newWinLinks;
var newWindow=null;
alert(document.links.length);
function newWinLinks()
{
for (var i=0;i<document.links.length;i++)
{
document.links[i].onclick=chgWindowState;
alert("111111");
}
}
function windowOpen()
{
if(newWindow && ! newWindow.closed)
{
return true;
}
return false;
}
function chgWindowState()
{
if(this.id == "closeWin")
{
if(windowOpen())
{
newWindow.close();
}
else
{
alert("This window is already open!");
}
}
if(this.id == "openWin")
{
if(windowOpen())
{
alert("The window is already open");
}
else
{
newWindow = window.open("","newWin","toolbar,location=yes,width=300,height=200");
}
}
return false;
}