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/
This commit is contained in:
Amauri CHAMPEAUX 2015-03-04 21:13:35 +01:00
parent 11dd85bc68
commit 3ca8eb7743
1 changed files with 2 additions and 2 deletions

View File

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