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

Adding Cookie JS to index.html

New Here ,
Mar 30, 2021 Mar 30, 2021

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
924
Translate
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"});
});
<

...
Translate
Participant ,
Mar 30, 2021 Mar 30, 2021

Try (with spaces)

 

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

 

 

Translate
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

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.

Translate
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

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>

Translate
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
LATEST

Thank you, TLCMediaDesign!

This seems to have fixed the problem!

 

It's awesomely working!

Translate
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