"Best practice" for Javascript widgets: Doesn't use any libraries, doesn't pollute the global namespace, it's cross-browser (to the best of my knowledge), and it's very small. Inspired by Get Satisfaction and Emil Stenström.
Created
July 29, 2010 11:15
-
-
Save kimjoar/497860 to your computer and use it in GitHub Desktop.
This file contains hidden or 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() { | |
| function add_iframe() { | |
| var iframe = document.createElement('iframe'); | |
| iframe.src = 'http://example.org/widget.html'; | |
| iframe.width = "300"; | |
| iframe.height = "200"; | |
| var el = document.getElementById("widget"); | |
| el.appendChild(iframe) | |
| } | |
| if (window.attachEvent) { | |
| window.attachEvent('onload', add_iframe); | |
| } else { | |
| window.addEventListener('load', add_iframe, false); | |
| } | |
| })(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment