Closed hahlamine closed 3 years ago
@hahlamine ,
this is probably caused by the fact that you've placed the scripts in the <head>
section.
Either place them at the end of the <body>
tag or alternatively you can wrap the entire initialization of the cookie with window.addEventListener('load'), like this:
<script src="https://cdn.jsdelivr.net/gh/orestbida/cookieconsent@v2.4.5/dist/cookieconsent.js" defer></script>
<script>
window.addEventListener('load', function(){
// obtain cookieconsent plugin
var cc = initCookieConsent();
// run plugin with config object
cc.run({
autorun : true,
delay : 0,
...
});
});
</script>
You're not the first one with this error. I should better clarify in the docs.
Weird. I call cookie.js and cookieconsent.js at the bottom of head and don't have any problems. Should I move it at the end of body tag? I am a bit confused why on my implementation is work. I work with pure HTML pages though and not PHP.
@panseit
probably because you are using defer
which explicitly tells the plugin to wait for body
tag to be loaded first. and then execute the code, as I stated in the previous issue.
Ohh perfect :D
I've got an error when installing this for the first time.
Here is my code :
`
`