Javascript Reference - HTML DOM Keygen type Property

The read only type property returns the type string of a keygen field.

Browser Support

The type property is supported in all major browsers, except Internet Explorer.

type Yes Yes Yes Yes Yes



Return Value

A String type value representing the type string of the keygen field.


The following code shows how to get the type of the keygen field.

<!DOCTYPE html>
Encryption: <keygen id="myKeygen" name="security">
<button onclick="myFunction()">test</button>
<p id="demo"></p>
<!--   w  ww.j av a  2s. co m-->
function myFunction() {
    var x = document.getElementById("myKeygen").type;
    document.getElementById("demo").innerHTML = x;


The code above is rendered as follows: