15.02.2013 Views

JavaScript Examples Bible - UserWorks Technologies

JavaScript Examples Bible - UserWorks Technologies

JavaScript Examples Bible - UserWorks Technologies

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

Methods<br />

alert(“message”)<br />

Chapter 2 ✦ Window and Frame Objects (Chapter 16)<br />

NN2 NN3 NN4 NN6 IE3/J1 IE3/J2 IE4 IE5 IE5.5<br />

Compatibility ✓ ✓ ✓ ✓ ✓ ✓ ✓ ✓ ✓<br />

Example<br />

The parameter for the example in Listing 16-20 is a concatenated string. It joins<br />

together two fixed strings and the value of the browser’s navigator.appName property.<br />

Loading this document causes the alert dialog box to appear, as shown in several<br />

configurations in Figure 2-5. The <strong>JavaScript</strong> Alert: line cannot be deleted from<br />

the dialog box in earlier browsers, nor can the title bar be changed in later browsers.<br />

Listing 16-20: Displaying an Alert Dialog Box<br />

<br />

<br />

window.alert() Method<br />

<br />

<br />

<br />

alert(“You are running the “ + navigator.appName + “ browser.”)<br />

<br />

<br />

<br />

Figure 2-5: Results of the alert() method in Listing 16-20<br />

in Internet Explorer 5 (top) and Navigator 6 (bottom)<br />

for Windows 98<br />

153<br />

windowObject.alert()

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!