Reputation: 1533
What is the best practice creating an iframe
HTML element using JavaScript?
var iframe = document.createElement("iframe");
iframe.setAttribute("sandbox", "")
iframe.setAttribute("src", url);
I faced the question while developing Firefox plugin, but usage is quite the same as developing a web page. I do not use jQuery.
Upvotes: 1
Views: 3605
Reputation: 172418
You can try like this:-
<script type="text/javascript">
function abc() {
iframe = document.createElement("IFRAME");
iframe.setAttribute("src", "http://example.com/");
iframe.style.width = "640px";
iframe.style.height = "480px";
document.body.appendChild(iframe);
}
</script>
Upvotes: 2