【发布时间】:2015-09-15 04:57:39
【问题描述】:
在此示例中,一个函数的返回值作为另一个函数的返回值传递。我不确定我是否理解这样做的必要性。 示例:
function(){
return function(){
// Check if the page contains the div
var node = document.getElementById("sponsored-content"); // use whatever id your block has
isInBody = document.body.contains(node);
// If true
if (isInBody){
dataLayer.push({'event':'spContent-detected'});
}
}
}
当它看起来像这样:
function(){
// Check if the page contains the div
var node = document.getElementById("sponsored-content"); // use whatever id your block has
isInBody = document.body.contains(node);
// If true
if (isInBody){
dataLayer.push({'event':'spContent-detected'});
}
}
为了更好的上下文,tag manager guide 是原始代码的来源。如果条件为假,添加它似乎会停止任何其他 js 运行。
【问题讨论】:
标签: javascript web google-tag-manager