• Skip to main content
  • Skip to search
  • Skip to select language
MDN Web Docs
  • References
    • Overview / Web Technology

      Web technology reference for developers

    • HTML

      Structure of content on the web

    • CSS

      Code used to describe document style

    • JavaScript

      General-purpose scripting language

    • HTTP

      Protocol for transmitting web resources

    • Web APIs

      Interfaces for building web applications

    • Web Extensions

      Developing extensions for web browsers

    • Accessibility

      Build web projects usable for all

    • Web Technology

      Web technology reference for developers

  • Learn
    • Overview / MDN Learning Area

      Learn web development

    • MDN Learning Area

      Learn web development

    • HTML

      Learn to structure web content with HTML

    • CSS

      Learn to style content using CSS

    • JavaScript

      Learn to run scripts in the browser

    • Accessibility

      Learn to make the web accessible to all

  • Plus
    • Overview

      A customized MDN experience

    • AI Help

      Get real-time assistance and support

    • Updates

      All browser compatibility updates at a glance

    • Documentation

      Learn how to use MDN Plus

    • FAQ

      Frequently asked questions about MDN Plus

  • Curriculum New
  • Blog
    • Playground

      Write, test and share your code

    • HTTP Observatory

      Scan a website for free

    • AI Help

      Get real-time assistance and support

  • Log in
  • Sign up for free
  1. References
  2. Web APIs
  3. Storage Access API
  4. Using the Storage Access API
    • Deutsch
    • 日本語

In this article

  • Usage notes
  • Allowing a sandboxed

Checking and requesting storage access

Now on to the code executed inside the embedded document. In this code:

  1. We first use feature detection (if (document.hasStorageAccess) {}) to check whether the API is supported. If not, we run our code that accesses cookies anyway, and hope that it works. It should be coded defensively to deal with such eventualities anyway.
  2. If the API is supported, we call document.hasStorageAccess().
  3. If that call returns true, it means this \n"}},{"type":"prose","value":{"id":"checking_and_requesting_storage_access","title":"Checking and requesting storage access","isH3":false,"content":"

    Now on to the code executed inside the embedded document. In this code:\n

      \n
    1. We first use feature detection (if (document.hasStorageAccess) {}) to check whether the API is supported. If not, we run our code that accesses cookies anyway, and hope that it works. It should be coded defensively to deal with such eventualities anyway.\n
    2. If the API is supported, we call document.hasStorageAccess().\n
    3. If that call returns true, it means this