asp.net页面详细执行流程

asp.net页面从请求到呈现给用户的过程

1. BeginRequest
2. AuthenticateRequest
3. PostAuthenticateRequest
4. AuthorizeRequest
5. PostAuthorizeRequest
6. ResolveRequestCache
7. PostResolveRequestCache
8. PostMapRequestHandler
9. AcquireRequestState
10. PostAcquireRequestState
11. PreRequestHandlerExecute
12. At this stage, the selected handler executes the current request. The most familiar handler is the Page handler.
13. PostRequestHandlerExecute
14. ReleaseRequestState
15. PostReleaseRequestState
16. UpdateRequestCache
17. PostUpdateRequestCache
18. EndRequest

其中第12步,具体的页面执行流程,分为如下步骤:

Page.OnPreInit
MasterPageControl.OnInit (for each control on the master page)
Control.OnInit (for each contol on the page)
MasterPage.OnInit
Page.OnInit
Page.OnInitComplete
Page.OnPreLoad
Page.OnLoad
MasterPage.OnLoad
MasterPageControl.OnLoad (for each control on the master page)
Control.OnLoad (for each contol on the page)
Page.OnXXX (control event)
MasterPage.OnBubbleEvent
Page.OnBubbleEvent
Page.OnLoadComplete
Page.OnPreRender
MasterPage.OnPreRender
MasterPageControl.OnPreRender (for each control on the master page)
Control.OnPreRender (for each contol on the page)
Page.OnPreRenderComplete
MasterPageControl.SaveControlState (for each control on the master page)
Control.SaveControlState (for each contol on the page)
Page.SaveViewState
Page.SavePageStateToPersistenceMedium
Page.OnSaveStateComplete
MasterPageControl.OnUnload (for each control on the master page)
Control.OnUnload (for each contol on the page)
MasterPage.OnUnload
Page.OnUnload

IE8上传文件时javascript取文件的本地路径的问题C:\fakepath\

前几天把IE升级到了IE8,没想到一个网站里面的上传图片时用JavaScript预览本地图片的功能失效了,图片总是显示错误,看了下图片的路径居然变成了C:\fakepath\xxx.gif,真实的路径被C:\fakepath\取代了,原来是因为IE8增加了安全选项,默认情况下不显示上传文件的真实路径,进入internet选项,修改下设置即可显示真实的文件路径。

工具 -> Internet选项 -> 安全 -> 自定义级别 -> 将本地文件上载至服务器时包含本地目录路径,选中启用即可。

ie8 fakepath

javascript判断浏览器是不是IE6

一个项目中要判断浏览器是不是IE6,用jQuery的utility里面的方法$.browser.version判断居然总是显示是IE6,但我用的明明是IE7(我的操作系统是server2003,$.browser.version在window6.0的系统上总是返回6.0,算是bug吧),最后没有办法只好用下面蹩脚的方法判断了,把下面的代码加在页面里就可以判断是不是IE6,当然稍加修改也可以用来判断是不是IE7、IE8。firefox可以用其它方法判断。

var isIE6=false;
document.write("<!--[if lte IE 6]><script>isIE6=true;</scr"+"ipt><![endif]-->");
if(isIE6){
	alert('你当前的浏览器是IE6或者以下');
}

附上另外一个判断方法:

if(window.XMLHttpRequest){ //Mozilla, Safari, IE7
	if(!window.ActiveXObject){ // Mozilla, Safari,
		alert('Mozilla, Safari');
	}else{
		alert('IE7');
	}
}else {
	alert('IE6');
}

附上其它的判断浏览器的语句

1. <!--[if !IE]><!--> 除IE外都可识别 <!--<![endif]-->
2. <!--[if IE]> 所有的IE可识别 <![endif]-->
3. <!--[if IE 5.0]> 只有IE5.0可以识别 <![endif]-->
4. <!--[if IE 5]> 仅IE5.0与IE5.5可以识别 <![endif]-->
5. <!--[if gte IE 5.0]> IE5.0以及IE5.0以上版本都可以识别 <![endif]-->
6. <!--[if IE 6]> 仅IE6可识别 <![endif]-->
7. <!--[if lte IE 6]> IE6以及IE6以下版本可识别 <![endif]-->
8. <!--[if gte IE 6]> IE6以及IE6以上版本可识别 <![endif]-->
9. <!--[if IE 7]> 仅IE7可识别 <![endif]-->
10. <!--[if lte IE 7]> IE7以及IE7以下版本可识别 <![endif]-->
11. <!--[if gte IE 7]> IE7以及IE7以上版本可识别 <![endif]-->

zblog的编辑器上的代码高亮让我抓狂

重新安装的zblog居然给文字加色和加背景色都没有效果,想插入一段html或javascript代码也让我无从下手,在提供的插件里下了个highlight,质量太差了,使用了之后格式化的代码难看不说,还提示javascript错误,不知道怎么就放出来了给zblog用户下载,在zblog论坛上下载了一个代码高亮的插件,安装后在编辑器里面使用让我抓狂,换到源代码编辑模式把html代码粘上去,在换到正常模式,代码里面的换行都不见了,这样代码高亮也是一点用处都没有了,代码都到一行了,而且一看网页源码的,那个代码高亮居然一口气加载了七八个js文件,严重影响网页下载速度,实在没办法了,所有的代码高亮插件全部删掉,还是用fck的代码高亮插件解决了,虽说不算完美,因为在生成的日志里面,复制的代码仍然不能换行!

非常酷的jquery弹框插件:FancyBox

一个外国人写的jquery弹框插件,看他网站的alexa排名真高,应该是非常有名的弹框插件了。插件网站地址:http://fancy.klade.lv/home google code上的源码地址:http://code.google.com/p/fancybox/downloads/detail?name=jquery.fancybox-1.2.1.zip

可以弹出如下内容的窗口(注意:所有的触发弹框的dom必须是A这个标签,而且a中必须带有href属性,感觉有点局限性)

1、单个图片,(href属性就是一个图片的地址了,而且地址必须满足这个正则:/\.(jpg|gif|png|bmp|jpeg)(.*)?$/i,也就是必须是图片扩展名结尾的地址,这个限制太死了,不知道作者是怎么想的);

2、一组图片,就是一个相册展示(和1差不多,但这组A中必须都有一个rel属性,而且所有的A的rel必须相同);

3、弹出一个Dom的内容(href属性这样写:href=”#domid”,domid就是要弹出的dom的id;

4、用iframe显示一个链接,(href属性中必须带有iframe字样,或者有个叫iframe的class,不然是弹不出这个链接的内容的);

5、用ajax请求一个连接的内容,然后显示,(href是一个可访问的链接即可,当然不要出现iframe字样,^_^);

就这几种弹出的方式了,差不多可以满足平常的需求。

附上使用插件的方法和初始化的配置项:

1. Include nessesary JS files
<script type="text/javascript" src="path-to-file/jquery.js"></script>
<script type="text/javascript" src="path-to-file/jquery.fancybox.js"></script>

Optional, add if you wish to use fancy transitions as jQuery by default supports only “swing” and “linear”
<script type="text/javascript" src="path-to-file/jquery.easing.js"></script>

2. Add FancyBox CSS file
Don`t forget to change image paths if CSS file is not in the same directory as images used by FancyBox
<link rel="stylesheet" href="path-to-file/fancybox.css" type="text/css" media="screen">

3. Create a link element (<a href>)

For images
<a id="single_image" href="image_big.jpg"><img src="image_small.jpg" alt=""/></a>

Inline content
<a id="inline" href="#data">This shows content of element who has id="data"</a>

Iframe
<a href="http://www.example?iframe">This goes to iframe</a> or <a class="iframe" href="http://www.example">This goes to iframe</a>

Ajax <a href="http://www.example/data.php">This takes content using ajax</a>

Optional: Use the title attribute if you want to show a caption
Note: You may want to set hideOnContentClick to false if you display iframed or inline content and it containts clickable elements (for example – play buttons for movies, links to other pages)

4. Fire plugin using jQuery selector
If you are not familiar with jQuery, please, read at least this tutorial for beginners
Sample examples: $(document).ready(function() { /* This is basic - uses default settings */ $("a#single_image").fancybox(); /* Using custom settings */ $("a#inline").fancybox({ 'hideOnContentClick': true }); $("a.group").fancybox({ 'zoomSpeedIn': 300, 'zoomSpeedOut': 300, 'overlayShow': false }); });
Galleries are created from found anchors who have the same “rel” tags

Available options

You can pass them as shown above or modify them at the bottom of FancyBox JS file

padding Padding around content
imageScale If true, images are scaled to fit in viewport
zoomOpacity If true, changes content transparency when animating
zoomSpeedIn Speed in miliseconds of the zooming-in animation
(no animation if 0)
zoomSpeedOut Speed in miliseconds of the zooming-out animation
(no animation if 0)
zoomSpeedChange Speed in miliseconds of the animation when changing gallery items
(no animation if 0)
easingIn, easingOut, easingChange Easing used for animations
frameWidth Default width for iframed and inline content
frameHeight Default height for iframed and inline content
overlayShow If true, shows the overlay (false by default)
Overlay color is defined in CSS file
overlayOpacity Opacity of overlay (from 0 to 1)
hideOnContentClick Hides FancyBox when cliked on opened item
centerOnScroll If true, content is centered when user scrolls page
itemArray Optional, can set custom item array
callbackOnStart Optional, called on start
callbackOnShow Optional, called on displaying content
callbackOnClose Optional, called on close

转一个作者网站上的常见问答:

4. How can I close FancyBox from other element? ?

Just call $.fn.fancybox.close() on your onClick event

动态加载javascript文件

Only for IE

/*Javascript 动态加载*/
var loadJS, loadjs;
loadJS=loadjs=function(src,id,callback){
	var scriptId = document.getElementById(id);
	if (scriptId){
		if(callback) callback();
	}else{
		var s = document.createElement("script");
		s.id = id;
		s.type = "text/javascript";
		s.src = src;
		s.onload = s.onreadystatechange = function(){
			if (s.readyState && s.readyState != 'loaded' && s.readyState != 'complete'){
				return;
			}
			s.onreadystatechange = s.onload = null;
			//当前文件加载完毕,触发回调事件
			if (callback) callback();
		};
		var head = document.getElementsByTagName('head').item(0);
		head.appendChild (s);
	}
}
loadJS("http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js", "jquery", function(){alert($("#sdf").length);});

(转)Firefox中Iframe的blur与focus事件问题

最近在做一个网站的HTML文章发布功能,用到了HTML编辑器,这个是以Iframe为基础的编辑器(貌似网上大多的都是用iframe 的)。却发现一个问题,IE下运行得好好的,在Firefox里却始终不能提交更新后的数据到服务器上,找了半天原因才发现原来是在iframe的 onblur事件里面调了更新数据内容的方法,但firefox下却没有执行。GOOGLE,发现了一个老外写的如下代码:

<script>
	function setit(){
		if(document.all){
			document.getElementById("myframe").attachEvent("onblur",dothis);
		}else{
			document.getElementById("myframe").contentWindow.addEventListener("blur",dothis,false);
		}
	}

	function dothis(){
		alert("blurred");
	}
</script>

<body onload="setit()">
	<iframe width="155" height="144" id="myframe"></iframe>
	<input />
</body>

试了一下果真可以直接触发,效果跟在IE下的一样。回过头去分析了一下代码,发现firefox中原来iframe上的事件挂到了iframe中的 contentWindow中去了,与真接在html元素里面写事件属性相比,IE可能把iframe上的事件关联到了contentWindow上了, 可firefox却不是这样的,还是各是各的。这样带来的问题是firefox想要给iframe加事件只能够用脚本去加了。
本来以为IE和firefox中对iframe的事件这部分定义不一样,回头去再去看看了HTML4.0中关于iframe的定义,果真是 iframe上面就没有任何事件的定义,看来是IE顺手给加上的。firefox号称最符合html标准,那么写在iframe上的“事件”没有任何响 应,自然也是合情合理的。DHTML手册上有一句话,由于没有“window”元素,body 元素将作为下列 window 对象事件的宿主:onblur, onbeforeunload, onfocus, onload 和 onunload。可HTML4.0里面body是有这两个事件的,所以也就不难解释为什么用脚本给iframe的contentWindow挂上事件就可以触发了,实际上这个事件是来自于contentWindow里面的body元素。

Ajax操作中维持历史记录

进行了一个ajax操作后,如何才能在浏览器的历史记录里显示呢,IE里可以通过放一个隐藏的iframe,改变iframe的location或者dom内容即可在history里面显示记录,firefox中就比较简单了,只需改变页面地址就可以产生一条历史记录,如在url后面加#XXX,

轻松去掉flash中的右键菜单

在flash父容器里hack:firefox下阻止mousedown默认事件及事件传播;IE下给父容器setCapture。JavaScript脚本如下:

function NoRightClick(pid){//pid:flash’s parentNode id  说明:flash父容器的id
 
var el = document.getElementById(pid);
 
if(el.addEventListener){
 
el.addEventListener("mousedown",function(event){
  
if(event.button == 2){
    
event.stopPropagation(); //for firefox
    
event.preventDefault()//for chrome
  
}
 
},true);
 
}else{
 
el.attachEvent("onmousedown",function(){
  
if(event.button == 2){
    
el.setCapture();
  
}
 
});
 
el.attachEvent("onmouseup",function(){
  
el.releaseCapture();
 
});
 
el.oncontextmenu = function(){
  
return false;
 
};
 
}
};
 
html页面中的代码如下:
<body>
 
<div id="testContent" style="width:800px">
 
</div>
 
<script type="text/javascript">
  var so = new SWFObject("test.swf", "t1", "800", "550", "9", "#000000");
  so.addParam("quality", "high");
  so.addParam("name", "t1");
  so.addParam("id", "t1");
  so.addParam("algin", "middle");
  so.addParam("AllowScriptAccess", "sameDomain");
  so.addParam("menu", "false");
  so.addParam("wmode", "opaque");
  so.addParam("pluginspage", "http://www.adobe.com/go/getflashplayer");
  so.write("testContent");
 
  NoRightClick("testContent");
 
</script>
</body>

 

Javascript格式化工具,压缩工具

<SCRIPT language=JavaScript>

function CLASS_FORMAT(code){

    function Hashtable(){
        this._hash        = new Object();
        this.add        = function(key,value){
                            if(typeof(key)!="undefined"){
                                if(this.contains(key)==false){
                                    this._hash[key]=typeof(value)=="undefined"?null:value;
                                    return true;
                                } else {
                                    return false;
                                }
                            } else {
                                return false;
                            }
                        }
        this.remove        = function(key){delete this._hash[key];}
        this.count        = function(){var i=0;for(var k in this._hash){i++;} return i;}
        this.items        = function(key){return this._hash[key];}
        this.contains    = function(key){return typeof(this._hash[key])!="undefined";}
        this.clear        = function(){for(var k in this._hash){delete this._hash[k];}}

    }

    this._caseSensitive = true;

    this.str2hashtable = function(key,cs){

        var _key    = key.split(/,/g);
        var _hash    = new Hashtable();
        var _cs        = true;

        if(typeof(cs)=="undefined"||cs==null){
            _cs = this._caseSensitive;
        } else {
            _cs = cs;
        }

        for(var i in _key){
            if(_cs){
                _hash.add(_key[i]);
            } else {
                _hash.add((_key[i]+"").toLowerCase());
            }

        }
        return _hash;
    }

    this._codetxt        = code;

    if(typeof(syntax)=="undefined"){
        syntax = "";
    }

    this._deleteComment = false;

    this._caseSensitive = true;

    this._blockElement  = this.str2hashtable("switch,if,do,while,try,finally");

    this._function      = this.str2hashtable("function");

    this._isFor            = "for";

    this._choiceElement = this.str2hashtable("else,catch,while");

    this._beginBlock    = "{";
    this._endBlock      = "}";

    this._singleEyeElement = this.str2hashtable("var,new,return,else,delete,in,case,typeof");

    this._wordDelimiters= "  ,.?!;:\\/<>(){}[]\"'\r\n\t=+-|*%@#$^&";

    this._quotation     = this.str2hashtable("\",'");

    this._lineComment   = "//";

    this._escape        = "\\";

    this._commentOn        = "/*";

    this._commentOff    = "*/";

    this._rowEnd        = ";";
    this._in            = "in";

    this.isCompress     = false;
    this.style          = 0;
    this._tabNum        = 0;

    this.format = function() {
        var codeArr        = new Array();
        var word_index    = 0;
        var htmlTxt        = new Array();

        if(this.isCompress){
            this._deleteComment = true;
        }

        for (var i = 0; i < this._codetxt.length; i++) {
            if (this._wordDelimiters.indexOf(this._codetxt.charAt(i)) == -1) {
                if (codeArr[word_index] == null || typeof(codeArr[word_index]) == 'undefined') {
                    codeArr[word_index] = "";
                }
                codeArr[word_index] += this._codetxt.charAt(i);
            } else {
                if (typeof(codeArr[word_index]) != 'undefined' && codeArr[word_index].length > 0)
                    word_index++;
                codeArr[word_index++] = this._codetxt.charAt(i);
            }
        }

        var quote_opened                = false;
        var slash_star_comment_opened   = false;
        var slash_slash_comment_opened  = false;
        var line_num                    = 1;
        var quote_char                  = "";      

        var function_opened             = false;

        var bracket_open                = false;
        var for_open                    = false;

        for (var i=0; i <=word_index; i++){
            if(typeof(codeArr[i])=="undefined"||codeArr[i].length==0){
                continue;
            } else if(codeArr[i]==" "||codeArr[i]=="\t"){
                if(slash_slash_comment_opened||slash_star_comment_opened){
                    if(!this._deleteComment){
                        htmlTxt[htmlTxt.length] = codeArr[i];
                    }
                }
                if(quote_opened){
                        htmlTxt[htmlTxt.length] = codeArr[i];
                }
            } else if(codeArr[i]=="\n"){
            } else if (codeArr[i] == "\r"){
                slash_slash_comment_opened = false;
                quote_opened    = false;
                line_num++;
                if(!this.isCompress){
                    htmlTxt[htmlTxt.length] = "\r\n"+ this.getIdent();
                }
            } else if (!slash_slash_comment_opened&&!slash_star_comment_opened && !quote_opened &&this.isFunction(codeArr[i])){
                htmlTxt[htmlTxt.length] = codeArr[i]  + " ";
                function_opened = true;
            } else if (!slash_slash_comment_opened&&!slash_star_comment_opened && !quote_opened &&codeArr[i]==this._isFor){
                htmlTxt[htmlTxt.length] = codeArr[i];
                for_open = true;
            } else if (!slash_slash_comment_opened&&!slash_star_comment_opened && !quote_opened &&codeArr[i]=="("){
                bracket_open    = true;
                htmlTxt[htmlTxt.length] = codeArr[i];
            } else if (!slash_slash_comment_opened&&!slash_star_comment_opened && !quote_opened &&codeArr[i]==")"){
                bracket_open    = false;
                htmlTxt[htmlTxt.length] = codeArr[i];
            } else if (!slash_slash_comment_opened&&!slash_star_comment_opened && !quote_opened &&codeArr[i]==this._rowEnd){
                if(!this.isCompress){
                    if(!for_open){
                        if(i<word_index&&(codeArr[i+1]!="\r"&&codeArr[i+1]!="\n")){
                            htmlTxt[htmlTxt.length] = codeArr[i] + "\n" + this.getIdent();
                        }else{
                            htmlTxt[htmlTxt.length] = codeArr[i] + this.getIdent();
                        }
                    }else{
                        htmlTxt[htmlTxt.length] = codeArr[i];
                    }
                }else{
                    htmlTxt[htmlTxt.length] = codeArr[i];
                }
            } else if(!slash_slash_comment_opened&&!slash_star_comment_opened && !quote_opened &&codeArr[i]==this._beginBlock){
                for_open    = false;
                if(!this.isCompress){
                    switch(this.style){
                        case 0:
                            this._tabNum++;
                            htmlTxt[htmlTxt.length] = codeArr[i] + "\n" + this.getIdent();
                            break;
                        case 1:
                            htmlTxt[htmlTxt.length] = "\n" + this.getIdent();
                            this._tabNum++;
                            htmlTxt[htmlTxt.length] = codeArr[i] + "\n"+ this.getIdent();
                            break;
                        default:
                            this._tabNum++;
                            htmlTxt[htmlTxt.length] = codeArr[i];
                            break;

                    }
                }else{
                    htmlTxt[htmlTxt.length] = codeArr[i];
                }

            } else if(!slash_slash_comment_opened&&!slash_star_comment_opened && !quote_opened &&codeArr[i]==this._endBlock){
                if(!this.isCompress){
                    this._tabNum--;
                    htmlTxt[htmlTxt.length] = "\n" + this.getIdent() + codeArr[i];
                }else{
                    if(i<word_index&&this.isNextChar(i,codeArr)==false){
                        htmlTxt[htmlTxt.length] = codeArr[i] + this._rowEnd;
                    }else{
                        htmlTxt[htmlTxt.length] = codeArr[i];
                    }
                }
            } else if (!slash_slash_comment_opened&&!slash_star_comment_opened && !quote_opened && this.isBlockElement(codeArr[i])){
                htmlTxt[htmlTxt.length] = codeArr[i];
            } else if (!slash_slash_comment_opened&&!slash_star_comment_opened && !quote_opened && this.isSingleEyeElement(codeArr[i])){
                if(codeArr[i]==this._in){
                    htmlTxt[htmlTxt.length] = " ";
                }
                htmlTxt[htmlTxt.length] = codeArr[i] + " ";
            } else if (!slash_star_comment_opened&&!slash_slash_comment_opened&&this._quotation.contains(codeArr[i])){
                if (quote_opened){
                    if(quote_char==codeArr[i]){
                        htmlTxt[htmlTxt.length] = codeArr[i];
                        quote_opened    = false;
                        quote_char      = "";
                    } else {
                        htmlTxt[htmlTxt.length] = codeArr[i];
                    }
                } else {
                    htmlTxt[htmlTxt.length] =  codeArr[i];
                    quote_opened    = true;
                    quote_char        = codeArr[i];
                }
            } else if(!slash_star_comment_opened&&!slash_slash_comment_opened &&codeArr[i] == this._escape){
                htmlTxt[htmlTxt.length] = codeArr[i];
                if(i<word_index-1){
                    if(codeArr[i+1].charCodeAt(0)>=32&&codeArr[i+1].charCodeAt(0)<=127){
                        htmlTxt[htmlTxt.length] = codeArr[i+1].substr(0,1);
                        htmlTxt[htmlTxt.length] = codeArr[i+1].substr(1);
                        i=i+1;
                    }
                }
            } else if (!slash_slash_comment_opened && !slash_star_comment_opened&&!quote_opened&&this.isStartWith(this._commentOn,codeArr,i)){
                slash_star_comment_opened = true;
                if(!this._deleteComment){
                    htmlTxt[htmlTxt.length] = this._commentOn;
                }
                i = i + this.getSkipLength(this._commentOn);
            } else if (!slash_slash_comment_opened && !slash_star_comment_opened&&!quote_opened&&this.isStartWith(this._lineComment,codeArr,i)){
                slash_slash_comment_opened = true;
                if(!this._deleteComment){
                    htmlTxt[htmlTxt.length] =  this._lineComment;
                }
                i = i + this.getSkipLength(this._lineComment);
            } else if (!slash_slash_comment_opened && !slash_star_comment_opened&&!quote_opened&&this.isStartWith(this._ignore,codeArr,i)){
                slash_slash_comment_opened = true;
                htmlTxt[htmlTxt.length] = this._ignore;
                i = i + this.getSkipLength(this._ignore);
            } else if (!quote_opened&&!slash_slash_comment_opened&&this.isStartWith(this._commentOff,codeArr,i)){
                if (slash_star_comment_opened) {
                    slash_star_comment_opened = false;
                    if(!this._deleteComment){
                        htmlTxt[htmlTxt.length] =  this._commentOff;
                    }
                    i = i + this.getSkipLength(this._commentOff);
                }
            } else {
                if(!quote_opened){
                    if(!slash_slash_comment_opened && !slash_star_comment_opened){
                            htmlTxt[htmlTxt.length] = codeArr[i];
                    }else{
                        if(!this._deleteComment){
                            htmlTxt[htmlTxt.length] = codeArr[i];
                        }
                    }
                }else{
                            htmlTxt[htmlTxt.length] = codeArr[i];
                }
            }

        }

        return htmlTxt.join("");
    }

    this.isStartWith = function(str,code,index){

        if(typeof(str)!="undefined"&&str.length>0){
            var cc = new Array();
            for(var i=index;i<index+str.length;i++){
                cc[cc.length] = code[i];
            }
            var c = cc.join("");
            if(this._caseSensitive){
                if(str.length>=code[index].length&&c.indexOf(str)==0){
                    return true;
                }
            }else{
                if(str.length>=code[index].length&&c.toLowerCase().indexOf(str.toLowerCase())==0){
                    return true;
                }
            }
            return false;

        } else {
            return false;
        }
    }

    this.isFunction = function(val){
        return this._function.contains(this._caseSensitive?val:val.toLowerCase());
    }

    this.isBlockElement = function(val) {
        return this._blockElement.contains(this._caseSensitive?val:val.toLowerCase());
    }

    this.isChoiceElement = function(val) {
        return this._choiceElement.contains(this._caseSensitive?val:val.toLowerCase());
    }

    this.isSingleEyeElement = function(val) {
        return this._singleEyeElement.contains(this._caseSensitive?val:val.toLowerCase());
    }

    this.isNextElement = function(from,word){
        for(var i=from+1;i<word.length;i++){
            if(word[i]!=" "&&word[i]!="\t"&&word[i]!="\r"&&word[i]!="\n"){
                return this.isChoiceElement(word[i]);
            }
        }
        return false;
    }

    this.isNextChar = function(from,word){
        for(var i=from+1;i<word.length;i++){
            if(word[i]!=" "&&word[i]!="\t"&&word[i]!="\r"&&word[i]!="\n"){
                return ";,)]}".indexOf(word[i])>=0||this.isChoiceElement(word[i]);
            }
        }
        return false;
    }

    this.getSkipLength = function(val){
        var count = 0;
        for(var i=0;i<val.length;i++){
            if(this._wordDelimiters.indexOf(val.charAt(i))>=0){
                count++;
            }
        }
        if(count>0){
            count=count-1;
        }
        return count;
    }

    this.getIdent=function(){
        var n = [];
        for(var i=0;i<this._tabNum;i++){
            n[n.length] = "\t";
        }
        return n.join("");
    }
}

function doformat(o){
    var htmltxt = "";

    if (o == null){
        alert("domNode is null!");
        return;
    }

    var _codetxt = "";

    if(typeof(o)=="object"){
        switch(o.tagName){
            case "TEXTAREA":
            case "INPUT":
                _codetxt = o.value;
                break;
            case "DIV":
            case "SPAN":
                _codetxt = o.innerText;
                break;
            default:
                _codetxt = o.innerHTML;
                break;
        }
    }else{
        _codetxt = o;
    }

    var _syn = new CLASS_FORMAT(_codetxt);
    htmltxt = _syn.format();
    return  htmltxt;
}

function go()
{
    var code    = document.getElementById("code").value;
    var xx      = new CLASS_FORMAT(code);
    var a       = new Date();

    if(document.getElementById('cboOperate').selectedIndex==1){
        xx.isCompress=true;
    }else{
        xx.style = parseInt(document.getElementById('cboStyle').value);
    }
    document.getElementById("display").value = xx.format();
    alert("共花:" + (new Date().getTime()-a.getTime()) + "ms");
}

</SCRIPT>
<TEXTAREA id=code rows=12 cols=100>
/*
这个是一个类
*/

function    xx   (num,str){//说明
var a = num;this.aa = a;
this.bb = function(){alert(str);}
this.cc = function(){for(var i=0;i<10;i++){document.title=i;}}//str=str.replace(/(\\)/gi,'\\\\');
};

var o = {a:function(){},b:345}

xx.prototype.dd= function(){alert("d  d        kd");}

var a = new xx(100,"hello"),b=new xx(0,"ttyp");
if(1>2)  {   alert();
 }
 else {
 alert(" hell ");
 }

a.bb();
b.dd();
alert(a.aa);

</TEXTAREA> <BR>
<select id="cboOperate" onchange="if(this.selectedIndex==1)document.getElementById('cboStyle').disabled=true;else document.getElementById('cboStyle').disabled=false;">
    <option value="0">格式化</option>
    <option value="1">压缩</option>
</select>
<select id="cboStyle">
    <option value="0">经典</option>
    <option value="1">微软</option>
</select>
<INPUT onclick=go() type=button value=go><br>
<textarea id=display rows=12 cols=100>
</textarea>