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.

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

newWind.document.write(output)<br />

newWind.document.close()<br />

}<br />

// close subwindow, including ugly workaround for IE3<br />

function closeWindow() {<br />

if (isIE3) {<br />

// if window is already open, nothing appears to happen<br />

// but if not, the subwindow flashes momentarily (yech!)<br />

newWind = window.open(“”,”subwindow”,”HEIGHT=200,WIDTH=200”)<br />

}<br />

if (newWind && !newWind.closed) {<br />

newWind.close()<br />

}<br />

}<br />

<br />

<br />

<br />

<br />

<br />

<br />

<br />

<br />

<br />

To complete the example of the window opening and closing, notice that the subwindow<br />

is given a button whose onClick event handler closes the main window. In<br />

Navigator 2 and Internet Explorer 3, this occurs without complaint. But in NN3+ and<br />

IE4+, the user is presented with an alert asking to confirm the closure of the main<br />

browser window.<br />

defaultStatus<br />

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

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

Example<br />

Unless you plan to change the default statusbar text while a user spends time at<br />

your Web page, the best time to set the property is when the document loads. In<br />

Listing 16-5, notice how I also read this property to reset the statusbar in an<br />

onMouseOut event handler. Setting the status property to empty also resets the<br />

statusbar to the defaultStatus setting.<br />

131<br />

windowObject.defaultStatus

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

Saved successfully!

Ooh no, something went wrong!