Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>I have coded up a permissions based workaround but I still find it far from ideal because I have to bug the user for permission when they click, but it's better than nothing.</p> <p>I still need a way to stop google from dropping unwanted cookies. There is no need to track users with so many cookies or any cookies at all in my opinion.</p> <p>This code makes an user click the link, when they click it they get asked if they want to show the button and what the consequenses are of that descision.</p> <p>My example code: <a href="http://jsfiddle.net/CADjN/3/" rel="nofollow">http://jsfiddle.net/CADjN/3/</a> </p> <p><strong>Live demo</strong> <a href="https://www.ortho.nl/orthomoleculaire-bibliotheek/artikel/8091/Langer-leven-met-vitamine-D" rel="nofollow">https://www.ortho.nl/orthomoleculaire-bibliotheek/artikel/8091/Langer-leven-met-vitamine-D</a></p> <pre><code>&lt;script type="text/javascript"&gt; // Function to set the cookie plusone. function setCookie() { domain = "www.mysite.com"; c_name="plusone"; value="yes"; var exdate=new Date(); exdate.setDate(exdate.getDate() + 365); var c_value=escape(value) + "; expires="+exdate.toUTCString()+';domain='+domain+';path=/'; document.cookie=c_name + "=" + c_value; } // Function to see if our plusone cookie exists and has value yes // Returns true when the cookie is set, false if isn't set. function getCookie() { var i,x,y,ARRcookies=document.cookie.split(";"); for (i=0;i&lt;ARRcookies.length;i++) { x=ARRcookies[i].substr(0,ARRcookies[i].indexOf("=")); y=ARRcookies[i].substr(ARRcookies[i].indexOf("=")+1); x=x.replace(/^\s+|\s+$/g,""); if (x.indexOf("plusone") != -1) { if(unescape(y)=="yes") { return true; } else { return false; } } } } // Load the plusone module but first ask permission function loadplusone(thelink) { // Cookie hasn't been set if(!getCookie()) { // Get permission if(window.confirm("If you wish to 'plusone' this page we need to load a special button from Google.com.\n\nWith this button Google will place some cookies on your computer. Google uses these cookies for statistics and maintaing your login status if you have logged in with Google.\n\nDo you consent to loading the button and the placement of cookies by Google?\n\nIf you agree this website will place a cookie with a year lifetime on your computer to remember this and the plusone button will be loaded on every page where the plusone button is present on this site.")) { // set cookie, load button setCookie(); var jsnode = document.createElement('script'); jsnode.setAttribute('type','text/javascript'); jsnode.setAttribute('src','https://apis.google.com/js/plusone.js'); document.getElementsByTagName('head')[0].appendChild(jsnode); document.getElementById(thelink).innerHTML = ''; } } // cookie has already been set, just load button. else { var jsnode = document.createElement('script'); jsnode.setAttribute('type','text/javascript'); jsnode.setAttribute('src','https://apis.google.com/js/plusone.js'); document.getElementsByTagName('head')[0].appendChild(jsnode); document.getElementById(thelink).innerHTML = ''; } } &lt;/script&gt; &lt;!-- Where the plusone button should go this piece of code should be placed --&gt; &lt;a id="plus1" href="javascript:loadplusone('plus1')"&gt;Show Google +1&lt;/a&gt;&lt;g:plusone&gt;&lt;/g:plusone&gt; &lt;!-- This should be placed below the above code or in the onload event of the document --&gt; &lt;script type="text/javascript"&gt; if(getCookie()) { var jsnode = document.createElement('script'); jsnode.setAttribute('type','text/javascript'); jsnode.setAttribute('src','https://apis.google.com/js/plusone.js'); document.getElementsByTagName('head')[0].appendChild(jsnode); document.getElementById('plus1').innerHTML = ''; } &lt;/script&gt; </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload