title: Chrome Extension: Load arbitrary URLs in iFrame
body: <p>I have a Chrome extension that comes with a popup window which, among other things, contains an <code>iframe</code> to load websites. In principle, I can set the <code>src</code> attribute of the iFrame and it works fine. The problem, however, is that many website do not allow to be loaded within frame, yielding a <code>Refused to display '...' in a frame because it set 'X-Frame-Options' to 'SAMEORIGIN'</code> error. Fair enough!</p>
  
  <p>After some looking around I found a PHP/cURL solution to uses a simple scrip to fetch the content of a URL using cURL and returning the content, which in turn is then used as value for the <code>src</code> attribute. Here's the script <code>grabber.php</code>:</p>
  
  <pre><code>&lt;?php
    $ch = curl_init($_GET['url']);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
    curl_setopt($ch, CURLOPT_BINARYTRANSFER, true);
    $content = curl_exec($ch);
    curl_close($ch); 
    echo $content;
  ?&gt;
  </code></pre>
  
  <p>And here's the code I use to set the <code>src</code> attribute of the iFrame:</p>
  
  <pre><code>$('#myIFrame').attr('src', './grabber.php?url='+someURL);
  </code></pre>
  
  <p>Again, this work in principle, but only reasonably well for rather static / plain HTML websites. As soon as the website is very dynamic, I only get some bits and pieces, i.e., missing content and/or missing style sheets. In short, what the iFrame shows has often almost nothing to do with how the website really looks like.</p>
  
  <p>Is there any chance to get this working properly for any website?</p>