Browse Source

Open the cookie manager with a class name on a link

Bonne idée 👍 https://github.com/AmauriC/tarteaucitron.js/issues/59

Pour faciliter les choses, c'est possible en ajoutant une class à un lien :
`<a href="https://www.monsite.fr/mapage_cookie/" class="tarteaucitronOpenPanel">Cookies</a>`
Amauri CHAMPEAUX 7 years ago
parent
commit
94319d0646
1 changed files with 4 additions and 2 deletions
  1. 4 2
      tarteaucitron.js

+ 4 - 2
tarteaucitron.js

@@ -33,8 +33,9 @@ var tarteaucitron = {
                 window.addEventListener("load", function () {
                     tarteaucitron.load();
                     tarteaucitron.fallback(['tarteaucitronOpenPanel'], function (elem) {
-                        elem.addEventListener("click", function () {
+                        elem.addEventListener("click", function (event) {
                             tarteaucitron.userInterface.openPanel();
+                            event.preventDefault();
                         }, false);
                     }, true);
                 }, false);
@@ -87,8 +88,9 @@ var tarteaucitron = {
                 window.attachEvent("onload", function () {
                     tarteaucitron.load();
                     tarteaucitron.fallback(['tarteaucitronOpenPanel'], function (elem) {
-                        elem.attachEvent("onclick", function () {
+                        elem.attachEvent("onclick", function (event) {
                             tarteaucitron.userInterface.openPanel();
+                            event.preventDefault();
                         });
                     }, true);
                 });