The Window Phase of Chrys`s Approach to ACP - Window name Property (Page 3 of 4 )
Definition and Usage
The name property sets or returns the name of the window.
Syntax
window.name=name
Example
The following example returns the name of the new window:
<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>
Window opener Property
Definition and Usage
The opener property returns a reference to the window that created the window.
Syntax
window.opener
Example
The following example writes some text to the opener window (parent window):
<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>
Window self Property
Definition and Usage
The self property returns a reference to the current window.
Syntax
window.self
Example
The following example checks whether or not the window is in a frame -- and if it is, it breaks out of the frame:
<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>
tryjs_breakout.htm is a file in the same directory.
Window status Property
Definition and Usage
The status property sets or returns the text in the status bar of a window.
Syntax
window.status=sometext
Example
The following example sets the text in the status bar:
<html>
<body><script type="text/javascript">
window.status="Some text in the status bar!!"
</script></body>
</html>
Please enable JavaScript to view the comments powered by Disqus. blog comments powered by