如何根据 gclid 参数隐藏 header?

How can I hide the header based on the gclid parameter?

我只想对来自 google ads(adwords) 并具有 gclid 参数的访问者隐藏 header 和页脚。我怎样才能做到这一点? 示例:使用 gclid 参数的 url,其中每个参数都是唯一的 www.example.com/?gclid=12345abcde

谢谢

if (window.location.href.indexOf('gclid') > 0) {
    document.getElementById('header').style.display = "none"
}

解释:window.location.href 获取当前 URL,然后使用 indexOf 可以确定字符串是否具有给定的子字符串,如果有 returns 索引,如果没有returns -1;因此 if 语句的 > 0 条件。