Created
January 2, 2014 10:12
-
-
Save vishaltelangre/8217253 to your computer and use it in GitHub Desktop.
Function to create iframes with ease
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function createIframe(id, targetEle, src, content, style){ | |
var iframe = document.createElement('iframe'); | |
(iframe.frameElement || iframe).style.cssText = style || "width: 0; height: 0; border: 0"; | |
iframe.id = id; | |
iframe.src = src || "javascript:false"; | |
$(targetEle).append(iframe); | |
if(src) return iframe; | |
var doc = iframe.contentWindow.document; | |
doc.open().write(content); | |
doc.close(); | |
return iframe; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment