Skip to content
Related Articles

Related Articles

Improve Article
Save Article
Like Article

HTML | DOM Storage key() Method

  • Last Updated : 30 Jan, 2019

The DOM Storage key() Method is related to the Storage object and is used to return the name of the key with the specified index. Storage object can be either a localStorage or sessionStorage Object.


  • Local storage:
  • Session storage:

    Parameters: It accepts a parameter i.e. index to get the name of the key with that particular given index.

    Return Values: It returns the name of the key in the form of the string.

    Below is the HTML code to show the working of HTML DOM Storage key() Object:

    <!DOCTYPE html>
            HTML DOM Storage key() Method
        <!-- Script to get the name of the key -->
            function myGeeks() {
                var key = localStorage.key(0);
                  "geeks").innerHTML = key;
        <h2>DOM Storage key() Method</h2>
        <button onclick="myGeeks()">
        <p id="geeks"></p>


    • Before Click:
    • After Click:

    Supported Browsers: The browser supported by DOM Storage key() Method are listed below:

    • Google Chrome 4
    • Internet Explorer 8
    • Firefox 3.5
    • Opera 10.5
    • Safari 4

    My Personal Notes arrow_drop_up
Recommended Articles
Page :

Start Your Coding Journey Now!