title: Click Button on Webpage with Applescript/JavaScript
body: <p>I have found several other similar questions, but none of them solve the precise problem I need to solve. I am attempting to simulate a mouse click, to get the entire results of a scroll (e.g., from this site: <a href="http://www.deadseascrolls.org.il/explore-the-archive/manuscript/4Q266-1" rel="nofollow">http://www.deadseascrolls.org.il/explore-the-archive/manuscript/4Q266-1</a>) visible. I specifically want to "click" on the "Load More Results" item at the bottom centre of displayed images (but I think this made more difficult because of the source encoding at the site). I would like to click it until all results are displayed. I have written the following Applescript:</p>
  
  <pre><code>on iaaScroll(myScroll)
  tell application "Safari"
      activate
      open location "http://www.deadseascrolls.org.il/explore-the-archive/manuscript/" &amp; myScroll &amp; "-1" as string
      delay 2.0
      do JavaScript "var myDIV = document.getElementById('loadmore').getElementsByTagName('span')[0];  myDIV.dispatchEvent(new MouseEvent('mousedown')); myDIV.dispatchEvent(new MouseEvent('mouseup'));" in document 1
  end tell
  </code></pre>
  
  <p>end iaaScroll</p>
  
  <p>I cannot, however, successfully get the JavaScript to load all the results on the page. How would I successfully do this? I do not know JavaScript, so your help is much appreciated.</p>