Question

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/.

Was it helpful?

Solution

I think so, but I'm not sure if it's compatible with Internet Explorer 7 or earlier versions, but you can download the Internet Explorer emulator. It emulates all versions of Internet Explorer since 5.5.

It's free and is available from Browser Compatibility Check for Internet Explorer Versions from 5.5 to 10.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top