title: Set content of iframe
body: <p>I have the following structure.</p>
  <pre><code>&lt;div&gt;
  &lt;p&gt;Hello World !!&lt;/p&gt;
  &lt;/div&gt;
  &lt;iframe id=&quot;myiframe&quot; src='myiframeContent.html'&gt;&lt;/iframe&gt; 
  </code></pre>
  <p>and I have the following JavaScript variable with <code>content</code>:</p>
  <pre><code>var s =&quot;&lt;html&gt;&lt;head&gt;&lt;/head&gt;&lt;body&gt;&lt;div&gt;Test_Div&lt;/div&gt;&lt;/body&gt;&lt;/html&gt;&quot;;
  </code></pre>
  <p>How can I change the content of iframe with id <code>myiframe</code> with variable <code>s</code>?</p>
  <p>I tried:</p>
  <pre><code>$(&quot;#myiframe&quot;).html(s);
  </code></pre>
  <p>Which giving me a very unusual return, it changes all the content of Current page to <code>VAR S</code>
  Ex : styles,background etc..</p>
  <p>How can I set the content of an iframe with a variable that contains <code>HTML</code>?</p>
  <p>The content of variable <code>s</code> follows:</p>
  <pre><code> &lt;html&gt;
    &lt;head&gt;
      &lt;title&gt;{page_name}&lt;/title&gt;
      &lt;meta name=&quot;keywords&quot; content=&quot;{page_meta_tags}&quot; /&gt;
      &lt;script src=&quot;/1.js&quot;&gt;&lt;/script&gt;
      &lt;script src=&quot;/2.js&quot;&gt;&lt;/script&gt;
   &lt;style&gt;
     h2{
   
   color:red;} 
  
   h1{
   color:red;}
  
   body{
       
   background-color:#f0eded;
   color:74f503;
   font-family:Verdana, Geneva, sans-serif;
   background:url({getUrl});}
    &lt;/style&gt; 
    &lt;/head&gt;
     
    &lt;body&gt;
      yahoo
      &lt;div style=&quot;float:right&quot;&gt;{pagecomment}&lt;/div&gt;
      &lt;div id=&quot;blogstart&quot; style=&quot;&quot;&gt;
        &lt;h1&gt;My Blog&lt;/h1&gt;
        {nextPrevPagination}
        {blog} 
        {nextPrevPagination}
      &lt;/div&gt;
      &lt;p&gt;My Page Name : {page_name}&lt;/p&gt;&lt;br/&gt;
      &lt;p&gt;Name of this template&lt;/p&gt;&lt;br/&gt;
      &lt;p&gt;Date started this page : {page_date}&lt;/p&gt;&lt;br/&gt;
      &lt;label&gt;Address&lt;/label&gt;
      &lt;textarea&gt;{page_address}&lt;/textarea&gt;
      
      &lt;span&gt;Country : {page_country} State :{page_state}&lt;/span&gt;
      &lt;p&gt;page City : {page_city} Page Pincode {page_pincode}&lt;/p&gt;
      &lt;a href=&quot;mailto:{page_email}&quot;&gt;Email me&lt;/a&gt;
      {page_bio_title} and {page_bio_desc}
      &lt;img src=&quot;{page_profile}&quot; /&gt;
      {page_avatar}
      &lt;p&gt;Contact me : {page_mobile} , {page_landline} &lt;/p&gt;
      &lt;a href=&quot;http://www.facebook.com/{page_facebook_user}&quot;&gt;I am on Facebook&lt;/a&gt;
      &lt;a href=&quot;http://www.twitter.com/{page_twitter_user}&quot;&gt;&lt;/a&gt;
    &lt;/body&gt;
    
  &lt;/html&gt;
  </code></pre>
  <p>After applying this variable to the iframe I got like this  [inspected through firebug]<br />
  Note that it doesn't have <code>BODY</code> ,<code>Head</code> tag, but the above one [var s] has a <code>BODY</code> tag.</p>
  <pre><code>&lt;html&gt;  
    
      &lt;title&gt;{page_name}&lt;/title&gt;
      &lt;meta content=&quot;{page_meta_tags}&quot; name=&quot;keywords&quot;&gt;
      
      
   &lt;style&gt;
     h2{
   
   color:red;} 
  
   h1{
   color:red;}
  
   body{
       
   background-color:#f0eded;
   color:74f503;
   font-family:Verdana, Geneva, sans-serif;
   background:url({url});}
    &lt;/style&gt; 
    
      yahoo
      &lt;div style=&quot;float: right;&quot;&gt;{pagecomment}&lt;/div&gt;
      &lt;div style=&quot;&quot; id=&quot;blogstart&quot;&gt;
        &lt;h1&gt;My Blog&lt;/h1&gt;
        {nextPrevPagination}
        {blog} 
        {nextPrevPagination}
      &lt;/div&gt;
      &lt;p&gt;My Page Name : {page_name}&lt;/p&gt;&lt;br&gt;
      &lt;p&gt;Name of this template&lt;/p&gt;&lt;br&gt;
      &lt;p&gt;Date started this page : {page_date}&lt;/p&gt;&lt;br&gt;
      &lt;label&gt;Address&lt;/label&gt;
      &lt;textarea&gt;{page_address}&lt;/textarea&gt;
      
      &lt;span&gt;Country : {page_country} State :{page_state}&lt;/span&gt;
      &lt;p&gt;page City : {page_city} Page Pincode {page_pincode}&lt;/p&gt;
      &lt;a href=&quot;mailto:{page_email}&quot;&gt;Email me&lt;/a&gt;
      {page_bio_title} and {page_bio_desc}
      &lt;img src=&quot;{page_profile}&quot;&gt;
      {page_avatar}
      &lt;p&gt;Contact me : {page_mobile} , {page_landline} &lt;/p&gt;
      &lt;a href=&quot;http://www.facebook.com/{page_facebook_user}&quot;&gt;I am on Facebook&lt;/a&gt;
      &lt;a href=&quot;http://www.twitter.com/{page_twitter_user}&quot;&gt;&lt;/a&gt;
    &lt;/html&gt;
  </code></pre>