JavaScript Event _ handler function for keyboard event and HTML event handler

Source: Internet
Author: User

The processing function of the keyboard event

1, KeyDown: When the user presses any key on the keyboard to trigger, if press and hold, will repeatedly trigger.

<script type= "Text/javascript" >    function() {        function () {//  do not need an object to call            alert (' Lee ');}        ;    } </script>

2, KeyPress: When the user presses the character key on the keyboard to trigger, if press and hold, the trigger will be repeated.

<script type= "Text/javascript" >    function() {        function  () {            alert (' Lee ');     </script>

3, KeyUp: When the user presses any key on the keyboard to release the key on the keyboard will be triggered.

<script type= "Text/javascript" >    function() {        function  () {            alert (' Lee ');}        ;     </script>

Second, the processing function of HTML event

1.load: Automatically fires on the window when the page is fully loaded, or fires on the frameset after the frameset has finished loading.

<script type= "Text/javascript" >    function() {         alert (' Lee ');    } </script>

2.unload: When the page is completely unloaded (no, the refresh will be there) automatically triggered on the window, or when the frameset is unloaded and triggered on the frameset.

<script type= "Text/javascript" >    function() {        alert (' Lee ');    } </script>

3.select: Triggered when the user selects one or more characters in a text box (input or textarea) and releases it.

<script type= "Text/javascript" >    function() {        var input = document.getElementsByTagName ("input") [0];        Input.onselect=function() {            alert (' Lee ');        };    } ; </script>

4.change: Triggers when text box (input or textarea) content changes and loses focus

<script type= "Text/javascript" >    function() {        var input = document.getElementsByTagName ("input") [0];        Input.onchange=function() {            alert (' Lee ');        };    } ; </script>

5.focus: Triggers on window and related elements when the page or element receives focus

<script type= "Text/javascript" >    function() {        var input = document.getElementsByTagName ("input") [0];        Input.onfocus=function() {            alert (' Lee ');        };    } ; </script>

6.blur: Triggers on window and related elements when the page or element loses focus.

<script type= "Text/javascript" >    function() {        var input = document.getElementsByTagName ("input") [0];        Input.onblur=function() {            alert (' Lee ');        };    } ; </script>

7.submit: Triggered on the <form> element when the user clicks the Submit button.

<script type= "Text/javascript" >    function() {        var form = document.getElementsByTagName ("form") [0];        Form.onsubmit=function() {            alert (' Lee ');        };    } ; </script>

8.reset: Triggered on the <form> element when the user clicks the reset button.

<script type= "Text/javascript" >    function() {        var form = document.getElementsByTagName ("form") [0];        Form.onreset=function() {            alert (' Lee ');        };    } ; </script>

9.resize: Triggers when the size of the window or frame changes (Firefox executes two times).

<script type= "Text/javascript" >    function() {            alert (' Lee ');    }; </script>

10.scroll: Triggered when the user scrolls an element with a scrollbar (some browsers refresh when the scroll bar moves and the event executes).

<script type= "Text/javascript" >Window.onscroll=function() {alert (' Lee '); };</script>

JavaScript Event _ handler function for keyboard event and HTML event handler

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.