📄 16.13 open方法.html
字号:
<html>
<head>
<title>无标题文档</title>
</head>
<body>
<script>
var newWin;
var intervalID;
var timeLen=0;
function getTimeLen()
{
//如果窗口已经关闭
if (newWin.closed)
{
window.clearInterval(intervalID);
window.alert("窗口打开了"+timeLen+"秒");
}
else
{ timeLen++;
window.defaultStatus =timeLen;
}
}
function openNew()
{
newWin=window.open("","公告","height=200,width=200,toolbar=no,menubar=no,status=yes,location=no,top=200,left=200,resizable=yes");
newWin.document.write("<h4 align='center'>公告</h4>");
newWin.document.write("这是一个closed属性测试");
newWin.document.write("<center><input type='button' value='关闭窗口' onclick='window.opner=null;window.close();'</center>");
intervalID=window.setInterval(getTimeLen,1000);
}
</script>
<form><input type="button" onclick="openNew()" value="打开窗口"></form>
</body>
</html>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -