# Re-open cookie-consent modal via js

**URL:** <https://support.iubenda.com/t/re-open-cookie-consent-modal-via-js/3985>\
**Category:** Feature requests\
**Created:** [March 17, 2021, 5:05pm UTC](https://support.iubenda.com/t/re-open-cookie-consent-modal-via-js/3985 "2021-03-17T17:05:57Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![s2\_user](https://avatars.discourse-cdn.com/v4/letter/s/7ab992/32.png) [@s2\_user](https://support.iubenda.com/u/s2_user)\
**Post date:** [March 17, 2021, 5:05pm UTC](https://support.iubenda.com/t/re-open-cookie-consent-modal-via-js/3985/1 "2021-03-17T17:05:57Z")

</div>

Hello,

as a frontend-developer, I want to re-open the cookie-policy with a link via javascript.

Currently I have create a link like \<a href="#" class="iubenda-cs-preferences-link" \>Cookies\</a\>. But this way, I suffer under the behavior, that only the first of such links does work. On our page, we use different footers (on different pages), where this link is included; and only the first does work; the 2nd one only works after a reload.

The class usage is like documented in the [documentation](https://www.iubenda.com/de/help/4802-cookie-solution-anpassen-erweiterte-anleitung#api) (german version).

I would like to have a JS-API-function like #showCP() or that a your class-name based solutions also works on links, loaded afterwards.

Feel welcome to forward this message or provide a different solution.

* * *

_Importato da [support.iubenda.com](http://support.iubenda.com) (topic #42000271990) · 👍 3 upvote su Freshdesk · 👁 1719 visualizzazioni_

---

<div class="post-metadata">

**Author:** ![s2\_user](https://avatars.discourse-cdn.com/v4/letter/s/7ab992/32.png) [@s2\_user](https://support.iubenda.com/u/s2_user)\
**Post date:** [March 22, 2021, 10:46am UTC](https://support.iubenda.com/t/re-open-cookie-consent-modal-via-js/3985/2 "2021-03-22T10:46:42Z")

</div>

sorry for **bouncing** this topic; this is a serious request and we need a solution for it from you.

---

<div class="post-metadata">

**Author:** ![wliam9514](https://avatars.discourse-cdn.com/v4/letter/w/5f9b8f/32.png) [@wliam9514](https://support.iubenda.com/u/wliam9514)\
**Post date:** [April 10, 2021, 1:10pm UTC](https://support.iubenda.com/t/re-open-cookie-consent-modal-via-js/3985/3 "2021-04-10T13:10:00Z")

</div>

Oh, same problem i m facing.

---

<div class="post-metadata">

**Author:** ![arikrhnn](https://avatars.discourse-cdn.com/v4/letter/a/779978/32.png) [@arikrhnn](https://support.iubenda.com/u/arikrhnn)\
**Post date:** [February 7, 2023, 3:12pm UTC](https://support.iubenda.com/t/re-open-cookie-consent-modal-via-js/3985/4 "2023-02-07T15:12:47Z")

</div>

I've installed the Iubenda Consent Solution JS SDK, and it appears to work. Once a user indicates their consent by scrolling or dismissing the notice, the banner goes away and, presumably, the consent is stored in the Iubenda system.[&nbsp;](https://2023-new-bmw-x8.blogspot.com/)[&nbsp;](https://2023cars.blogspot.com/)[&nbsp;](https://2023golfandpolo.blogspot.com/)[&nbsp;](https://autumnflowerss.blogspot.com/)[&nbsp;](https://bmwix1xdrive30.blogspot.com/)[&nbsp;](https://2023modelbmwm2.blogspot.com/)[&nbsp;](https://cadillac-lyriq.blogspot.com/)[&nbsp;](https://fallflowerss.blogspot.com/)

Once the consent is recorded, one must be able to retrieve it and Iubenda says this can be done using either the HTTP API or by JavaScript, however these methods are not well documented.

How can I use JavaScript to retrieve the consent?

&nbsp;

---

<div class="post-metadata">

**Author:** ![ludovico.grossi](https://avatars.discourse-cdn.com/v4/letter/l/8797f3/32.png) [@ludovico.grossi](https://support.iubenda.com/u/ludovico.grossi)\
**Post date:** [May 29, 2024, 10:59am UTC](https://support.iubenda.com/t/re-open-cookie-consent-modal-via-js/3985/5 "2024-05-29T10:59:59Z")

</div>

I'm not part of the Iubenda team but I have similar problems and these are the solutions I found so far  
  
  
**To open the generic dialog (requires the link in the page)**

```
document.querySelector('.iubenda-cs-preferences-link').click();
```

&nbsp;

**To open only the TCF panel**

```
_iub.cs.openAdvertisingPreferences()
```

&nbsp;

**To retrieve the GDPR consent**  
use the iubenda callbacks in the configuration

```
callback: {
    onPreferenceExpressedOrNotNeeded: function(preferences) {
        console.log(preference);
    }
}
```

&nbsp;

**To retrieve the TCF consents**  
use the \_\_tcfApi&nbsp;

```
__tcfapi(‘getTCData’, 2, function(tcdata, success) {
console.log(tcdata);
}
```

&nbsp;&nbsp;

Waiting for the support team to confirm, and more solid and documented methods to do this
