2017-06-09 5 views
0

InsitesのCookieConsentプラグインを使用していて、 "onStatusChange"メソッド内の "setCookie"関数を使用して追加の(他の)Cookieを作成したいとします。InsitesによるCookieConsentのsetCookieの使用

onStatusChange: function(status, chosenBefore){ 
var type = this.options.type; 
    var didConsent = this.hasConsented(); 

    if (type == 'opt-in' && didConsent) { 
    // enable cookies 


    } 

} 

問題は、「未定義のプロパティ 'setCookie'を読み取ることができません」ということです。どんな助けもありがとう。

敬具

+0

'<>'と、[作成]をクリックしてください: [リンク]ここhttps://cookieconsent.insites.com/documentation/javascript-api/

とは私のスクリプトです関連するJSファイルとHTMLで – mplungjan

+0

とmcve]ここに私のスクリプトです – Tinko

答えて

0

これは私が使用するプラグインです:

<script> 

window.addEventListener("load", function(){ 
    var p; 
window.cookieconsent.initialise({ 

    "palette": { 
    "popup": { 
     "background": "rgba(255,150,33,0.9)", 
     "text": "black" 
    }, 
    "button": { 
     "background": "transparent", 
     "border": "white", 
     "text": "black" 
    } 
    }, 
    "type": "opt-in", 
    "content": { 
    message:'The message', 
    dismiss:'dismiss', 
    allow:'allow', 
    link:'Read more', 
    href:'http://example.com', 

    }, 
    revokable:true, 
    onStatusChange: function(status, chosenBefore) { 
    var type = this.options.type; 
    var didConsent = this.hasConsented(); 

    if (type == 'opt-in' && didConsent) { 

    setCookie('xxx','allow',365,'/','');  

    } 
    }, 
    cookie: { 
    name: 'wwwZalarisCC'  
    }, 
onRevokeChoice: function(){ 


} 
}, function (popup) { 

    p = popup; 
    var output = ''; 
    for (var property in p) { 
    output += property + ': ' + p[property]+'; '; 
} 

    }); 
document.getElementById('btn-revokeChoice').onclick = function (e) { 

    p.revokeChoice(); 

    }; 
    }); 

</script> 
関連する問題