window // represents the browser window or tab
document // represents the HTML document loaded in the window (DOM)
navigator // provides information about the browser
location // represents the URL of the current page
history // represents the browser's session history
The Browser Object Model represents objects provided by the browser to work with.
navigator.cookieEnabled // boolean indicates whether cookes are enabled or not
navigator.userAgent // returns user agent header string for current browser
navigator.language // returns language being used by browser
navigator.onLine // returns true if online
Object that contains information about the user's browser.
history.back() // same as clicking back in the browser
history.forward() // same as clicking forward in the browser
history.go(n) // go to a specific position in the history stack n (positive or negative integer)
history.pushState(state, title, URL) // adds an entry to the browser's session history stack
history.replaceState(state, title, URL) // modifies the current history entry with a new state and URL
History object contains the browser's history stack.
window.innerHeight // returns the interior height of the window in pixels including height of scrollbar
window.innerWidth // returns interior width of the window in pixels, includes width of vertical scroll bar
window.open(url, target, features) // opens a new window with specified URL, target, and features
window.close() // closes current window
window.moveTo(x, y) // moves the current window to the specified coordinates
window.resizeTo(width, height) // dynamically resizes the window
window.scrollTo({top: 0, behavior: "smooth"}) // scrolls to a position on the document
Some window methods and properties.
location.href // returns current URL, also can be used to modify it
location.hostname // returns the domain name of the web host
location.pathname // returns the path and filename of current page
location.protocol // represents protocol scheme or URL, http: or https:
location.port // returns the number of the internet host port
location.assign() // methods causes the window to load and display the document at URL specified
Represents the location (URL) of the object it is linked to.
screen.width // returns the width of the screen in pixels
screen.height // returns the height of the screen in pixels
screen.availWidth // returns the amount of width available
screen.availHeight // returns the amount of height available
screen.colorDepth // returns the color depth of the screen
screen.pixelDepth // returns the pixel depth of the screen
Represents a screen, usually the one on which the current window is being rendered.
alert(msg) // displays an alert dialog box with message
confirm(msg) // displays a dialog to confirm or cancel, returns boolean
prompt(msg, defaultText) // display a dialog prompting user to input some text, returns input
open(url, target, features) opens a new browser window or tab
close() // closes the current browser window or tab
setTimeout(function, delay) // executes a function after a delay
clearTimeout(timeoutID) // to cancel a timeout function before it executes
setInterval(function, delay) // to repeatedly call a function with a specified delay
clearInterval(intervalID) // to cancel the repeated execution of the interval function
Methods that are from and work with the browser.