javascript Google Optimize Script
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了javascript Google Optimize Script相关的知识,希望对你有一定的参考价值。
function setCookie(cname, cvalue, exdays) {
var d = new Date();
d.setTime(d.getTime() + (exdays*24*60*60*1000));
var expires = "expires="+ d.toUTCString();
document.cookie = cname + "=" + cvalue + ";" + expires + ";path=/";
}
function getCookie(cname) {
var name = cname + "=";
var decodedCookie = decodeURIComponent(document.cookie);
var ca = decodedCookie.split(';');
for(var i = 0; i <ca.length; i++) {
var c = ca[i];
while (c.charAt(0) == ' ') {
c = c.substring(1);
}
if (c.indexOf(name) == 0) {
return c.substring(name.length, c.length);
}
}
return "";
}
function checkCookie() {
var seenBanner = getCookie("seenBanner");
if (seenBanner !== "") {
}else{
$('body').prepend("<div class='container-fluid' id='banner' style='display:inline-flex; border-bottom: 2px solid #024b6c; background-color:#cceaf9 ;padding-top: 14px; padding-bottom:4px; margin:0;'><div id='banner-msg' style='width: calc(100vw - 90px)'><p id='banner-msg-header' style='font-family:ARTIFAKT ELEMENT BOLD; color:#024b6c'><b>An update to our navigation</b></p><p id='banner-msg-body' style='color:#024b6c; font-size: 12px;'>Looking for accounts management? It is now moved under the user context menu.</p></div><div id='banner-btn' style='width: 60px; padding-left: 10px; line-height: 50px;'><a href='#' id='close' style='color:#024b6c;font-family:ARTIFAKT ELEMENT BOLD;'>Got it</a></div></div>");
$('#close').click(function() {
$('#banner').fadeOut("fast", function() {
setCookie("seenBanner", true, 30);
});
});
}
}
checkCookie();
以上是关于javascript Google Optimize Script的主要内容,如果未能解决你的问题,请参考以下文章
javascript Google Analytics事件跟踪Javascript
javascript [userscript] [Google]修复Google搜索标签的顺序
使用 JavaScript 的 Google 大查询
如何通过 Javascript 中的 Google Calendar API 获取 Google Calendar 中事件的位置?
javascript 使用Google Analytics跟踪JavaScript错误(作为事件)
javascript 使用Google Analytics跟踪JavaScript文件加载时间