该脚本必须运行 1 次。如何?

It is necessary that the script worked 1 time. How?

有一个脚本将计数写入 3,然后阻止横幅的显示。但问题是,如果你再次刷新页面,然后计数器又重新开始。如何避免?请告诉我

$('#grandSale').each(function(i) {
  var self = this,
      cookieCounter = $.cookie('disable_banner');
  if (cookieCounter && cookieCounter < 3) {
      cookieCounter++;
      $(self).show();
      $('#topbar').remove();
      $.cookie('disable_banner', cookieCounter, { expires: 365, path: "/" });
  } else {
      $.cookie('disable_banner', 0, { expires: 365, path: "/" });
  }
});

去掉"else",稍微修改一下条件应该没问题。似乎你重置了计数器并在达到 3 后重新开始。

$('#grandSale').each(function(i) {
  var self = this,
      cookieCounter = $.cookie('disable_banner') || 0;
  if (cookieCounter < 3) {
      cookieCounter++;
      $(self).show();
      $('#topbar').remove();
      $.cookie('disable_banner', cookieCounter, { expires: 365, path: "/" });
  }
});