Write about window object in Java Script


window object

Window object: The window object represents a window in browser. An object of window is created automatically by the browser.the window object is top level object in client side java script, represent a window or a frame. Since window object is a top level object, it contains other objects like document, history ect,.

Syntax: to open a new window ,use the following syntax:

[window var=[window.]open(“url”,”window name “ ,[window features])

Where window var is a name that you create for a new window.

Window features are height, width,location,resizable,menubar,scroll bar, status bar,and tool bar.

Window object properties:

PROPERTY
DESCRPTION
EXAMPLE
Closed
Returns true if window is closed
myWindow.closed
Status
It is used to get the current status of the browser window
mywindow.status
Default status
It is used to declare the default status of the browser window
mywindow.defaultStatus = "This is the default text in the status bar!!"
Name
It is used to find the name of the browser window
myWindow.name
Length
It returns integer defining the number of frames in the page
var x = mywindow.length;
Locations
It returns the full URL path of the document used as a string
Mywindow.location;
Parent
It is used to identify the parent window object
mywindow.parent
Self
It is returns instance of the current window
mywindow.self
Top
It is used to get the top most browser window in a series of nested windows
mywindow.top

Window object functions:

Method
Description
Example
Alert ()
Method alert (“string”) is used to popup an alert message
Alert (“hai”)
Confirm ()
Method confirm (“string”) is used to display confirm dialogue box
X = confirm (“if you do hard work”)
Prompt box ()
Method prompt (“string”) is used to get user input
Var name = prompt (“enter user name”, “sri”)
Open ()
Method open (URL, Name) is used to open a new window using java script
Window.open(“ “, “Mywindow “, width = 200, height = 100”);
Close ()
It is used to close a window
Mywindow.close();
Scroll (x,y)
It is used to move a window to a new position
Window.scrollTo (300,500);
Blur()
It is used to remove the focus from the window
Mywindow.blur ();
Focus
It is used to bring a window in focus
Mywindow.focus();
Set time out()
It is used to excute an expression or function after a time interval
Myvar=SetTimeOut(function(),3000);
ClearTimeOut()
It is used to clear time out set using the above method
clearTimeOut(myvar);


Related

Web Technology 5385123937396290361

Post a Comment

emo-but-icon

Follow Us

item