关键字语法高亮

2006-03-22 09:17:31

[code]<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> <HTML> <HEAD> <TITLE> New Document </TITLE> <META NAME="Generator" CONTENT="Microsoft FrontPage 4.0"> <META NAME="Author" CONTENT=""> <META NAME="Keywords" CONTENT=""> <META NAME="Description" CONTENT=""> </HEAD> <BODY> <TEXTAREA ID="ta_CodeBox" ROWS="20" COLS="40">var Stroll = new Object(); window.alert(); function window.onload() { } </TEXTAREA> <br> <INPUT TYPE="button" value="TEXT" onclick="TestCode(ta_CodeBox.value)"> <br> <div id="dv_ShowCodeBox"> </div> <SCRIPT LANGUAGE="JavaScript"> <!-- function TestCode(Str) { var re = /(^|\b)(if|var|else|function|while|for|switch|new|with|case)(\b|$|;|\()/gi; dv_ShowCodeBox.innerHTML = "<pre>"+Str.replace(re,"$1<font color=blue>$2</font>$3")+"</pre>"; } //--> </SCRIPT> </BODY> </HTML> [/code]