Một số người nghĩ rằng cửa sổ pop-up quảng cáo vốn đã ác, và một số nghĩ rằng họ đang sử dụng hợp pháp của công nghệ Web. Bất cứ nơi nào bạn rơi vào cuộc tranh luận, ý thức được rằng cửa sổ pop-up phần mềm diệt tồn tại, một số người lướt tải về và cài đặt để tránh nhìn thấy cửa sổ pop-up quảng cáo | Chapter 13 Handling User-Initiated Events 247 Using window events for good not evil Some folks think pop-up ads are inherently evil and some think they re a legitimate use of Web technology. Wherever you fall in the debate be aware that pop-up-killer software exists which some surfers download and install to avoid seeing pop-up ads. Know too that many surfers refuse to revisit sites which bombard them with pop-up ads. Keyboard events Keyboard-related events occur when a user presses a key while a Web page is loaded. In addition to capturing the overall keyPress event you can separately capture and respond to the user s pressing the key and then releasing the key. The following sample code ties a custom JavaScript function named disallowInputt to the onKeyPress event handler associated with the d ocument object BODY onKeyPress disallowInput For details on the other objects that support keyboard events check out Table 13-5. Table 13-5 Keyboard-Related Event Handlers Event Handler Supporting Objects Event Event Handler Triggered When. onKeyDown Button Checkbox document FileUpload Image Link Password Radio Reset Select Submit Text Textarea The user presses a key. onKeyPress Button Checkbox document FileUpload Image Link Password Radio Reset Select Submit Text Textarea The user presses and releases a key which combines the onKeyDown and onKeyUp event handlers . onKeyUp Button Checkbox document FileUpload Image Link Password Radio Reset Select Submit Text Textarea The user releases a previously pressed key. 248 Part IV Interacting with Users_ Chapter 14 Handling Runtime Errors Jn This Chapter Getting familiar with runtime errors and exceptions Taking a peek at the try catch and throw statements upport for exception handling a technique for anticipating and recovering gracefully from errors that has long been supported in languages like C was finally implemented for JavaScript in Internet Explorer and Navigator . .