title: Getting URL of the top frame
body: <p>Inside a facebook application I need to check what is the top frame (the main window) URL, and show content accordingly.</p>
  
  <p>I tried using the following:</p>
  
  <pre><code>if (top.location.toString().toLowerCase().indexOf("facebook.com") &lt;0) { ... }
  </code></pre>
  
  <p>Which works well if the page is not inside an iframe, but when the page is loaded within an iframe (as it does when used as facebook application) the code generates </p>
  
  <blockquote>
    <p>"Uncaught TypeError: Property
    'toString' of object # is not a
    function".</p>
  </blockquote>
  
  <p>Is there any way I can fix this code (with cross-browser compatibility - maybe with jQuery)?</p>
  
  <p>Thanks!</p>
  
  <p>Joel</p>