title: JavaScript "document is not defined" error when script is not a part of the page
body: <p><strong>What I want to do:</strong> I want to get message from the web page with posts.
  Then I'd like to parse the message into strings according to regular expressions rules.
  (For example, find all the sentences containing a word "bug").</p>
  
  <p>I've chosen JavaScript for no reason - so if there's better way of doing it - please be so kind to mention it.</p>
  
  <p><strong>What I do:</strong> I open <a href="http://vk.com/topic-59389006_28908655?offset=180" rel="nofollow">URL</a>, then I launch JavaScript, which should</p>
  
  <pre><code>var x=document.getElementById("post-59389006_839");
  alert (x.value);
  //or
  var x=document.getElementById("bp_data-59389006_839").innerHTML;
  alert(x);
  </code></pre>
  
  <p>...but it shows "ReferenceError: document is not defined" error.
  If I download the page, then insert my script into it, of course, it works.</p>
  
  <p><strong>Questions</strong>:</p>
  
  <blockquote>
    <ol>
    <li>What am I doing wrong with my JavaScript?</li>
    <li>Is there a better way to parse the strings from web-pages using regexp?</li>
    </ol>
  </blockquote>
  
  <p>p.s. <em>Usually I can find the answers to all my questions (someone has already asked and answered them), but now I either completely misuse JS, or I failed in googling.</em></p>