popupConsent.js是一个jQuery插件,允许您的页面和网络应用程序遵守欧洲Cookie法和GDPR。
它在页面加载时显示cookie同意弹出窗口,通知用户您的网站使用cookie,并提供cookie设置面板,用户可以在其中选择并接受某些cookie进行激活。
1.将jQuery popupConsent.js插件的文件插入到您的文档中。
<link rel="stylesheet" href="popupConsent.css" /> <script src="/path/to/cdn/jquery.min.js"></script> <script src="popupConsent.min.js"></script>
2.配置GDPR和Cookie同意弹出窗口。
var cookieConsentOptions = { // Cookie consent text 'textPopup': 'We use cookies/targeted advertising to ensure you have the best experience on our site. If you continue to use our site, we will assume that you agree to their use. For more information, please see our <a href="#">privacy policy</a>.', // Accept button 'textButtonAccept' : 'Accept all', // Config button 'textButtonConfigure' : 'Configuring choices', // Save button 'textButtonSave' : 'Save choices', authorization: [ { textAuthorization: 'Allow access to geolocation data', nameCookieAuthorization: 'autoriseGeolocation' }, { textAuthorization: 'Allow personalised ads and content, ad measurement and audience analysis', nameCookieAuthorization: 'targetedAdvertising' }, { textAuthorization: 'Storing and/or accessing information on a device', nameCookieAuthorization: 'cookieConsent' } ] }
3.初始化插件并完成。
popupConsent(cookieConsentOptions);
2.0.0版(2021-12-05)