HTML | Window name Property

The Window name property is used for setting or returning the name of a window. It is generally used to modify the name of a window which has been created in the past. It returns a string which represents the name of the window.

Syntax:

window.name

Below program illustrates the Window name Property :



Returning the name of a window.

filter_none

edit
close

play_arrow

link
brightness_4
code

<!DOCTYPE html>
<html>
  
<head>
    <title>
      Window name Property in HTML
    </title>
    <style>
        h1 {
            color: green;
        }
          
        h2 {
            font-family: Impact;
        }
          
        body {
            text-align: center;
        }
    </style>
</head>
  
<body>
  
    <h1>GeeksforGeeks</h1>
    <h2>Window name Property</h2>
  
    <p>
      For returning the name of the window,
      double click the "Check Name" button:
    </p>
  
    <button ondblclick="fname()">Check Name</button>
  
    <!--window.open() defines the name of the window -->
    <!-- w.name property print the name of that window -->
    <script>
        function fname() {
            var w = window.open("","My Window",
                       "width=400, height=400");
            w.document.write("The name of the window is : "
                                      + w.name);
        }
    </script>
  
</body>
  
</html>

chevron_right


Output:

After clicking the button

Supported Browsers: the browser supported by HTML | Window name Property are listed below:

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


My Personal Notes arrow_drop_up

I am a technology enthusiast who has a keen interest in programming I am pursuing Engineering in Computer Science from GEU, Dehradun I like to unwind by watching movies and English sitcomsI have a keen interest in music

If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. 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.




Article Tags :
Practice Tags :


Be the First to upvote.


Please write to us at contribute@geeksforgeeks.org to report any issue with the above content.