我必须在现有代码中添加一行,但我不确定这是否是正确的方法。
这是现有的代码
if (window.total_time <= window.cutOffTime) {
tos = TrackingLogTime(tos.split(":").reverse());
ga("send", "event", "Time", "Log", tos)
} else {
window.clearInterval(window.stIntervalObj)
}
我需要添加此操作
ga("newTracker.send", "event", "Time", "Log", tos)
这样可以吗
if (window.total_time <= window.cutOffTime) {
tos = TrackingLogTime(tos.split(":").reverse());
ga("send", "event", "Time", "Log", tos) && ga("newTracker.send", "event", "Time", "Log", tos)
} else {
window.clearInterval(window.stIntervalObj)
}
最佳答案
只需将新函数调用添加为单独的语句即可:
if (window.total_time <= window.cutOffTime) {
tos = TrackingLogTime(tos.split(":").reverse());
ga("send", "event", "Time", "Log", tos);
ga("newTracker.send", "event", "Time", "Log", tos);
} else {
window.clearInterval(window.stIntervalObj);
}
关于javascript - 满足条件后双重 Action ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29616972/