title: Execute JavaScript functions in google chrome address bar
body: <p>I want to execute JavaScript code in address bar of my google chrome <code>javascript:</code>. It works fine with something simple such as:</p>
  
  <pre><code>javascript:alert("aaa");
  </code></pre>
  
  <p>But it doesn't work with more than one alert. I found out that placing everything in brackets would do the trick:</p>
  
  <pre><code>javascript:{alert("aaa"); alert("blabla"); document.getElementsById("myId").innerHTML = "aa";}
  </code></pre>
  
  <p>But it doesn't work with something more complex such as <code>for</code> or calling a function. I really need to execute <code>for</code> like this: </p>
  
  <pre><code>var elements = document.getElementsByTagName('div');
  
  for (var i = 0; i &lt; elements.length; i++) {
      elements[i].innerHTML = "foo";
  }​
  </code></pre>
  
  <p>I tried it with both <code>javascript:</code> and <code>javascript:{</code>...<code>}</code> and it didn't work. </p>
  
  <p>So my question is: How can I execute more complex JavaScript code such as this one above?</p>