[JavaScript] Brower Object Model (BOM)

The Browser Object Model (BOM) is the way for JavaScript to interact with the web browser. There are no official standards for BOM, but most browsers support common interfaces.

window Object

There is a global object in every JavaScript host environment. In a web browser, the “window” object is a global object, and you can access it anywhere in the script.

Properties of “window” Object

The “window” object is a starting point when you work with the web pages.

  • document: the web page
  • history: the URLs that have been visited before and after the current page
  • location: the current URL of the browser window. (is used to navigate to another page)
  • navigator: the object about the browser information
  • screen: the screen object

Also, you can get the information about the window.

  • frames[]: an array of the frames
  • name: the name of a window
  • innerHeight, innerWidth: the size of a windows’ content area
  • outerHeight, outerWidth: the size of a windows
  • screenLeft, screenX: x position of the window relative to the screen
  • screenTop, screenY: y position of the window relative to the screen
  • status: the text in the status bar

Window Simple Dialogs

  • alert(msg)
    • displays a message box with an OK button
  • confirm(msg)
    • displays a dialog box with an OK and a Cancel button
  • prompt(msg, defaultText)
    • displays a dialog box that prompts the user for input
var name = prompt('Please enter your name:', 
  'your name here');
if (name) {
  let choice = confirm('Is your name ' + name + '?');
  if (choice) {
  } else {

Leave a Comment

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s