Last active
December 27, 2015 00:59
-
-
Save cdeutsch/7241538 to your computer and use it in GitHub Desktop.
Better Marketo / Salesforce munchkin.js loading that won't fire initMunchkin twice in IE.
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
| <script type="text/javascript"> | |
| (function() { | |
| function initMunchkin() { | |
| Munchkin.init('YOUR-ID'); | |
| // custom handling after marketo is ready | |
| if (typeof marketo_ready != 'undefined') marketo_ready(); | |
| } | |
| var s = document.createElement('script'); | |
| s.type = 'text/javascript'; | |
| s.async = true; | |
| s.src = document.location.protocol + '//munchkin.marketo.net/munchkin.js'; | |
| if (s.readyState) { // IE, incl. IE9 | |
| s.onreadystatechange = function() { | |
| if (s.readyState == "loaded" || s.readyState == "complete") { | |
| s.onreadystatechange = null; | |
| initMunchkin(); | |
| } | |
| }; | |
| } else { // Other browsers | |
| s.onload = initMunchkin; | |
| } | |
| ( document.getElementsByTagName('head')[0] || document.getElementsByTagName('body')[0] ).appendChild( s ); | |
| })(); | |
| </script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment