开发者

Javascript that creates an Iframe

开发者 https://www.devze.com 2023-01-12 19:40 出处:网络
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 s开发者_如何学运维cript tag

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 s开发者_如何学运维cript 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. ).


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


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>
0

精彩评论

暂无评论...
验证码 换一张
取 消