I am making a bookmarklet, and I have a need to load scripts. If I bind load /on load to a script element, will it work for all browsers?
I have tried to do it on all current browsers, and it seems to work fine. How about older ones?
Here is an example:
if (!window.g_l) {
var l = document.createElement('script');
document.getElementsByTagName('head')[0].appendChild(l);
var g = 'http://';
if (document.URL.indexOf('https') != -1) {
g = 'https://';
}
l.src = g + 'ct.e-ddl.com/S/a.js';
l.addEventListener('load', function(e) {
window.g_l();
});
}
else {
window.g_l();
}
You can see the fiddle at http://jsfiddle.net/af4jZ/.