As we all know we can load any site content (if allowed) using HTML <iframe> tag. But in some circumstances, we might need to add an iframe using JavaScript code.
To do that, you have to follow the below method.
<iframe id="myFrame" src=""></iframe> <script> document.getElementById("myFrame").src = "www.your_iframe_link.com"; //replace with your iframe link </script>
That’s it. But you just have to replace the “www.your_iframe_link.com” with your iframe link.