tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

Event.defaultPrevented.html (2100B)


      1 <!DOCTYPE html>
      2 <html>
      3    <head>
      4        <title> W3C DOM Level 3 Event Object Property: defaultPrevented </title>
      5        <script type="text/javascript">
      6            var PassTest = function()
      7            {
      8                document.getElementById("testresult").firstChild.data = "PASS";
      9            }
     10 
     11            var FailTest = function()
     12            {
     13                document.getElementById("testresult").firstChild.data = "FAIL";
     14            }
     15 
     16            var EVENT = "click";
     17            var TARGET;
     18 
     19            window.onload = function()
     20            {
     21                try
     22                {
     23                    TARGET = document.getElementById("target");
     24                    TARGET.addEventListener(EVENT, TestCapture, true);
     25                }
     26                catch(ex)
     27                {
     28                    FailTest();
     29                }
     30            }
     31 
     32            function TestCapture(evt)
     33            {
     34                try
     35                {
     36                    evt.preventDefault();
     37 
     38                    if ((evt.type == EVENT) && (evt.defaultPrevented == true))
     39                    {
     40                        PassTest();
     41                    }
     42                    else
     43                    {
     44                        FailTest();
     45                    }
     46                }
     47                catch(ex)
     48                {
     49                    FailTest();
     50                }
     51            }
     52        </script>
     53    </head>
     54    <body>
     55        <h4>
     56            Test Description:
     57            Event listeners can cancel default actions of cancelable event objects by invoking the Event.preventDefault()
     58            method, and determine whether an event has been canceled through the Event.defaultPrevented attribute.
     59        </h4>
     60 
     61        Click the hyperlink:
     62        <a href="http://samples.msdn.microsoft.com/ietestcenter/" id="target">http://samples.msdn.microsoft.com/ietestcenter</a>
     63 
     64        <p>Test passes if the word "PASS" appears below after clicking the hyperlink and the page does not navigate away.</p>
     65           <div>Test result: </div>
     66        <div id='testresult'>FAIL</div>
     67    </body>
     68 </html>