span
p
h1
h2
h3
h4
h5
h6
b
i
strong
em
q
cite
acronym
blockquote
ins
del
sub
sup
big
small
addresspre
code
var
bdo
dfn
kbd
samp
- li
- li
- li
- li
-
dt
- dd
- dd2
ththtdtd
ththtdtdththtdtdlegend
button
optionoption
label
textarea
var NORMAL_STYLE = [
"display",
"margin-top",
"margin-bottom",
"margin-left",
"margin-right",
"padding-top",
"padding-bottom",
"padding-left",
"padding-right",
"border-left-width",
"border-right-width",
"border-top-width",
"border-bottom-width",
"border-left-style",
"border-right-style",
"border-top-style",
"border-bottom-style",
"overflow",
"font-weight",
"font-size",
"font-style",
"font-variant",
"text-decoration",
"line-height",
"border-collapse",
"vertical-align"
];
function toCamelCase(str) {
return str.replace(/-D/g, function(match){
return match.charAt(1).toUpperCase();
});
}
var tagMap = {};
function elementsStyles(el) {
elementStyles(el);
el = el.firstChild;
while (el) {
if (el.nodeType == 1) {
elementsStyles(el);
}
el = el.nextSibling;
}
}
var alterColor = false;
function elementStyles(el) {
var tagName = el.tagName;
if (tagMap[tagName]) {
return;
}
tagMap[tagName] = 1;
html.push("
" + el.tagName + "");alterColor = !alterColor;
for (var i = 0, l = NORMAL_STYLE.length; i < l; i++) {
var sty = NORMAL_STYLE[i];
html.push("
",elementStyle(el, sty),
"
");}
html.push("
");}
function elementStyle(el, sty) {
var currentStyle = el.currentStyle || document.defaultView.getComputedStyle(el, null);
return currentStyle[toCamelCase(sty)];
}
var html = ["
for (var i = 0, l = NORMAL_STYLE.length; i < l; i++) {
html.push("
" + NORMAL_STYLE[i] + "");}
html.push("
");//elementStyles(document.documentElement);
elementsStyles(document.body);
html.push("
");document.body.innerHTML += html.join("");
---★ 本文转摘自『IT学习者』→http://www.itlearner.com/article/4437