资料
表格
制度
合同
管理
职场
经营
创业
范文
总结
计划
作文
文章
美文
词句
教程
模板
图片
字体
图标
办公
人事
财务
生产
管理资源吧首页
>>>
教程
>>>
编程
>>>
JavaScript教程
>>>
支持IE和firefox的js代码美化加亮源码
自己在IE和FF试过了js代码加亮效果,用了一段别人的压缩后的代码作为例子,受限制,删了一部分。 发现错误的大虾一定要留下测试用的代码啊!
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> <HTML xmlns:v="urn:schemas-microsoft-com:vml"> <HEAD> <TITLE> 管理资源吧 <A href="http://www.glzy8.com" _ewebeditor_ta_href="http%3A%2F%2Fwww.glzy8.com">www.glzy8.com</A> </TITLE> <META NAME="Generator" CONTENT="EditPlus"> <META NAME="Author" CONTENT=""> <META NAME="Keywords" CONTENT=""> <META NAME="Description" CONTENT=""> <link rel="Shortcut Icon" href="shell32.dll,20"> <STYLE> #oTxt{ color:#333333; background-color:#f0f0f0; font-family:Courier New; font-size:12px; margin:0; line-height:13px; border-left:none; overflow:scroll; } #oResult{ color:#333333; background-color:#f0f0f0; font-family: Courier New; font-size:12px; margin:0; line-height:13px; border-left:none; overflow:scroll; height:164px; } </STYLE> </HEAD> <BODY> <div id="oEditor" style="width:400;height:164px;padding:0;margin:0;border:none;border-right:solid 2px gray;border-bottom:solid 2px gray;"> <textarea id=oTxt wrap=off style="border:dashed 1px gray; border-right:none; border-bottom:none; width:400;height:164px;padding:2px;" onkeyup="_highlight()"> //<!-- // test comment // s = s.replace(/\/\//g, ''); /*/ 'this is a block' 'http://test.com' 'comment !!' //*/ //*/ 'string2' 'http://test.com' "string1/*" //*/ /*/ 'this is a block' 'http://test.com' "comment !!" /*/ "string1: start a comment /* " 'http://test.com' 'string2: end a comment */ ' //*/ /****************************\ * code highlight * * necrocoder 2006.05.11 * \****************************/ var sss = kkkk.innerHTML+"\r\n"; for(var i=0;i<5;i++) sss += kkkk.innerHTML+"\r\n"+"\r\n"; var tm = (new Date()).getTime(); sss = sss.syntaxed(); var dtm = (new Date()).getTime() - tm; aaa.innerHTML = sss; //aaaa.innerText = sss; document.write('highlighted in '+dtm+'ms.'); /* * Examples */ Array.prototype.indexOf=function(o){for(var i=0;i<this.length;i++){if(this[i]==o)return i;} return-1;};Array.prototype.lastIndexOf=function(o){for(var i=this.length-1;i>=0;i--){if(this[i]==o)return i;}return-1;};Array.prototype.contains=function(o){return this.indexOf(o)!= -1;};Array.prototype.copy=function(o){return this.concat();};Array.prototype.insertAt=function(o,i){this.splice(i,0,o);};Array.prototype.insertBefore=function(o,o2){var i=this.indexOf(o2);if(i== -1)this.push(o);else this.splice(i,0,o);};Array.prototype.removeAt=function(i){this.splice(i,1);};Array.prototype.remove=function(o){var i=this.indexOf(o);if(i!= -1)this.splice(i,1);};String.prototype.trim=function(){return this.replace(/(^\s+)|\s+$/g,"");};Function.READ=1;Function.WRITE=2;Function.READ_WRITE=3;Function.prototype.addProperty=function(sName,nReadWrite){nReadWrite=nReadWrite||Function.READ_WRITE;var capitalized=sName.charAt(0).toUpperCase()+sName.substr(1);if(nReadWrite&Function.READ) this.prototype["get"+capitalized]=new Function("","return this._"+sName+";");if(nReadWrite&Function.WRITE) this.prototype["set"+capitalized]=new Function(sName,"this._"+sName+" = "+sName+";");};function BiObject(){this._hashCode=BiObject._hashCodePrefix+Math.round(Math.random()*1000)+BiObject._hashCodePrefix+BiObject._hashCodeCounter++;} _p=BiObject.prototype=new Object;_p._className="BiObject";_p._disposed=false;_p._id=null;BiObject._hashCodeCounter=1;BiObject._hashCodePrefix="hc";BiObject.toHashCode=function(o){if(o._hashCode!=null) return o._hashCode;return o._hashCode=BiObject._hashCodePrefix+Math.round(Math.random()*1000)+BiObject._hashCodePrefix+BiObject._hashCodeCounter++;};BiObject.prototype.getDisposed=function(){return this._disposed;};BiObject.prototype.getId=function(){return this._id;};BiObject.prototype.setId=function(v){this._id=v;};BiObject.prototype.getUserData=function(){return this._userData;};BiObject.prototype.setUserData=function(v){this._userData=v;};_p.toHashCode=function(){return BiObject.toHashCode(this);};_p.dispose=function(){this._disposed=true;delete this._userData;};_p.toString=function(){if(this._className) return"[object "+this._className+"]";return"[object Object]";};_p.getProperty=function(sPropertyName){var getterName="get"+sPropertyName.charAt(0).toUpperCase()+sPropertyName.substr(1);if(typeof this[getterName]=="function") return this[getterName]();throw new Error("No such property, "+sPropertyName);};_p.setProperty=function(sPropertyName,oValue){var setterName="set"+sPropertyName.charAt(0).toUpperCase()+sPropertyName.substr(1);if(typeof this[setterName]=="function") this[setterName](oValue);else throw new Error("No such property, "+sPropertyName);};_p.setAttribute=function(sName,sValue,oParser) {var v;if(sValue=="true") v=true;else if(sValue=="false") v=false;else if(parseFloat(sValue)==sValue) v=parseFloat(sValue);else v=sValue;this.setProperty(sName,v);};_p.getAttribute=function(sName) {return String(this.getProperty(sName));};_p.addXmlNode=function(oNode,oParser) {if(oNode.nodeType==1) oParser.fromNode(oNode);};if(typeof BiObject=="undefined") BiObject=new Function;function BiBrowserCheck(){if(BiBrowserCheck._singleton) return BiBrowserCheck._singleton;var ua=navigator.userAgent;this._ie= /msie/i.test(ua);this._moz=navigator.product=="Gecko";this._platform=navigator.platform;if(this._moz) {/rv\:([^\);]+)(\)|;)/.test(ua);this._version=RegExp.$1;this._ie55=false;this._ie6=false;} else {/MSIE\s+([^\);]+)(\)|;)/.test(ua);this._version=RegExp.$1;this._ie55= /msie 5\.5/i.test(ua);this._ie6= /msie 6/i.test(ua);} BiBrowserCheck._singleton=this;} BiBrowserCheck.prototype=new BiObject;BiBrowserCheck.prototype.getIe=function() {return this._ie;};BiBrowserCheck.prototype.getIe55=function() {return this._ie55;};BiBrowserCheck.prototype.getIe6=function() {return this._ie6;};BiBrowserCheck.prototype.getMoz=function() {return this._moz;};BiBrowserCheck.prototype.getVersion=function() {return this._version;};BiBrowserCheck.prototype.getPlatform=function() {return this._platform;};var _br=new BiBrowserCheck;BiBrowserCheck.ie=_br.getIe();BiBrowserCheck.ie55=_br.getIe55();BiBrowserCheck.ie6=_br.getIe6();BiBrowserCheck.moz=_br.getMoz();BiBrowserCheck.version=_br.getVersion();BiBrowserCheck.platform=_br.getPlatform();_br=null;function BiUri(sBase,sRel) {this._params={};if(sBase) {this.setHref(sBase);if(sRel) this._setRelative(sRel)}} _p=BiUri.prototype=new BiObject;_p._className="BiUri";_p._scheme="";_p._userInfo="";_p._port="";_p._host="";_p._path="";_p._dirPath="";_p._fragment="";_p._query="";_p._hrefCache=null;BiUri.prototype.getScheme=function(){return this._scheme;};BiUri.prototype.getPath=function(){return this._path;};BiUri.prototype.getDirPath=function(){return this._dirPath;};BiUri.prototype.getHost=function(){return this._host;};BiUri.prototype.getPort=function(){return this._port;};BiUri.prototype.getFragment=function(){return this._fragment;};BiUri.prototype.getQuery=function(){return this._query;};BiUri.prototype.getUserInfo=function(){return this._userInfo;};BiUri.regExps={scheme:/^([^:]+)\:.+$/,user:/^([^@\/]+)@.+$/,host:/^([^:\/\?\#]+).*$/,port:/^:(\d+)/,path:/^([^\?#]*)/,dirPath:/^(.*\/)[^\/]*$/,fragment:/^[^#]*#(.*)$/,absUri:/^\w(\w|\d|\+|\-|\.)*:/i};_p.toString=function() {return this.getHref();};_p.setHref=function(s) {this._hrefCache=null;s=String(s);this._scheme="";this._userInfo="";this._host="";this._port=null;this._path="";this._dirPath="";this._query="";this._fragment="";this._params={};var err=new Error("Not a well formatted URI");var ok=BiUri.regExps.scheme.test(s);if(!ok)throw err;this._scheme=RegExp.$1;if(this._scheme=="mailto"||this._scheme=="news"||this._scheme=="view-source") s=s.substring(this._scheme.length+1);else s=s.substring(this._scheme.length+3);ok=BiUri.regExps.user.test(s);if(ok) {this._userInfo=RegExp.$1;s=s.substring(this._userInfo.length+1);} if(this._scheme!="file"||s.charAt(0)!="/") {ok=BiUri.regExps.host.test(s);if(!ok) throw err;this._host=RegExp.$1;s=s.substring(this._host.length);} ok=BiUri.regExps.port.test(s);if(ok) {this._port=Number(RegExp.$1);s=s.substring(RegExp.$1.length+1);} this._parsePathAndRest(s);};_p._parsePathAndRest=function(s) {var err=new Error("Not a well formatted URI");var ok=BiUri.regExps.path.test(s);if(!ok) throw err;this._path=RegExp.$1;s=s.substring(this._path.length);if(this._path==""&&(this._scheme=="file"||this._scheme=="http"||this._scheme=="https"||this._scheme=="ftp")) {this._path="/";} var segments=this._path.split("/");var sb=[];var j=0;for(var i=0;i<segments.length;i++) {if(segments[i]==".") continue;if(segments[i]=="..") {j--;delete sb[j];sb.length=j continue;} sb[j++]=segments[i];} this._path=sb.join("/");if(this._path.length>0) {ok=BiUri.regExps.dirPath.test(this._path);if(!ok) throw err;this._dirPath=RegExp.$1;} ok=BiUri.regExps.fragment.test(s);if(ok) {this._fragment=RegExp.$1;s=s.substring(0,s.length-this._fragment.length-1);this._fragment="#"+this._fragment.replace("#","%23");} this._query=s;s=s.substring(1);if(this._query!="") {var pairs=s.split(/\;|\&/);var parts;for(var i=0;i<pairs.length;i++) {parts=pairs[i].split("=");if(parts.length==2) this._params[parts[0]]=decodeURIComponent(parts[1]);else this._params[pairs[i]]=null;}}};_p._setRelative=function(s) {this._hrefCache=null;s=String(s);var isAbsolute=BiUri.regExps.absUri.test(s);if(isAbsolute) {this.setHref(s);return;} var dirPath=this._dirPath;this._path="";this._dirPath="";this._query="";this._fragment="";this._params={};if(s.charAt(0)=="/") {this._parsePathAndRest(s)} else this._parsePathAndRest(dirPath+s);};_p.getHref=function() {if(this._hrefCache!=null) return this._hrefCache;var s=this._scheme+(this._scheme=="mailto"||this._scheme=="news"||this._scheme=="view-source"?":":"://")+this._userInfo+(this._userInfo==""?"":"@")+this._host+(this._port!=null?":"+this._port:"")+this._path;var sb=[];for(var name in this._params) {if(this._params[name]!=null) sb.push(name+"="+encodeURIComponent(this._params[name]));else sb.push(name);} return this._hrefCache=s+this.getQuery()+this._fragment;};_p.getParam=function(sName) {return this._params[sName];};_p.setParam=function(sName,sValue) {this._hrefCache=null;return this._params[sName]=String(sValue);};_p.removeParam=function(sName) {this._hrefCache=null;delete this._params[sName];};_p.getQuery=function() {var sb=[];for(var name in this._params) {if(this._params[name]!=null) sb.push(name+"="+encodeURIComponent(this._params[name]));else sb.push(name);} return(sb.length>0?"?"+sb.join("&"):"");};function BiEvent(sType) {BiObject.call(this);this._type=sType;} _p=BiEvent.prototype=new BiObject;_p._className="BiEvent";_p._bubbles=false;_p._propagationStopped=true;_p._defaultPrevented=false;BiEvent.prototype.getType=function(){return this._type;};BiEvent.prototype.getTarget=function(){return this._target;};BiEvent.prototype.getCurrentTarget=function(){return this._currentTarget;};BiEvent.prototype.getBubbles=function(){return this._bubbles;};_p.initDispatch=function(){};_p.stopPropagation=function() {this._propagationStopped=true;};_p.preventDefault=function() {this._defaultPrevented=true;};_p.dispose=function() {this._target=null;this._currentTarget=null;};_p.getDefaultPrevented=function() {return this._defaultPrevented;};function BiMouseEvent(){};function BiKeyboardEvent(){};application=new BiApplication;application._coreScriptFiles_ie=["js/coreclasses.js","js/xmlrpc.js","js/guicomponents.js","js/gauge.ie.js","js/menu.ie.js","js/window.js","js/grids.js","js/databinding.js","js/chartingbase.js","js/charting.js","js/charting2.js","js/datetime.js"];application._coreScriptFiles_moz=["js/coreclasses.js","js/xmlrpc.js","js/guicomponents.js","js/menu.moz.js","js/window.js","js/grids.js","js/databinding.js","js/chartingbase.js","js/charting2.js","js/datetime.js"];if(BiBrowserCheck.ie) application._coreScriptFiles=application._coreScriptFiles_ie;else application._coreScriptFiles=application._coreScriptFiles_moz; //--> </textarea></div> <img src="/_New/_cj/myeditor/sysimage/space.gif" class="ewebeditor__script" _ewebeditor_fake_tag="script" _ewebeditor_fake_value="%3CSCRIPT%20LANGUAGE%3D%22JavaScript%22%3E%20%0D%0A%3C!--%20%0D%0Avar%20tm_highlight%20%3D%20null%3B%20%0D%0Afunction%20_highlight()%20%0D%0A%7B%20%0D%0A%20%20%20%20clearTimeout(tm_highlight)%3B%20%0D%0A%20%20%20%20tm_highlight%20%3D%20setTimeout('document.getElementById(%22oResult%22).innerHTML%20%3D%20(%22%3Cnobr%3E%22%2Bdocument.getElementById(%22oTxt%22).value.formatJS()%2B%22%3C%2Fnobr%3E%22)%3B'%2C%201000)%3B%20%0D%0A%7D%20%0D%0A%2F%2FString.prototype.div%20%3D%20document.createElement('div')%3B%20%0D%0AString.prototype.toHtml%20%3D%20function%20()%20%7B%20%0D%0A%20%20%20%20return%20this%20%0D%0A%20%20%20%20.replace(%2F%5C%26%2Fg%2C%20'%26amp%3B')%20%0D%0A%20%20%20%20.replace(%2F%5C%3C%2Fg%2C%20'%26lt%3B')%20%0D%0A%20%20%20%20.replace(%2F%5C%3E%2Fg%2C%20'%26gt%3B')%20%0D%0A%20%20%20%20.replace(%2F%5Cx20%2Fg%2C%20'%26nbsp%3B')%20%0D%0A%20%20%20%20.replace(%2F(%5Cr%5Cn%7C%5Cr%7C%5Cn)%2Fg%2C%20'%0D%0A')%3B%20%0D%0A%7D%3B%20%0D%0AString.prototype.formatJS%20%3D%20function%20()%20%0D%0A%7B%20%0D%0A%20%20%20%20var%20s%20%3D%20this%3B%20%0D%0A%20%20%20%20var%20index%20%3D%200%2C%20brch%3D0%3B%20%0D%0A%20%20%20%20var%20keywords%20%3D%20%5B'abstract'%2C'boolean'%2C'break'%2C'byte'%2C'case'%2C'catch'%2C'char'%2C'class'%2C'const'%2C'continue'%2C'default'%2C'delete'%2C'do'%2C'double'%2C'else'%2C'extends'%2C'false'%2C'final'%2C'finally'%2C'float'%2C'for'%2C'function'%2C'goto'%2C'if'%2C'implements'%2C'import'%2C'in'%2C'instanceof'%2C'int'%2C'interface'%2C'long'%2C'native'%2C'new'%2C'null'%2C'package'%2C'private'%2C'protected'%2C'public'%2C'return'%2C'short'%2C'static'%2C'super'%2C'switch'%2C'synchronized'%2C'this'%2C'throw'%2C'throws'%2C'transient'%2C'true'%2C'try'%2C'typeof'%2C'var'%2C'void'%2C'while'%2C'with'%5D%3B%20%0D%0A%20%20%20%20var%20objects%20%3D%20%5B'Anchor'%2C'anchors'%2C'Applet'%2C'applets'%2C'Area'%2C'Array'%2C'arguments'%2C'Button'%2C'Checkbox'%2C'Date'%2C'document'%2C'FileUpload'%2C'Form'%2C'forms'%2C'Frame'%2C'frames'%2C'Function'%2C'Hidden'%2C'history'%2C'Image'%2C'images'%2C'Link'%2C'links'%2C'Area'%2C'location'%2C'Math'%2C'MimeType'%2C'mimeTypes'%2C'navigator'%2C'options'%2C'Password'%2C'Plugin'%2C'plugins'%2C'Radio'%2C'Reset'%2C'RegExp'%2C'Select'%2C'String'%2C'Submit'%2C'Text'%2C'Textarea'%2C'window'%5D%3B%20%0D%0A%20%20%20%20var%20specials%20%3D%20%5B'prototype'%2C'callee'%2C'caller'%2C'apply'%2C'call'%2C'encodeURIComponent'%2C'decodeURIComponent'%2C'parseInt'%2C'parseFloat'%2C'__defineGetter__'%2C'__defineSetter__'%5D%3B%20%0D%0A%20%20%20%20var%20blocks%20%3D%20%5B%5D%3B%20%0D%0A%20%20%20%20var%20indent%20%3D%20%22%22%2C%20indent_fix%3D%22%22%3B%20%0D%0A%20%20%20%20s%3Ds%20%0D%0A%20%20%20%20.replace(%2F%5Ct%2Fg%2C%20'%20%20%20%20')%20%0D%0A%20%20%20%20.replace(%2F%5Cr%5Cn%7C%5Cr%2Fg%2C%20%22%5Cn%22)%20%0D%0A%20%20%20%20.replace(%2F(%5C%2F%5C%2F%5B%5E%5Cn%5D*(%5Cn%7C%24)%7C%5C%2F%5C*(%5C*(%3F!%5C%2F)%7C%5B%5E%5C*%5D)*%5C*%2B%5C%2F%7C%5C%22(%5C%5C%5C%22%7C%5C%5C%5C%5C%7C%5B%5E%5C%22%5Cn%5D)*%5C%22%7C%5C'(%5C%5C%5C'%7C%5C%5C%5C%5C%7C%5B%5E%5C'%5Cn%5D)*%5C'%7C(%5B%3D!%5C(%5C%3A%5C%7B%5C%5B%5C%3B%5D%5Cs*)%5C%2F(%5C%5C.%7C%5B%5E%5C%2F%5Cn%5D)%2B%5C%2F%5Bigm%5D*)%2Fg%2C%20%0D%0A%20%20%20%20%20%20%20%20function%20(%240)%20%0D%0A%20%20%20%20%20%20%20%20%7B%20%0D%0A%20%20%20%20%20%20%20%20%20%20%20%20var%20color%20%3D%20%22%23CCCCCC%22%2C%20ret%20%3D%20%22'%22%3B%20%2F%2F%20comment%20%0D%0A%20%20%20%20%20%20%20%20%20%20%20%20var%20kkk%20%3D%20%240%3B%20%0D%0A%20%20%20%20%20%20%20%20%20%20%20%20if(kkk.charAt(0)%20%3D%3D%20'%22')%20%0D%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20color%20%3D%20%22%23FF00FF%22%3B%20%2F%2F%20double%20quote%20%0D%0A%20%20%20%20%20%20%20%20%20%20%20%20else%20if(kkk.charAt(0)%20%3D%3D%20%22'%22)%20%0D%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20color%20%3D%20%22%239900FF%22%3B%20%2F%2F%20single%20quote%20%0D%0A%20%20%20%20%20%20%20%20%20%20%20%20else%20if(kkk.match(%2F%5E(%3F%3A%5B%3D!%5C(%5C%3A%5C%7B%5C%5B%5D%5Cs*)(%5C%2F(%5C%5C.%7C%5B%5E%5C%2F%5Cn%5D)%2B%5C%2F%5Bigm%5D*%24)%2F))%20%0D%0A%20%20%20%20%20%20%20%20%20%20%20%20%7B%20%0D%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20ret%20%3D%20kkk.replace(%2F%5E(%5B%3D!%5C(%5C%3A%5C%7B%5C%5B%5D%5Cs*)(%5C%2F(%5C%5C.%7C%5B%5E%5C%2F%5Cn%5D)%2B%5C%2F%5Bigm%5D*%24)%2F%2C%20%22%241'%22)%3B%20%0D%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20kkk%20%3D%20kkk.replace(%2F%5E(%5B%3D!%5C(%5C%3A%5C%7B%5C%5B%5D%5Cs*)(%5C%2F(%5C%5C.%7C%5B%5E%5C%2F%5Cn%5D)%2B%5C%2F%5Bigm%5D*%24)%2F%2C%20%22%242%22)%3B%20%0D%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20color%20%3D%20%22%236666CC%22%3B%20%2F%2F%20regexp%20%0D%0A%20%20%20%20%20%20%20%20%20%20%20%20%7D%20%0D%0A%20%20%20%20%20%20%20%20%20%20%20%20blocks%5Bblocks.length%5D%20%3D%20%22%3Cfont%20color%3D%22%2Bcolor%2B%22%3E%22%2Bkkk.toHtml()%2B%22%3C%2Ffont%3E%22%3B%20%0D%0A%20%20%20%20%20%20%20%20%20%20%20%20return%20ret%3B%20%0D%0A%20%20%20%20%20%20%20%20%7D)%20%0D%0A%2F%2F%20%20%20%20alert(blocks)%3Bs%3Ds%20%0D%0A%20%20%20%20.replace(%2F(%5C%7D%3F%5B%5Cn%20%5D*%3B%5B%5Cn%20%5D*)%2Fg%2C%20function%20(%240%2C%241)%7Breturn%20%241.replace(%2F%5B%5Cn%20%5D%2Fg%2C%20'')%2B%22%5Cn%22%3B%7D)%20%0D%0A%20%20%20%20.replace(%2F%5Cb(else)%5Cb%2Fg%2C%20%22%241%5Cn%22)%20%0D%0A%20%20%20%20.replace(%2F%5Cb((case%7Cdefault)%5B%5E%3A%5D*%5C%3A)%2Fg%2C%20%22%241%5Cn%22)%20%0D%0A%20%20%20%20.replace(%2F(%5C%7B%5B%5Cn%20%5D*)(((%5BA-Za-z%5C%24%5C_%5D%5B0-9A-Za-z%5C%24%5C_%5D*%7C%60)%5B%5Cn%20%5D*%5C%3A%5B%5Cn%20%5D*%5B%5E%2C%5C%7D%5D%2B%2C%3F)%2B)(%5B%5Cn%20%5D*%5C%7D)%2Fg%2C%20function%20(%240%2C%241%2C%242%2C%243%2C%244%2C%245)%20%0D%0A%20%20%20%20%20%20%20%20%7B%20%0D%0A%20%20%20%20%20%20%20%20%20%20%20%20return%20%241%2B%242.replace(%2F%5B%5Cn%20%5D%2B%2Fg%2C%20'%20').replace(%2F((%5BA-Za-z%5C%24%5C_%5D%5B0-9A-Za-z%5C%24%5C_%5D*%7C%60)%5C%3A%5B%5E%2C%5C%7D%5D%2B%2C%3F)%2Fg%2C%20%22%241%5Cn%22)%2B%245%3B%20%0D%0A%20%20%20%20%20%20%20%20%7D)%20%0D%0A%20%20%20%20.replace(%2F%5B%5Cn%20%5D*(%5C%7B%7C%5C%7D%3B%3F)%5B%5Cn%20%5D*%2Fg%2C%20function%20(%240%2C%20%241)%20%0D%0A%20%20%20%20%20%20%20%20%7B%20%0D%0A%20%20%20%20%20%20%20%20%20%20%20%20if(%241.charAt(0)%20%3D%3D%20'%7D')%20brch--%3B%20%0D%0A%20%20%20%20%20%20%20%20%20%20%20%20var%20ss%20%3D%20%22%5Cn%22%3B%20%0D%0A%20%20%20%20%20%20%20%20%20%20%20%20for(var%20i%3D0%3Bi%3Cbrch%3Bi%2B%2B)%20ss%20%2B%3D%20%22%20%20%20%20%22%3B%20%0D%0A%20%20%20%20%20%20%20%20%20%20%20%20if(%241%20%3D%3D%20'%7B')%20brch%2B%2B%3B%20%0D%0A%20%20%20%20%20%20%20%20%20%20%20%20return%20ss%2B%241%2B%22%5Cn%22%3B%20%0D%0A%20%20%20%20%20%20%20%20%7D)%20%0D%0A%20%20%20%20.replace(%2F%5B%5Cn%20%5D*%5C%7B%5B%5Cn%20%5D*%5C%7D%2Fg%2C%20'%7B%7D')%20%0D%0A%20%20%20%20.replace(%2F%5E%5B%20%5D*(%5B%5E%5C%7B%5C%7D%5D)%2Fg%2C%20%22%241%22)%20%0D%0A%20%20%20%20.replace(%2F(%5Cn%5Cs*for%5Cb%5B%5E%5Cn%5D*%5C%3B%5Cs*)%5Cn%2Fg%2C%20'%241')%20%0D%0A%20%20%20%20.replace(%2F(%5Cn%5Cs*for%5Cb%5B%5E%5Cn%5D*%5C%3B%5Cs*)%5Cn%2Fg%2C%20'%241')%20%0D%0A%20%20%20%20.replace(%2F%5Cn%5Cs*(for%7Cwhile%7Cif%7Cswitch)%5Cb%5B%5E%5Cn%5D*%3B%20*%5Cn%2Fg%2C%20function%20(%240%2C%20%241)%20%0D%0A%20%20%20%20%20%20%20%20%7B%20%0D%0A%20%20%20%20%20%20%20%20%20%20%20%20var%20le%20%3D%200%3B%20%0D%0A%20%20%20%20%20%20%20%20%20%20%20%20for(var%20i%3D0%3Bi%3C%240.length%3Bi%2B%2B)%20%0D%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20if(%240.charAt(i)%20%3D%3D%20'(')%20le%2B%2B%3B%20else%20if(%240.charAt(i)%20%3D%3D%20')')%7Ble--%3B%20if(le%20%3D%3D%200)return%20%240.substr(0%2Ci%2B1)%2B%22%5Cn%22%2B%240.substr(i%2B1%2C%240.length)%3B%7D%20%0D%0A%20%20%20%20%20%20%20%20%7D)%20%0D%0A%20%20%20%20.replace(%2F(%5Cn%20*)*(%5Cn%20*)%2Fg%2C%20%22%242%22)%20%0D%0A%20%20%20%20.replace(%2F(%60%5Cs*)%5C%2B(%3F%3D%5Cs*%60)%2Fg%2C%20%22%241%5Cn%2B%22)%20%0D%0A%20%20%20%20.replace(%2F(%20*)(%5B%5E%5Cn%5D*)%5Cn%2Fg%2C%20function%20(%240%2C%20space%2C%20text)%20%0D%0A%20%20%20%20%20%20%20%20%7B%20%0D%0A%20%20%20%20%20%20%20%20%20%20%20%20var%20ret%20%3D%20%240%3B%20%0D%0A%20%20%20%20%20%20%20%20%20%20%20%20if(text.match(%2F%5E%5C%7B%2F))%20%0D%0A%20%20%20%20%20%20%20%20%20%20%20%20%7B%20%0D%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20indent%20%3D%20space%2B%22%20%20%20%20%22%3B%20%0D%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20indent_fix%20%3D%20%22%22%3B%20%0D%0A%20%20%20%20%20%20%20%20%20%20%20%20%7D%20%0D%0A%20%20%20%20%20%20%20%20%20%20%20%20else%20if(text.match(%2F%5E%5C%7D%2F))%20%0D%0A%20%20%20%20%20%20%20%20%20%20%20%20%7B%20%0D%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20indent%20%3D%20space%3B%20%0D%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20indent_fix%20%3D%20%22%22%3B%20%0D%0A%20%20%20%20%20%20%20%20%20%20%20%20%7D%20%0D%0A%20%20%20%20%20%20%20%20%20%20%20%20else%20%0D%0A%20%20%20%20%20%20%20%20%20%20%20%20%7B%20%0D%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20if(text.match(%2F%5E(case%7Cdefault)%5Cb%2F))%20%0D%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20ret%20%3D%20indent.substr(0%2Cindent.length-4)%20%2B%20text%3B%20%0D%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20else%20%0D%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20ret%20%3D%20indent%20%2B%20indent_fix%20%2B%20text%3B%20%0D%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20if(text.match(%2F%5E(if%7Cfor%7Celse%7Cvar%7Cwhile)%5Cb%2F)%20%26%26%20!text.match(%2F%5C%3B%5Cs*%24%2F))%20%0D%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20indent_fix%20%3D%20%22%20%20%20%20%22%3B%20%0D%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20else%20if(!text.match(%2F%5B%5E%5C%3B%5D%5Cs*%24%2F))%20%0D%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20indent_fix%20%3D%20%22%22%3B%20%0D%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20if(text.charAt(0)%3D%3D'%2B')%20%0D%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20ret%20%3D%20%22%20%20%20%20%22%2Bret%3B%20%0D%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20ret%20%2B%3D%20%22%5Cn%22%3B%20%0D%0A%20%20%20%20%20%20%20%20%20%20%20%20%7D%20%0D%0A%20%20%20%20%20%20%20%20%20%20%20%20return%20ret%3B%20%0D%0A%20%20%20%20%20%20%20%20%7D)%20%0D%0A%20%20%20%20.replace(%2F%5C%26%2Fg%2C%20'%26amp%3B')%20%0D%0A%20%20%20%20.replace(%2F%5C%3C%2Fg%2C%20'%26lt%3B')%20%0D%0A%20%20%20%20.replace(%2F%5C%3E%2Fg%2C%20'%26gt%3B')%20%0D%0A%20%20%20%20.replace(%2F%5Cx20%2Fg%2C%20'%26nbsp%3B')%20%0D%0A%20%20%20%20.replace(eval('%2F%5C%5Cb('%2Bkeywords.join('%7C')%2B')%5C%5Cb%2Fg')%2C'%3Cfont%20color%3Dblue%3E%241%3C%2Ffont%3E')%20%2F%2F%20keywords%20%0D%0A%20%20%20%20.replace(eval('%2F%5C%5Cb('%2Bobjects.join('%7C')%2B')%5C%5Cb%2Fg')%2C'%3Cfont%20color%3Dred%3E%241%3C%2Ffont%3E')%20%2F%2F%20objects%20%0D%0A%20%20%20%20.replace(eval('%2F%5C%5Cb('%2Bspecials.join('%7C')%2B')%5C%5Cb%2Fg')%2C'%3Cfont%20color%3D%230099CC%3E%241%3C%2Ffont%3E')%20%2F%2F%20objects%20%0D%0A%20%20%20%20.replace(%2F%5Cn%2Fg%2C%20'%0D%0A')%20%0D%0A%20%20%20%20.replace(%2F%5C'%2Fg%2C%20function%20(%240)%7Breturn%20blocks%5Bindex%2B%2B%5D%3B%7D)%3B%20%0D%0A%20%20%20%20return%20s%3B%20%0D%0A%7D%20%0D%0Atm_highlight%20%3D%20setTimeout('document.getElementById(%22oResult%22).innerHTML%20%3D%20(%22%3Cnobr%3E%22%2Bdocument.getElementById(%22oTxt%22).value.formatJS()%2B%22%3C%2Fnobr%3E%22)%3B'%2C%201)%3B%20%0D%0A%2F%2F--%3E%20%0D%0A%3C%2FSCRIPT%3E"> <hr style="color:black;height:2px;"> <div id="oResult" style="width:100%;height:164px;padding:0;margin:0;border: dashed 1px gray;border-right:solid 2px gray;border-bottom:solid 2px gray;" contentEditable> </div> </BODY> </HTML>
[Ctrl+A 全选 注:
如需引入外部Js需刷新才能执行
]
教程首页
更多教程