0% found this document useful (0 votes)
14 views

01-06 Window Object

Css notes

Uploaded by

tejasbadgujar238
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
14 views

01-06 Window Object

Css notes

Uploaded by

tejasbadgujar238
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 6

Basics Of JavaScript Programming

 Window Object

Window OBJECT
 In JavaScript, the window object is fundamental part of browser environment.
 It represents the browser window or tab.
 It is the global object in the browser for the code running in the browser.
 All global variables, functions, and objects are the properties of the window object.
 It provides numerous properties, methods and events to interact with the browser and the
webpage.
 Window Object Properties
o Some key properties of the window object include:
Property Name Description
window.document Represents the Document Object Model (DOM) of the
current webpage. Allows interaction with HTML elements.
window.innerWidth The inner dimensions of the browser's window (viewport).
window.innerHeight
window.location Contains information about the current URL. It can be used
to redirect users, get the URL, or manipulate it.
window.history Provides access to the browser’s session history (e.g.,
back, forward navigation)
window.navigator Contains information about the browser environment (e.g.,
user-agent, platform)
window.screen Provides information about the user’s screen (e.g., screen
width, height)

Subject: Java Script Notes Print Date: [20/Oct/24], Page 1 of 6


 Window Object Methods
o Some important methods include:
Method Name Description
window.alert() Displays an alert dialog with a message
window.confirm() Displays a dialog with a message and OK/Cancel options.
Returns true if OK is pressed, false otherwise
window.prompt() Displays a dialog with a text input field. Returns the
inputted text or null if cancelled.
window.open() Opens a new browser window or tab
window.setTimeout() Executes a function after a specified delay (in milliseconds)
window.setInterval() Executes a function repeatedly with a fixed time delay
between each call.

Subject: Java Script Notes Print Date: [20/Oct/24], Page 2 of 6


Subject: Java Script Notes Print Date: [20/Oct/24], Page 3 of 6
Subject: Java Script Notes Print Date: [20/Oct/24], Page 4 of 6
 Window Object Events
o Some key events associated with the window object are:
Event Name Description
load Fires when the page has fully loaded (all resources such
as images, scripts, etc.)
Resize Fires when the window is resized.
scroll Fires when the window is scrolled
beforeunload Fires when the user is about to close or refresh the page.
Can be used to display a warning before leaving the page.

Subject: Java Script Notes Print Date: [20/Oct/24], Page 5 of 6


unload Fires when the page is completely unloaded (used for
cleanup)

Subject: Java Script Notes Print Date: [20/Oct/24], Page 6 of 6

You might also like