6

次のコードを自分のサイトに配置して、標準的な +1 を追加すると、

<!-- Place this tag where you want the +1 button to render. -->
<div class="g-plusone"></div>

<!-- Place this tag after the last +1 button tag. -->
<script type="text/javascript">
  window.___gcfg = {lang: 'nl'};

  (function() {
    var po = document.createElement('script'); po.type = 'text/javascript'; po.async = true;
    po.src = 'https://apis.google.com/js/plusone.js';
    var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(po, s);
  })();
</script>

それは私が望まないことをします。

このコードがなければ、サイトを機能させるために必要な独自の phpsessid しかありません。

このコードにより、次の Cookie がドメイン plusone.google.com から削除されます

Google Plus one はたくさんの Cookie をドロップします!

さて、有効期限を見ると、2014年、2022年、2013年のどこかで...彼らは非常に長い間生きます.

ポイントは、Google + 1ボタンによるCookieの配置を無効にする方法に簡単にアクセスできるドキュメントはどこにもないということです.

ただし、クエストで分析用のCookieを無効にする方法を見つけました(万歳!)が、今度は、plusoneにCookieをドロップしないように指示する方法、javascriptオプション、または何かを見つける必要があります(長生きするオランダ語/ヨーロッパのCookie法)

質問: +1 ボタンに Cookie をドロップしないように指示するドキュメント/オプションに遭遇したことのある人はいますか?

4

3 に答える 3

1

EU の Cookie 法は、一見したよりもはるかに扱いにくいようです :\

Google の +1 ボタンによって設定された Cookie をブロックする方法はないようです。ユーザーは設定でサードパーティの Cookie をブロックする可能性があります、サイト開発者として、特定のサイトがサードパーティからの Cookie を許可しないことを示すことはできず、実際の Cookie は別のドメインに設定されているため、Javascript もそれを妨害することはできません。

このディレクティブにより、必須のCookie を保持できるため、訪問者が Cookie を受け入れたか拒否したかを記録する目的で Cookie を保存できます。その Cookie が設定されていない場合は、一度許可を求めることができます。+1 ボタンの初期化は、訪問者がサード パーティの Cookie を追跡する許可を与えた場合、または既に Cookie に記録された許可を取得している場合にのみ続行してください。それ以外の場合は、+1 ボタンの初期化コードをスキップする必要があります。

大まかな不完全な例 (実際の Cookie 操作は省略):

(function() {
    var allowed = getCookie('allowCookies');
    if (allowed === undefined) {
        allowed = confirm('Allow cookies?');
        setCookie('allowCookies', allowed? 1: 0);
    }
    if (allowed) {
        // initialize +1 buttons:
        var po = document.createElement('script'); po.type = 'text/javascript'; po.async = true;
        po.src = 'https://apis.google.com/js/plusone.js';
        var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(po, s);

        // initialize any other third-party tools that might set cookies ...
    }
})();
于 2012-10-27T08:07:19.323 に答える
0

ソーシャル共有ボタンについて私が気に入らないことの 1 つは、JavaScript 操作と無駄な速度があることです。

ほとんどの場合、私は静的ボタンを使用するので、静的ボタン も使用する必要があります

それ以外の場合: この問題の回避策は、ページのロード後に Cookie の設定を解除することです

onLoad() を使用して設定を解除する

あなたは何を考えていますか?

于 2012-10-29T06:41:08.600 に答える
0

アクセス許可ベースの回避策をコード化しましたが、ユーザーがクリックしたときにアクセス許可を得るためにユーザーにバグを報告する必要があるため、理想からはほど遠いと思いますが、何もないよりはましです。

Google が不要な Cookie をドロップしないようにする方法が必要です。私の意見では、非常に多くの Cookie または Cookie を使用してユーザーを追跡する必要はまったくありません。

このコードは、ユーザーにリンクをクリックさせます。クリックすると、ボタンを表示するかどうか、およびその決定の結果は何かを尋ねられます。

私のコード例: http://jsfiddle.net/CADjN/3/

ライブデモ https://www.ortho.nl/orthomoleculaire-bibliotheek/artikel/8091/Langer-leven-met-vitamine-D

<script type="text/javascript"> 
// 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<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 = ''; 
        }
    }
    </script>
    <!-- Where the plusone button should go this piece of code should be placed -->
    <a id="plus1" href="javascript:loadplusone('plus1')">Show Google +1</a><g:plusone></g:plusone>
    <!-- This should be placed below the above code or in the onload event of the document -->
    <script type="text/javascript">
    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 = ''; 
        }
    </script>
于 2012-10-22T10:21:32.117 に答える