/ /

Opening the Drawer (Storage Preferences)

Updated 4 months ago

There may be cases where you’d like to open the Storage Preferences Drawer (where users can review or update their consent preferences) without using the Osano cookie widget, for example, if you want to trigger it from a custom button or link.

You can do this programmatically using JavaScript and the methods provided below.

Recommended Method:

The preferred way to open the drawer is with the Osano.cm.showDrawer() method:

  Osano.cm.showDrawer('osano-cm-dom-info-dialog-open');

Note: You can call this method from any event handler, such as a button click or custom link.

Example: HTML

  <a href="#" onclick="Osano.cm.showDrawer('osano-cm-dom-info-dialog-open')">
    Cookie Preferences
  </a>

Example: React

  <a onClick={() => Osano.cm.showDrawer('osano-cm-dom-info-dialog-open')}>
    Cookie Preferences
  </a>

Alternative Syntax

In some environments, you may need to reference the global window object directly:

  window.Osano.cm.showDrawer('osano-cm-dom-info-dialog-open');

Example: Vue

  @click="window.Osano.cm.showDrawer('osano-cm-dom-info-dialog-open')"

Deprecated Method:

The following legacy method has been deprecated and should no longer be used:

Osano.cm.emit("osano-cm-dom-info-dialog-open");

Please use Osano.cm.showDrawer() instead for all new implementations.


Note: If the drawer doesn’t open as expected, make sure the Osano script has fully loaded before calling the showDrawer() method. Calling it too early (before initialization) can prevent the drawer from displaying.

Was this article helpful?
Subscribe to receive updates on this article