mozilla
Your Search Results

    Window.onblur

    Summary

    The onblur property can be used to set the blur handler on the window, which is triggered when the window loses focus.

    Syntax

    window.onblur = funcRef;
    
    • funcRef is a reference to the function to be executed.

    Example

    <!DOCTYPE html>
    <html lang="en">
    <head>
    <meta charset="UTF-8" />
    <title>onblur test</title>
    
    <script>
    window.onblur = blurText;
    
    function blurText() {
      alert("blur event detected!");
      // remove the event to stop an infinite loop!
      window.onblur = '';
    }
    </script>
    
    </head>
    <body>
    <p>click on another window
    to fire the blur event for this browser window</p>
    </body>
    </html>
    

    Specification

    DOM Level 0. Not part of any standard.

    Document Tags and Contributors

    Last updated by: fscholz,
    Hide Sidebar