Reputation: 5800
I was wondering how you use a javascript tag in HTML to create an Iframe.
I've see it around, for example the 'Share This' button that everyone wants in there site is a script tage that then turns it's self into an Iframe.
How do you do this. I would rather give the client a line of script as opposed to an Iframe tag (so I can host the script externally and do things like change the location of the embedded Iframe. ).
Upvotes: 1
Views: 436
Reputation: 38526
An IFrame is just an HTML tag like anything else, so the same code you would use to populate HTML somewhere works to create an iFrame.
<script type=text/javascript>
document.getElementById('someDiv').innerHTML = '<iframe src="whatever.com/" height= width=>';
</script>
Upvotes: 1
Reputation: 63522
document.createElement("iframe");
here's a good tutorial as well: http://www.eggheadcafe.com/community/aspnet/3/83909/how-to-createelementa-and-add-innertext.aspx
Upvotes: 2