Javascript | Window Blur() and Window Focus() Method

Window.blur() Method
The blur() method is used to remove focus from the current window. i.e, It send the new open Window to the background.



Parameter: It does not require any parameters.

Return Value: It does not Return any value.

Window.focus() Method
The focus() method is used to focus on the new open window. i.e bringing back the blur window to the foreground.



Parameter: It does not require any parameters.

Return Value: It does not Return any value.

Below example illustrates the window.blur() and window.focus() method in JavaScript:






<!DOCTYPE html>
      window Blur and Focus method
        body {
            text-align: center;
        .gfg {
            font-size: 40px;
            font-weight: bold;
            color: green;
    <div class="gfg">GeeksforGeeks</div>
    <h2>Blur and Focus</h2>
        var Window;
        // Function that open the new Window 
        function windowOpen() {
            Window =
                "_blank", "width=400, height=450");
        // function that Closes the open Window 
        function windowClose() {
        //function that blur the open Window
        function windowBlur() {
        //function that focus on open Window
        function windowFocus() {
    <button onclick="windowOpen()">
      Open GeeksforGeeks
    <button onclick="windowBlur()">
      Blur GeeksforGeeks
    <button onclick="windowFocus()">
      Focus GeeksforGeeks
    <button onclick="windowClose()">
      Close GeeksforGeeks


Output: If click on blur GeeksforGeeks button then page will move to the background and if click on focus GeeksforGeeks button then the geeksforgeeks.oge windows will come to foreground.

Click on the Blur:

Click on the Focus:

Supported Browser: The browser supported by Window Blur() and Window Focus() Method are listed below:

  • Google Chrome
  • Internet Explorer
  • Firefox
  • Opera
  • Safari

My Personal Notes arrow_drop_up

Check out this Author's contributed articles.

If you like GeeksforGeeks and would like to contribute, you can also write an article using or mail your article to See your article appearing on the GeeksforGeeks main page and help other Geeks.

Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.