window.addEventListener('load', function() { var tbls = document.getElementsByTagName('table'), len = tbls.length, obj = document.createElement('object'); for (var i = 0; i < len; i++) { var t = tbls[i], o = obj.cloneNode(); o.setAttribute('tid', i); o.onload = function(e) { loadTsv(e) }; o.data = t.getAttribute('data'); document.body.appendChild(o); } }); function loadTsv(e) { var o = e.target, tsv = o.contentDocument.body.textContent, rows = tsv.split(/[\n\r]+/), nrow = rows.length, tid = o.getAttribute('tid'), tbl = document.getElementsByTagName('table')[tid], ary = [], s = document.createElement('script'); ary.push(''); ary.push(rows[0].split(/\t/).join('')); for (var i = 1; i < nrow; i++) { if (rows[i].length === 0) break; ary.push(''); ary.push(rows[i].split(/\t/).join('')); } tbl.innerHTML = ary.join(''); // remove OBJECT element o.parentNode.removeChild(o); // add dummy script tag for Firefox Auto Reload s.src = o.data; document.body.appendChild(s); }