March 2011 Archives

Firefox 4 bug adding inline script tag - last tag doesn't fire

I came across a nasty bug in Firefox 4 today, which will break a lot of AJAX.

All script tags fire, except for the last one, eg:


function test(num) {
    var temp = document.createElement('div');
    var src  = '<script type="text/javascript">' +
                       'alert("Hi");'  + 
                    '<' + '/script>';
    if (num === 2) {
        src = src + '<script></' +'script>';
    }
    temp.innerHTML = src;
    body.appendChild(temp);
}


About Clinton Gormley

user-pic The doctor will see you now...