I need to develop a widget for embedding my contents on 3rd party HTMLs.
I searched several pages about this topic, and understood pros/cons of using iframe and javascript but still remain one question.
I mean:
using iframe is giving 3rd party users a iframe tag, e.g. <iframe src="https://sample.com/widget.html</iframe>
using javascript is giving 3rd party users a script tag, e.g. <script src="https://sample.com/widget.js</script>
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.
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();
My question is how differences between just using iframe and using iframe that Js generated and inserted?
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?