Feel free to utilize this snippet for your HTML and CSS implementation:
HTML:
<div class="responsive-iframe"> <!--you can embed this within a responsive layout-->
<iframe id="custom-Iframe" width="560" height="315" frameborder="0"></iframe>
</div>
CSS:
.responsive-iframe{
position: relative;
width: 100%;
padding-bottom: 56.25%;
height: 0;
}
.responsive-iframe iframe{
position: absolute;
top:0;
left: 0;
width: 100%;
height: 100%;
}
The JavaScript part is quite fascinating, as you can dynamically set the content using the contentWindow property without writing to any files,
var customIframe = document.getElementById("custom-Iframe");
customIframe.contentWindow.document = y; //y represents the specific code you wish to insert
For more information, check out: https://www.w3schools.com/jsref/prop_frame_contentwindow.asp