a me dà errore con IE e Firefox. Credo che sia la riga 13:

t.removeChild(t.lastChild);

dove t.lastChild è null