Source code for bookmarklet Show Tables.
javascript:
(function(){
function hasAttribute(e, a)
{
return e.hasAttribute(a);
}
var table_count = 0;
function eD(dt) {
var fs = dt.getElementsByTagName( "TABLE" );
for (var i = 0, l = fs.length; i < l; ++i )
{
++table_count;
fs[i].style.border = "thin solid red;";
if ( hasAttribute(fs[i], "SUMMARY") )
{
fs[i].style.borderTop = "thick solid green";
fs[i].title = "Table summary: " + fs[i].summary;
}
}
}
function ifs_( fs )
{
for (var i = 0; i < fs.length; ++i)
{
try {
dI_(fs[i].contentDocument, fs[i]); // recursive call
}
catch (e) {
alert(e || "Unspecified error");
}
}
}
// "dI" == "documentIterator"
function dI_(dt, f) {
if (dt == null) {return;}
eD(dt, f);
ifs_( dt.getElementsByTagName("FRAME") );
ifs_( dt.getElementsByTagName("IFRAME") );
}
// iterate through all documents
dI_(document, null);
var st = (table_count > 0) ? ("Tables: " + table_count) : "No tables";
alert(st + ".");
})();