Click here to Skip to main content
       

JavaScript

 
Questionjavascript PinmemberNAVNEET KUMAR SINGH18-Feb-13 18:45 
AnswerRe: javascript PinmvpRahul Rajat Singh18-Feb-13 23:52 
AnswerRe: javascript Pinmemberryanb3119-Feb-13 2:37 
QuestionJavaScript run slow with Ipad iOS 6 Pinmemberkornkimhour13-Feb-13 22:59 
QuestionJavaScript: How to reference user control inside content page? PinmemberTesic Goran12-Feb-13 20:36 
SuggestionRe: JavaScript: How to reference user control inside content page? PinmemberBlikkies13-Feb-13 2:14 
AnswerRe: JavaScript: How to reference user control inside content page? Pinmemberryanb3114-Feb-13 3:33 
AnswerRe: JavaScript: How to reference user control inside content page? Pinmembertwseitex15-Feb-13 0:02 
Represents an open window in the browser.
 
Members Table
 
The following table lists the members exposed by the window object. Click a tab on the left to choose the type of member you want to view.
 
   Attributes/Properties     

Show:
Attributes/Properties
Collections
Events
Methods
Objects
Property Description
closed Retrieves whether the referenced window is closed.
defaultStatus Sets or retrieves the default message displayed in the status bar at the bottom of the window.  
dialogArguments Retrieves the variable or array of variables passed into the modal dialog window.  
dialogHeight Sets or retrieves the height of the modal dialog window.  
dialogLeft Sets or retrieves the left coordinate of the modal dialog window.  
dialogTop Sets or retrieves the top coordinate of the modal dialog window.  
dialogWidth Sets or retrieves the width of the modal dialog window.  
frameElement Retrieves the frame or iframe object that is hosting the window in the parent document.
length Sets or retrieves the number of objects in a collection.
name Sets or retrieves a value that indicates the window name.
offscreenBuffering Sets or retrieves whether objects are drawn offscreen before being made visible to the user.
opener Sets or retrieves a reference to the window that created the current window.  
parent Retrieves the parent of the window in the object hierarchy.  
returnValue Sets or retrieves the value returned from the modal dialog window.  
screenLeft Retrieves the x-coordinate of the upper left-hand corner of the browser's client area, relative to the upper left-hand corner of the screen.  
screenTop Retrieves the y-coordinate of the top corner of the browser's client area, relative to the top corner of the screen.
self Retrieves a reference to the current window or frame.  
status Sets or retrieves the message in the status bar at the bottom of the window.
top Retrieves the topmost ancestor window.



 
Attributes/Properties
 
Collections
 
Collection Description
frames Retrieves a collection of all window objects defined by the given document or defined by the document associated with the given window.
 
Events
 
Event Description
onactivate Fires when the object is set as the active element.
onafterprint Fires on the object immediately after its associated document prints or previews for printing.  
onbeforedeactivate Fires immediately before the activeElement is changed from the current object to another object in the parent document.
onbeforeprint Fires on the object before its associated document prints or previews for printing.  
onbeforeunload Fires prior to a page being unloaded.  
onblur Fires when the object loses the input focus.  
oncontrolselect Fires when the user is about to make a control selection of the object.
ondeactivate Fires when the activeElement is changed from the current object to another object in the parent document.
onerror Fires when an error occurs during object loading.
onfocus Fires when the object receives focus.  
onhelp Fires when the user presses the F1 key while the browser is the active window.  
onload Fires immediately after the browser loads the object.  
onmove Fires when the object moves.
onmoveend Fires when the object stops moving.
onmovestart Fires when the object starts to move.
onresize Fires when the size of the object is about to change.  
onresizeend Fires when the user finishes changing the dimensions of the object in a control selection.
onresizestart Fires when the user begins to change the dimensions of the object in a control selection.
onscroll Fires when the user repositions the scroll box in the scroll bar on the object.  
onunload Fires immediately before the object is unloaded.  
 
Methods
 
Method Description
alert Displays a dialog box containing an application-defined message.  
attachEvent Binds the specified function to an event, so that the function gets called whenever the event fires on the object.
blur Causes the element to lose focus and fires the onblur event.
clearInterval Cancels the interval previously started using the setInterval method.  
clearTimeout Cancels a time-out that was set with the setTimeout method.  
close Closes the current browser window or HTML Application (HTA).  
confirm Displays a confirmation dialog box that contains an optional message as well as OK and Cancel buttons.
createPopup Creates a popup window.
detachEvent Unbinds the specified function from the event, so that the function stops receiving notifications when the event fires.
execScript Executes the specified script in the provided language.
focus Causes the element to receive the focus and executes the code specified by the onfocus event.  
moveBy Moves the screen position of the window by the specified x and y offset values.
moveTo Moves the screen position of the upper-left corner of the window to the specified x and y position.  
navigate Loads the specified URL to the current window.
open Opens a new window and loads the document specified by a given URL.
print Prints the document associated with the window.
prompt Displays a dialog box that prompts the user with a message and an input field.
resizeBy Changes the current size of the window by the specified x- and y-offset.  
resizeTo Sets the size of the window to the specified width and height values.  
scroll Causes the window to scroll to the specified x- and y-offset at the upper-left corner of the window.  
scrollBy Causes the window to scroll relative to the current scrolled position by the specified x- and y-pixel offset.  
scrollTo Scrolls the window to the specified x- and y-offset.  
setActive Sets the object as active without setting focus to the object.
setInterval Evaluates an expression each time a specified number of milliseconds has elapsed.
setTimeout Evaluates an expression after a specified number of milliseconds has elapsed.  
showHelp Displays a Help file. This method can be used with Microsoft HTML Help.  
showModalDialog Creates a modal dialog box that displays the specified HTML document.
showModelessDialog Creates a modeless dialog box that displays the specified HTML document.
 
Objects
 
Object Description
clientInformation Contains information about the Web browser.  
clipboardData Provides access to predefined clipboard formats for use in editing operations.
document Represents the HTML document in a given browser window.  
event Represents the state of an event, such as the element in which the event occurred, the state of the keyboard keys, the location of the mouse, and the state of the mouse buttons.  
external Allows access to an additional object model provided by host applications of the Microsoft® Internet Explorer browser components.
history Contains information about the URLs visited by the client.
location Contains information about the current URL.  
navigator Contains information about the Web browser.  
screen Contains information about the client's screen and rendering capabilities.  
 
Remarks
 
You can use the window object to retrieve information about the state of the window. You also can use this object to gain access to the document in the window, to the events that occur in the window, and to features of the browser that affect the window.
 
Typically, the browser creates one window object when it opens an HTML document. However, if a document defines one or more frames (that is, contains one or more frame or iframe tags), the browser creates one window object for the original document and one additional window object for each frame. These additional objects are child windows of the original window and can be affected by actions that occur in the original. For example, closing the original window causes all child windows to close. You can also create new windows (and corresponding window objects) using methods such as open, showModalDialog, and showModelessDialog.
 
You can apply any window property, method, or collection to any variable or expression that evaluates to a window object, regardless of how that window was created. Additionally, you can access all window properties, methods, and collections in the current window by using the property, method, or collection name directly?that is, without prefixing it with an expression that evaluates to the current window object. However, to help make more readable code and to avoid potential ambiguities, many authors use the window keyword when accessing window properties, methods, and collections for the current window. This keyword always refers to the current window.
 
Note   : The window's properties, methods, and collection names are reserved keywords and cannot be used as the names of variables or routines.
The following table lists pertinent information for some of the properties of the window object.
 
Property Method Description
opener open The opener property is available only from a page opened using the window.open method.
parent, top None The parent and top properties are available for a window opened inside a frame or iframe. The two properties return the topmost parent and immediate parent, respectively.
parent, top open The parent and top properties are available for a window opened via the open method or as a dialog and returns the current window.
length None Regardless of how the window is opened, the length property returns the number of frames in a window.
dialogArguments, dialogHeight, dialogLeft, dialogTop, dialogWidth, returnValue showModalDialog and showModelessDialog These properties are available only for windows created using the two methods listed?showModalDialog and showModelessDialog
 

This object is available in script as of Internet Explorer 3.0.
 
Examples
 
This example displays an alert for the current window.
 
alert("A simple message.")
This example checks whether the current window contains child windows and, if it does, displays the names of those child windows.
 
if ( window.frames != null ) {
      for ( i = 0; i< window.frames.length; i++ )
            window.alert ("Child window " +i+ " is named "+window.frames(i).name);
}
This example shows a simple event handler function for the window's onload event. In the absence of a "window" element, the body element hosts the following window object events: onblur, onbeforeunload, onfocus, onload, and onunload.
 
&lt;BODY onload="window.status='Page is loaded!'">
Questiongetting rid of  &Nbsp's [modified] PinmemberBrianCampbellMCAD11-Feb-13 3:52 
AnswerRe: getting rid of  &Nbsp's PinmemberBrianCampbellMCAD11-Feb-13 8:17 
QuestionCreate Appointment in yahoo calendar using API Pinmembersrinivasan.p.t29-Jan-13 3:08 
AnswerRe: Create Appointment in yahoo calendar using API Pinmemberryanb314-Feb-13 8:52 
QuestionJava Script is not working in Chrome PinmemberFlex_Query29-Jan-13 2:17 
QuestionRe: Java Script is not working in Chrome Pinmemberryanb314-Feb-13 8:52 
AnswerRe: Java Script is not working in Chrome PinmemberBrisingr Aerowing10-Mar-13 10:19 
QuestionPosting a message from diffrent domain PinmemberAghaKhan28-Jan-13 22:01 
GeneralRe: Posting a message from diffrent domain PinmemberPrasad Khandekar13-Mar-13 23:58 
QuestionProject Help Please Pinmemberjmallen25-Jan-13 4:53 
AnswerRe: Project Help Please Pinmembersarinya_chalat3-Feb-13 16:17 
AnswerMessage Automatically Removed PinmemberMember 822740423-Jan-13 1:30 
Questionproject question Pinmemberjacklyne16-Jan-13 20:04 
AnswerRe: project question PinmvpRichard MacCutchan16-Jan-13 23:45 
GeneralRe: project question PinmemberAnalogNerd17-Jan-13 5:21 
AnswerRe: project question PinmemberJ4amieC17-Jan-13 0:09 
QuestionAbout mobile web debugger Pinmembertidelgl13-Jan-13 19:18 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.


Advertise | Privacy | Mobile
Web03 | 2.8.141022.2 | Last Updated 22 Oct 2014
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid