title: why doesn't 'do javascript' call in Applescript execute when the same code typed into browser does?
body: <p>I'm trying to figure out why my Applescript does nothing when the same javascript code typed into a Safari location bar works.</p>
  
  <p>Go to a search results page, such as: <a href="http://www.google.com/search?q=test">http://www.google.com/search?q=test</a> .  For the correct behavior, type this into the location bar and hit enter:</p>
  
  <pre><code>javascript: document.getElementsByClassName('vspib')[0].click();
  </code></pre>
  
  <p>You'll see that it selects the magnifier for the first search result.</p>
  
  <p>This is what I want to make happen via javascript.  So I typed up the following:</p>
  
  <pre><code>tell application "Safari"
      activate
      do JavaScript "document.getElementsByClassName('vspib')[0].click();" in document 1
  end tell
  </code></pre>
  
  <p>However, it does nothing.  Any ideas?</p>