因此,我一直在阅读issue #3888,并试图弄清楚如何恢复已暂停的脚本。
本质上,我试图使用分析来跟踪按钮(我正在使用Opera Mini and JavaScript进行跟踪)。
window.onload = function () {
onClick = function () {
var button = document.getElementById('button');
setGoal = function () {
ym(54060910, 'reachGoal', 'TEST');
return true;
}
setInterval(setGoal, 50);
// Unpauses the interval
restart = function () {
// This can be an empty function
}
button.addEventListener('click', restart, false);
}
}
该跟踪在现代浏览器中可以正常运行,但在Opera Mini中却不能。我已根据上述博客文章中的功能对该功能进行了建模,该功能旨在恢复已暂停的脚本:
var box = document.getElementById('box'),
update = document.getElementById('valofnewcol'),
start = 0;
changecolor = function(element, degreeshift, update) {
var newcol = (start * degreeshift) / 360 << 8,
col = 'hsl(' + newcol + ', 100%, 50%)',
coltxt = document.createTextNode(col),
anim,
restart;
element.style.background = col;
start++;
if (update.firstChild) {
update.replaceChild(coltxt, update.firstChild);
} else {
update.appendChild(coltxt);
}
}
anim = setInterval(changecolor, 50, box, 45, update);
// Unpauses the interval
restart = function(){
// This can be an empty function
}
box.addEventListener('click', restart, false);
我的问题是:
P.s我正在使用Yandex Metrica,但我假设相同的原理也适用于Google Analytics(分析)