title: jQuery get variable value from another html page
body: <p>I have got an html page with this content, called "page1.html":</p>
  
  <pre><code>&lt;div&gt;
      &lt;div id="content"&gt;
          content
      &lt;/div&gt;
      &lt;script type="text/javascript"&gt;
          var x=5;
          var y=2;
      &lt;/script&gt;
      &lt;div id="other"&gt;Some other content&lt;/div&gt;
  &lt;/div&gt;
  </code></pre>
  
  <p>In another html page, I'd like to get the value of the variable "x" (5).
  This is the main page:</p>
  
  <pre><code>&lt;!DOCTYPE html&gt;
  &lt;html&gt;
  &lt;head lang="en"&gt;
      &lt;script type="text/javascript" src="app.js"&gt;&lt;/script&gt;
  &lt;/head&gt;
  &lt;body&gt;
      &lt;div id="new_content"&gt;&lt;/div&gt;
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>And this is the app.js script:</p>
  
  <pre><code>$(function(){
      $.get('page1.html', function(result){
          var obj = $(result).find('script');
          $(this).append($('#new_content').text(obj.html()));
      });
  });
  </code></pre>
  
  <p>And the result is "var x=5; var y=2;". Is there a way to get only the value 5 from the var x?</p>
  
  <p>Thanks for the help.</p>
  
  <p>EDIT: I forgot to write that it's only an example, the code into the script in page1.html is more complex than the one shown. The object "obj" in app.js is an [object htmlscriptelement] so I'd like to know if a method/att exists that I can use to directly access the var x.</p>