我正在制作一个书签,并且需要加载脚本。如果我将load / on load绑定到脚本元素,它将适用于所有浏览器吗?
我已经尝试在所有当前的浏览器上执行此操作,并且看起来工作正常。那年纪大些的呢?
这是一个例子:
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();
}
您可以在http://jsfiddle.net/af4jZ/上看到小提琴。
我认为是这样,但是我不确定它是否与Internet Explorer 7或更早版本兼容,但是您可以下载Internet Explorer模拟器。它模拟了5.5版以来的所有Internet Explorer版本。
它是免费的,并且可以从5.5到10的Internet Explorer版本的浏览器兼容性检查中获得。
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句