笔记(1):Window对象最常见的属性和函数
常用属性
- closed
A boolean value that is true only if the window has been closed.
defaultStatus, status - document
A reference to the Document object that represents the HTML document displayed in the window.
frames[] An array of Window objects that represent the frames (if any) within the window.
history A reference to the History object that represents the user's browsing history for the window.
location A reference to the Location object that represents the URL of the document displayed in the window. Setting this property causes the browser to load a new document.
name The name of the window. Can be used with the target attribute of the HTML <a> tag, for example.
opener A reference to the Window object that opened this one, or null if this window was opened by the user.
parent If the current window is a frame, a reference to the frame of the window that contains it.
self A self-referential property; a reference to the current Window object. A synonym for window.
top If the current window is a frame, a reference to the Window object of the top-level window that contains the frame. Note that top is different from parent for frames nested within other frames.
window A self-referential property; a reference to the current Window object. A synonym for self.
常用方法
- alert( ) , confirm( ), prompt( )
Display simple dialog boxes to the user and, for confirm( ) and prompt( ), get the user's response.
close( ) Close the window.
focus( ) , blur( ) Request or relinquish keyboard focus for the window. The focus( ) method also ensures that the window is visible by bringing it to the front of the stacking order.
moveBy( ) , moveTo( ) Move the window.
open( ) Open a new top-level window to display a specified URL with a specified set of features.
print( ) Print the window or frame -- same as if the user had selected the Print button from the window's toolbar (Netscape 4 and later and IE 5 and later only).
resizeBy( ) , resizeTo( ) Resize the window.
scrollBy( ) , scrollTo( ) Scroll the document displayed within the window.
setInterval( ) , clearInterval( ) Schedule or cancel a function to be repeatedly invoked with a specified delay between invocations.
setTimeout( ) , clearTimeout( ) Schedule or cancel a function to be invoked once after a specified number of milliseconds.