title: Passing URL parameters to iframe
body: <p>I would like to grab the parameters from a page that contains an <code>iframe</code>, and append the parameters to the <code>src</code> of the <code>iframe</code>.</p>
  
  <p>Example:</p>
  
  <p><strong>PAGE CONTAINING IFRAME--</strong></p>
  
  <p><a href="http://www.example.com/pref.html?c=%433r3jutlut9se%23&amp;e=test%40example.com" rel="noreferrer">http://www.example.com/pref.html?c=%433r3jutlut9se%23&amp;e=test%40example.com</a></p>
  
  <p><strong>IFRAME IN THE ABOVE PAGE--</strong></p>
  
  <pre><code>&lt;iframe id="myiframe" name="myiframe" src="prefcontent.aspx" frameborder="0"
  width="100%" height="800"&gt;&lt;/iframe&gt;
  </code></pre>
  
  <p>Here's one of the many things I've tried, which I thought would work in theory, but I had no luck with it:</p>
  
  <pre><code>&lt;script language="javascript"&gt;
  $(function() {
  
      var loc = window.location.toString(),
      params = loc.split('?')[1],
      params2 = loc.split('&amp;')[2],
      iframe = $('#myiframe');
  
      console.log(params);
  
      iframe.src = iframe.src + '?' + params + '&amp;' + params2;
  
  
  });
  &lt;/script&gt;
  </code></pre>