Source code
Revision control
Copy as Markdown
Other Tools
<!DOCTYPE HTML>
<html>
    <head>
        <title> W3C DOM Level 3 Event: error </title>
        <script type="text/javascript">
            var PassTest = function()
            {
                document.getElementById("testresult").firstChild.data = "PASS";
            }
            var FailTest = function()
            {
                document.getElementById("testresult").firstChild.data = "FAIL";
            }
            function TestCapture(evt)
            {
                TARGET = document.getElementById("target");
                if ((evt.type == EVENT) && (evt.currentTarget == window) && (evt.target == TARGET))
                {
                    TestResult = true;
                }
                else
                {
                    TestResult = false;
                }
            }
            var EVENT = "error";
            var TARGET;
            var TestResult = false;
            try
            {
                window.addEventListener(EVENT, TestCapture, true);
            }
            catch(ex)
            {
                TestResult = false;
            }
            window.onload = function()
            {
                if (true == TestResult)
                {
                    PassTest();
                }
                else
                {
                    FailTest();
                }
            }
        </script>
    </head>
    <body>
        <h4>Test Description: error event fires when an IMG resource failed to load.</h4>
        <img id="target" src="./support/InvalidBitMap.png" alt="ERROR">
        <p>Test passes if the word "PASS" appears below.</p>
           <div>Test result: </div>
        <div id='testresult'>FAIL</div>
    </body>
</html>