Skip to content
Related Articles

Related Articles

Improve Article
Save Article
Like Article

HTML DOM Keygen name Property

  • Last Updated : 28 Oct, 2021

The keygen name property in HTML DOM is used to set or return the value of the name attribute of the <keygen> element. The name attribute is used to specify the name of the keygen element.

Syntax:

Attention reader! Don’t stop learning now. Get hold of all the important HTML concepts with the Web Design for Beginners | HTML  course.

  • It returns the name property.

    keygenObject.name
  • It sets the name property.



    keygenObject.name = keygenName

Return Values: It returns a string value that represents the name of the keygen element.

Property Value: It contains a string value that specifies the name of the keygen element. 

Example: The below HTML code returns and sets the name of the keygen element.

HTML




<!DOCTYPE html>
<html>
  
<head>
    <style>
        h1 {
            color: green;
        }
  
        body {
            text-align: center;
        }
    </style>
</head>
  
<body>
    <h1>GeeksforGeeks</h1>
  
    <h2>HTML DOM Keygen name Property</h2>
    <br>
  
    <form id="myGeeks">
        Username: <input type="text" 
                         name="uname">
        <br><br> Encryption:
        <keygen id="Geeks" form="myGeeks"
                name="secure" autofocus>
        <input type="submit">
    </form>
    <br>
    <button onclick="display()">Display</button>
    <button onclick="set_name()">Set</button>
  
    <p id="test"></p>
  
  
    <script>
        function display() {
            var d = document.getElementById("Geeks").name;
            alert(
              "The name of the keygen is: " + d);
        }
  
        function set_name() {
            var g = document.getElementById(
                "Geeks").name = "myKeygen";
  
            alert(
                "The name of the Keygen was changed to " + g
            );
        }
    </script>
</body>
  
</html>

Output:

Supported Browsers:

  • Google Chrome
  • Opera
  • Safari
  • Firefox



My Personal Notes arrow_drop_up
Recommended Articles
Page :

Start Your Coding Journey Now!