title: Javascript Set Var once
body: <p>I want to make a Google chrome extension that when i click on it.</p>
  
  <p>then the variable i will go up once and when i click again i want it to go up once more.
  when Variable i equals 3 then i want to to set to 0 again.</p>
  
  <p>I want to make a sort of switch.</p>
  
  <p><strong>BACKGROUND.JS</strong></p>
  
  <pre><code>var i = 0;
          chrome.browserAction.onClicked.addListener(function(activeTab) {
      i = i + 1
      if (i == 1) {
          var newURL = "http://www.website1.com";
          chrome.tabs.create({ url: newURL });
              var newURL = "http://www.website2.com";
          chrome.tabs.create({ url: newURL });
              var newURL = "http://www.website3.com";
          } elseif (i == 2) {
           chrome.tabs.close()
          } else {
           var i = 0
          }
      });
  </code></pre>
  
  <p>when i click on my Extension notification then it doesnt do anything at all.
  and i think the chrome.tabs.close also doensnt work.</p>