Load iframe using JavaScript

banner-image

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.

Tags:

Subscribe
Notify of
guest
0 Comments
Oldest
Newest Most Voted
Inline Feedbacks
View all comments
0
Would love your thoughts, please comment.x
()
x