浏览代码

IE hack

IE 8 and lower does not innerHTML script if a 'visible' element is not
present before.
Thanks
https://allofetechnical.wordpress.com/2010/05/21/ies-innerhtml-method-with-script-and-style-tags/
Amauri CHAMPEAUX 10 年之前
父节点
当前提交
3ca8eb7743
共有 1 个文件被更改,包括 2 次插入2 次删除
  1. 2 2
      tarteaucitron.js

+ 2 - 2
tarteaucitron.js

@@ -707,7 +707,7 @@ var tarteaucitron = {
             }
             tarteaucitron.makeAsync.antiGhost += 1;
             tarteaucitron.addScript(url, '', function () {
-                document.getElementById(id).innerHTML += tarteaucitron.makeAsync.buffer;
+                document.getElementById(id).innerHTML += "<span style='display:none'>&nbsp;</span>" + tarteaucitron.makeAsync.buffer;
                 tarteaucitron.makeAsync.buffer = '';
                 tarteaucitron.makeAsync.execJS(id);
             });
@@ -725,7 +725,7 @@ var tarteaucitron = {
                 if (type === '') {
                     type = (scripts[i].getAttribute('language') !== null) ? scripts[i].getAttribute('language') : '';
                 }
-                if (scripts[i].getAttribute('src') !== null) {
+                if (scripts[i].getAttribute('src') !== null && scripts[i].getAttribute('src') !== '') {
                     childId = id + Math.floor(Math.random() * 99999999999);
                     document.getElementById(id).innerHTML += '<div id="' + childId + '"></div>';
                     tarteaucitron.makeAsync.getAndParse(scripts[i].getAttribute('src'), childId);