Page 1 of 1

Adding code to a website

Posted: Sat Apr 28, 2018 8:08 pm
by ekdesigns
Hiya,

I found a nice bit of code for a cookie consent (I know there is one for this software but I wasn't sure how customised I could get it to match a website I'm recreating) - but the instructions are to place it before the </head> tag - I've tried a few of the options on 'insert html' and nothing seems to be appearing. I tested it out on another software and it appears fine so I must be doing something wrong.. Or perhaps it wouldn't be supported?

Here's the code:
<link rel="stylesheet" type="text/css" href="//cdnjs.cloudflare.com/ajax/libs/cookieconsent2/3.0.3/cookieconsent.min.css" />
<script src="//cdnjs.cloudflare.com/ajax/libs/cookieconsent2/3.0.3/cookieconsent.min.js"></script>
<script>
window.addEventListener("load", function(){
window.cookieconsent.initialise({
"palette": {
"popup": {
"background": "#232323"
},
"button": {
"background": "#f4cc22"
}
},
"content": {
"message": "We use cookies to track usage and preferences.",
"dismiss": "I Understand",
"link": "Privacy Policy",
"href": "http://www.malcolmdown.co.uk/privacypolicy.html"
}
})});
</script>

Many thanks!
Esther

Re: Adding code to a website

Posted: Sat Apr 28, 2018 8:35 pm
by Pablo
You can place this code between the head tags in Page HTML.
The code will be inserted "AS IS", so it will work the same as with other software.

Note that because the 'https' prefix is missing in the css/script references, this code will only work online.

Re: Adding code to a website

Posted: Sun Apr 29, 2018 3:58 pm
by ekdesigns
Hi Pablo,

Yes I thought as much, but unfortunately even after I put the code in that location and also publish it, it's still not appearing. I did get it to work briefly when I discovered another version of the code was also in the 'inside <html> tag' part but when I got rid of that, it never appeared again! Must be missing something..

Here's where I published it: http://www.ekdesigns.co.uk/demo/

Thanks,
Esther

Re: Adding code to a website

Posted: Mon Apr 30, 2018 5:53 am
by Pablo
It seems to work correct for me.
Maybe you have clicked 'I Understand' and it will never be displayed again?

Re: Adding code to a website

Posted: Fri May 04, 2018 4:08 am
by mexman
Esther:
It is not working here, because you inserted PHP code into teh demo page without changing its extension to "PHP"
Regards
Michael