• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

Adding Cookie JS to index.html

New Here ,
Mar 30, 2021 Mar 30, 2021

Copy link to clipboard

Copied

I'm having a little trouble adding a JS Cookie to the index.html built with Captivate. Quite frankly, it shouldn't be that difficult considering it's nothing more than <script> content and a file. What happens is that after I've inserted the code, the Cookie container flashes and then the Captivate slider appears but nowhere to be seen is the Cookie container, even though the code is present. However, if I was to load the scripts in a separate web file (as a tester), no problem! I can see and interact with the Cookie prompt.

 

Within the <body>:

<script type="text/javascript">
document.addEventListener('DOMContentLoaded', function () {
cookieconsent.run({"notice_banner_type":"standalone","consent_type":"express","palette":"light","language":"en","website_name":"webname","change_preferences_selector":"#changePreferences","cookies_policy_url":"https://www.fluhah.com/corporate/en/legal/privacy.html"});
});
</script>

 

Loader:

var lJSFiles = [ 'assets/js/jquery-3.3.1.min.js','assets/js/CPM.js','assets/js/cookie-consent.js'];

 

cookie-consent.js (attached as .txt)

 

There are no errors in the console displaying when attempting to make this work. I just can't get the Cookie consent container to appear after the slider loads.

 

Thank you for your assistance!

 

 

TOPICS
Editing

Views

409

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

People's Champ , Mar 31, 2021 Mar 31, 2021

Just put this in the head of the html, don't add the js file to the loader section:

 

<script type="text/javascript" src="assets/js/cookie-consent.js"></script>
<script>
window.addEventListener( 'moduleReadyEvent', function( e )
{

cookieconsent.run({"notice_banner_type":"standalone","consent_type":"express","palette":"light","language":"en","website_name":"webname","change_preferences_selector":"#changePreferences","cookies_policy_url":"https://www.fluhah.com/corporate/en/legal/privacy.html"});
});
<

...

Votes

Translate

Translate
Participant ,
Mar 30, 2021 Mar 30, 2021

Copy link to clipboard

Copied

Try (with spaces)

 

var lJSFiles = [ @JSFILES_ARRAY , 'assets/js/jquery-3.3.1.min.js' , 'assets/js/CPM.js' , 'assets/js/cookie-consent.js' ];

 

 

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Mar 30, 2021 Mar 30, 2021

Copy link to clipboard

Copied

The fact that the code loads isn't the problem. The problem is that the Cookie container flashes prior to the Captivate object being visible. After the page loads, the Cookie prompt disappears when it shouldn't and the Captivate is visible. Not the type of functionality expected.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
People's Champ ,
Mar 31, 2021 Mar 31, 2021

Copy link to clipboard

Copied

Just put this in the head of the html, don't add the js file to the loader section:

 

<script type="text/javascript" src="assets/js/cookie-consent.js"></script>
<script>
window.addEventListener( 'moduleReadyEvent', function( e )
{

cookieconsent.run({"notice_banner_type":"standalone","consent_type":"express","palette":"light","language":"en","website_name":"webname","change_preferences_selector":"#changePreferences","cookies_policy_url":"https://www.fluhah.com/corporate/en/legal/privacy.html"});
});
</script>

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Mar 31, 2021 Mar 31, 2021

Copy link to clipboard

Copied

LATEST

Thank you, TLCMediaDesign!

This seems to have fixed the problem!

 

It's awesomely working!

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Resources
Help resources