title: Return Javascript variable to AppleScript
body: <p>So, I have a simple problem which may not be possible in AppleScript. I'm attempting to return a variable from a javascript that doesn't have a return in the code. In other words, I'm trying to get the status of an element so that I can run a function conditionally. Here is the code I have that will not get a return: </p>
  
  <pre><code>tell application "Safari"
      activate
      open location "http://127.0.0.1:9999"
      delay 1
      set myVar to do JavaScript "var obj = document.getElementById(87); myVar = obj.value; return myVar;" in document 1
      return myVar
  end tell
  </code></pre>
  
  <p>So, basically I'm trying to get the value of <code>obj</code> and return it to AppleScript, which should be between 0 and 255 (it's a button). The problem is, I don't have any control over the javascript function so I can't add a <code>return obj.value</code>. Is this possible?</p>