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!
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"});
});
<
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' ];
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.
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>
Copy link to clipboard
Copied
Thank you, TLCMediaDesign!
This seems to have fixed the problem!
It's awesomely working!