Movatterモバイル変換


[0]ホーム

URL:


  1. Web
  2. Web APIs
  3. WindowSharedStorage

WindowSharedStorage

Deprecated: This feature is no longer recommended. Though some browsers might still support it, it may have already been removed from the relevant web standards, may be in the process of being dropped, or may only be kept for compatibility purposes. Avoid using it, and update existing code if possible; see thecompatibility table at the bottom of this page to guide your decision. Be aware that this feature may cease to work at any time.

TheWindowSharedStorage interface of theShared Storage API represents the shared storage for a particular origin within a standard browsing context.

WindowSharedStorage is accessed viaWindow.sharedStorage.

Instance properties

workletDeprecated

Contains theSharedStorageWorklet instance representing the shared storage worklet for the current origin.SharedStorageWorklet includes theaddModule() method, which is used to add a module to the shared storage worklet.

Instance methods

WindowSharedStorage inherits properties from its parent interface,SharedStorage.

run()Deprecated

Executes aRun output gate operation that has been registered in a module added to theSharedStorageWorklet of the current origin.

selectURL()Deprecated

Executes aURL Selection output gate operation that has been registered in a module added to theSharedStorageWorklet of the current origin.

Examples

js
// Randomly assigns a user to a group 0 or 1function getExperimentGroup() {  return Math.round(Math.random());}async function injectContent() {  // Add the module to the shared storage worklet  await window.sharedStorage.worklet.addModule("ab-testing-worklet.js");  // Assign user to a random group (0 or 1) and store it in shared storage  window.sharedStorage.set("ab-testing-group", getExperimentGroup(), {    ignoreIfPresent: true,  });  // Run the URL selection operation  const fencedFrameConfig = await window.sharedStorage.selectURL(    "ab-testing",    [      { url: `https://your-server.example/content/default-content.html` },      { url: `https://your-server.example/content/experiment-content-a.html` },    ],    {      resolveToConfig: true,    },  );  // Render the chosen URL into a fenced frame  document.getElementById("content-slot").config = fencedFrameConfig;}injectContent();

See theShared Storage API landing page for a walkthrough of this example and links to other examples.

Specifications

This feature does not appear to be defined in any specification.

Browser compatibility

See also

Help improve MDN

Learn how to contribute

This page was last modified on byMDN contributors.


[8]ページ先頭

©2009-2026 Movatter.jp