Translate

Monday, 23 April 2012

JavaScript PopUp Boxes / Windows


JavaScript PopUp Boxes / Windows

What is a PopUp Box/ window?

A PopUp box is a small message box window that appears(pops up) in your browser in response to a certain Event like Page load, button click, form submit, clicked inside a field etc. See JavaScript Eventsfor more.The main types of Javascript popup boxes
  • Alert Box- Give some info to user
  • Prompt Box - Ask user to input some value like name, age etc.
  • Confirm Box- Confirm before proceeding with a request ex- delete a file.
Popup boxes appear differently in different browsers.

PopUp Box as it appears in FireFox

In Mozilla Firefox 5.0, the JavaScript Popup box appears in the center of page. But unlike IE and Chrome, the box does not appear as a separate movable window. you cannot click and drag it across the screen.
JS popup box firefox

JS PopUp Box Appears in Internet Explorer 8

You can click and hold down the mouse key as shown in the screenshot below and drag the popup window across the screen.
javascript popus in internet explorer
Note the Yellow symbol, that is an IE 8 symbol for Alerts.

JavaScript PopUp Box / Window Appears in Google Chrome

alert box in chrome

PopUp Boxes Sytntax

We will deal with practical examples of popup windows in the next lesson, however the general syntax is
command name ("text message");

PopUp Box Message Line Break

If the message is too lengthy, it will be put into the next line, however we can also enter a line break '\n' to manually enter a line break in the popup window message. Example in Lesson on JS Confirm box

No comments: