Share this Page URL

Chapter 7. Client-Side Browser Syntax > Event.ABORT - Pg. 555

Client-Side Browser Syntax </body> </html> 555 Event.ABORT JavaScript 1.0+, JScript 1.0+ Nav2+, IE 3+, Opera3+ Syntax Event.ABORT Description The ABORT property of the Event object is used by images and refers to the event in which a transfer is interrupted or aborted by a user. Example Listing 7.217 shows an example in which an HTML document may have a large .gif file embedded within it, but, during the document loading process, the loading of the .gif file is aborted (by clicking the Stop button in the browser). The captureEvents() method catches the ABORT event and passes it to the handleAbort(), method which handles it accordingly. Example 7.217. Listing 7.217 Using the ABORT Event Property <html> <head> <title>Example of Event.ABORT</title> </head> <body> <script language = "JavaScript"> <!--Hide // sets up the window to capture ABORT events document.captureEvents(Event.ABORT); // function that handles the specific event. The evnt parameter refers to // the event object. In this case the function is handling any type of ABORT events. function handleAbort(evnt){ alert("An ABORT event has occurred."); return true; } // This registers the handle function as the event handler for the // ABORT event. document.onAbort = handleAbort; // End Hide ---> </script> This page loads the sample.gif image. Assuming this is a large image and takes some time to load, if the user clicks the stop button on the browser, an <b>abort</b> event will be captured. <br><br><br> <img src="sample.gif" width="350" height="500" onAbort=''> </body> </html>