L
LLLOS.ai
Learn
L

Ask Your Tutor

What are some common BOM methods besides alert and open?

General knowledge Asked by Anonymous from Dallas, United States 24 Oct 2026, 11:20 AM IST Updated

In one line

Common BOM methods are commands in JavaScript that let you interact with the browser window, like showing messages, getting user input, or moving the window.

The rule

BOM (Browser Object Model) methods are functions provided by the browser to control or interact with the browser window and its parts, like dialogs, size, and navigation.

Some common BOM methods:

  • alert() — shows a simple message box.
  • open() — opens a new browser window or tab.
  • confirm() — asks the user to confirm (OK/Cancel).
  • prompt() — asks the user to enter some text.
  • close() — closes the current window (if opened by script).
  • setTimeout() — runs code after a set time.
  • setInterval() — runs code again and again at set intervals.
  • window.print() — opens the print dialog.

Let's understand it simply

Imagine your browser window is like a shop. BOM methods are like the shopkeeper's tools. For example, alert() is like the shopkeeper making an announcement. prompt() is like the shopkeeper asking you to write your name on a slip. confirm() is like the shopkeeper asking, "Are you sure you want to buy this?"

Common BOM Methods
MethodWhat it doesExample use
alert()Shows a message boxWarning: Wrong password
prompt()Asks for user inputEnter your name
confirm()Asks for OK/CancelAre you sure you want to leave?
open()Opens new window/tabShow help page
close()Closes window opened by scriptClose popup
setTimeout()Runs code after delayShow message after 5 sec
setInterval()Runs code repeatedlyUpdate clock every sec
window.print()Opens print dialogPrint ticket

How it works

  1. You write JavaScript code using a BOM method, like prompt().
  2. The browser sees this and shows a dialog box to the user.
  3. The user responds (types something, clicks OK/Cancel).
  4. The browser gives the answer back to your code.
  5. Your code can use this answer to do something next.

Where you see it in real life

  • Filling a form online → prompt() can ask for your name.
  • Confirming before leaving a page → confirm() asks if you want to leave without saving.
  • Showing a warning message → alert() pops up to say, "Password is wrong!"
  • Printing a ticket → window.print() opens the print dialog for your train ticket.
  • Auto-logout after 5 minutes → setTimeout() logs you out after some time.

Why it matters

  • Makes websites interactive and user-friendly.
  • Helps in getting user input or confirmations.
  • Useful for reminders, warnings, or auto-actions.
  • Used in many online forms, banking sites, and shopping carts.

Common mistakes

  • Mixing up alert(), prompt(), and confirm() — each has a different use.
  • Forgetting that close() only works on windows opened by script, not the main tab.
  • Using too many pop-ups — can annoy users and get blocked by browsers.

Remember it

Think: BOM methods are the browser's way to talk to you — to show, ask, or confirm things.

Check yourself

What does prompt() do?

It asks the user to enter some text and gives that text back to your code.

Why might using too many alert() pop-ups be a problem?

They can annoy users and may get blocked by the browser.

Which BOM method would you use to print a page?

window.print(), because it opens the print dialog.

Why does close() not work on the main browser tab?

For safety, browsers only allow close() on windows opened by script, not the main tab.

Quick recap

  • BOM methods let JavaScript interact with the browser window.
  • alert(), prompt(), and confirm() show dialogs to the user.
  • setTimeout() and setInterval() control timing of actions.
  • open() and close() handle browser windows or tabs.
  • window.print() opens the print dialog.
Written by the LLOS.ai tutor. Asked by Anonymous from Dallas, United States on 24 Oct 2026, 11:20 AM IST