title: Embed widget : javascript generate iframe
body: <p>I need to develop a widget for embedding my contents on 3rd party HTMLs.</p>
  
  <p>I searched several pages about this topic, and understood pros/cons of using iframe and javascript but still remain one question.</p>
  
  <p>I mean:<br>
  using iframe is giving 3rd party users a iframe tag, e.g. <code>&lt;iframe src="https://sample.com/widget.html&lt;/iframe&gt;</code><br>
  using javascript is giving 3rd party users a script tag, e.g. <code>&lt;script src="https://sample.com/widget.js&lt;/script&gt;</code></p>
  
  <p>A page explains about using Js, but their Js code just generates iframe and insert it into parent's node and set contents to iframe.
  e.g.</p>
  
  <pre><code>var iframe = document.createElement('iframe');  
  iframe.src = 'https://sample.com/widget.html
  // insert iframe into parent node
  // or set content into document
  var doc = iframe.contentWindow.document;
  doc.open();
  doc.write('content');
  doc.close();
  </code></pre>
  
  <p>My question is how differences between just using iframe and using iframe that Js generated and inserted?</p>
  
  <p>My understanding is that iframe via Js is better if I want to change iframe's behavior/appearance.
  But these are almost same behavior if Js code just inserting iframe.
  Is it correct?</p>