JavaScript - hasStorageAccess() method

revision:


Category : document

The hasStorageAccess() method of the Document interface returns a Promise that resolves with a boolean value indicating whether the document has access to unpartitioned cookies.

This method is part of the Storage Access API.

Syntax :

        hasStorageAccess()
    

Parameters: none

Examples:

            <script>
                document.hasStorageAccess().then((hasAccess) => {
                    if (hasAccess) {
                    // storage access has been granted already.
                    } else {
                    // storage access hasn't been granted already;
                    // you may want to call requestStorageAccess().
                    }
                });
            </script>
        

Practical examples

example:

code:
                    
                

example:

code:
                    
                

example:

code: