<script defer>
function _show(str){
var w=window.open('','');
var d=w.document;
d.open();
str=str.replace(/=(?!")(.*?)(?!")( |>)/g,"=\"$1\"$2");
str=str.replace(/(<)(.*?)(>)/g,"<span style='color:red;'><$2></span><br />");
str=str.replace(/\r/g,"<br />\n");
d.write(str);
}
</script>
<html>
<body>
<form>
<input type="button" value="SHOW" onClick="_show(document.documentElement.innerHTML)" />
</form>
</body>
</html>
中间用了正则表达式