Window 对象
来源:互联网 发布:中邮网络培训学院 编辑:程序博客网 时间:2024/06/07 21:33
HTML DOM closed 属性
closed 属性可返回一个布尔值,该值声明了窗口是否已经关闭。该属性为只读。
当浏览器窗口关闭时,表示该窗口的 Windows 对象并不会消失,它将继续存在,不过它的 closed 属性将设置为 true。
<html>
<head>
<script type="text/javascript">
function ifClosed()
{
document.write("'myWindow' has been closed!")
}
function ifNotClosed()
{
document.write("'myWindow' has not been closed!")
}
function checkWin()
{
if (myWindow.closed)
ifClosed()
else
ifNotClosed()
}
</script>
</head>
<body>
<script type="text/javascript">
myWindow=window.open('','','width=200,height=100')
myWindow.document.write("This is 'myWindow'")
</script>
<input type="button" value="Has 'myWindow' been closed?"
onclick="checkWin()">
</body>
</html>
HTML DOM defaultStatus 属性
defaultStatus 属性可设置或返回窗口状态栏中的默认文本。该属性可读可写。
该文本会在页面加载时被显示。
<html>
<body>
<script type="text/javascript">
window.defaultStatus="This is the default text in the status bar!!";
</script>
<p>Look at the text in the statusbar.</p>
</body>
</html>
HTML DOM innerheight、innerwidth 属性
只读属性,声明了窗口的文档显示区的高度和宽度,以像素计。
这里的宽度和高度不包括菜单栏、工具栏以及滚动条等的高度。
IE 不支持这些属性。它用 document.documentElement 或 document.body (与 IE 的版本相关)的 clientWidth 和 clientHeight 属性作为替代。
HTML DOM innerheight、innerwidth 属性
只读属性,声明了窗口的文档显示区的高度和宽度,以像素计。
这里的宽度和高度不包括菜单栏、工具栏以及滚动条等的高度。
IE 不支持这些属性。它用 document.documentElement 或 document.body (与 IE 的版本相关)的 clientWidth 和 clientHeight 属性作为替代。
HTML DOM name 属性
name 属性可设置或返回存放窗口的名称的一个字符串。
该名称是在 open() 方法创建窗口时指定的或者使用一个 <frame> 标记的 name 属性指定的。
窗口的名称可以用作一个 <a> 或者 <form> 标记的 target 属性的值。以这种方式使用 target 属性声明了超链接文档或表单提交结果应该显示于指定的窗口或框架中。
<html>
<head>
<script type="text/javascript">
function checkWin()
{
document.write(myWindow.name)
}
</script>
</head>
<body>
<script type="text/javascript">
myWindow=window.open('','MyName','width=200,height=100')
myWindow.document.write("This is 'myWindow'")
</script>
<input type="button" value="What's the name of 'myWindow'?"
onclick="checkWin()">
</body>
</html>
HTML DOM opener 属性
opener 属性是一个可读可写的属性,可返回对创建该窗口的 Window 对象的引用。
opener 属性非常有用,创建的窗口可以引用创建它的窗口所定义的属性和函数。
<html>
<body>
<script type="text/javascript">
myWindow=window.open('','MyName','width=200,height=100')
myWindow.document.write("This is 'myWindow'")
myWindow.focus()
myWindow.opener.document.write("This is the parent window")
</script>
</body>
</html>
HTML DOM self 属性
self 属性可返回对窗口自身的只读引用。等价于 Window 属性。
<html>
<head>
<script type="text/javascript">
function breakout()
{
if (window.top!=window.self)
{
window.top.location="tryjs_breakout.htm"
}
}
</script>
</head>
<body>
<input type="button" onclick="breakout()"
value="Break out of frame!">
</body>
</html>
HTML DOM status 属性
status 属性可设置或返回窗口状态栏中的文本。
<html>
<body>
<script type="text/javascript">
window.status="Some text in the status bar!!"
</script>
</body>
</html>
HTML DOM top 属性
top 属性返回最顶层的先辈窗口。
该属性返回对一个顶级窗口的只读引用。如果窗口本身就是一个顶级窗口,top 属性存放对窗口自身的引用。如果窗口是一个框架,那么 top 属性引用包含框架的顶层窗口。
<html>
<head>
<script type="text/javascript">
function breakout()
{
if (window.top!=window.self)
{
window.top.location="tryjs_breakout.htm"
}
}
</script>
</head>
<body>
<form>
Click the button to break out of the frame:
<input type="button" onclick="breakout()" value="Break out!">
</form>
</body>
</html>
- window对象
- window对象
- Window对象
- window对象
- window对象
- window对象
- Window 对象
- window对象
- Window 对象
- window对象
- window对象
- window对象
- Window 对象
- Window对象
- window对象
- Window对象
- window对象
- window对象
- BZOJ 2144 LCA 解题报告
- 计算循环队列元素个数
- 怎么面试架构师
- F1V3.0-图形-绘图快捷操作帮助
- CDOJ1590-dfs+树链剖分(2017 UESTC Training for Data Structures O)
- Window 对象
- 利用递归求n以内的素数之和
- 位操作-leetcode 401. Binary Watch
- Android中EditText限制仅允许输入汉字/仅允许汉字和数字
- 百度ueditor富文本--PC端单个,PC端多个,mobile单个,mobile多个
- win7 codeblock在调用boost::thread遇到的错误——解决办法
- 我的第一个Hbuilder项目(WEB)
- 照片人脸建模
- Linux 升级 Python 至 3.x