T4nk JS混淆工具

  1. <HTML><HEAD><TITLE>T4nk JS混淆工具</TITLE>   
  2. <BODY>   
  3. <SCRIPT language=JavaScript>   
  4. <!--   
  5. /**//**//**//**   
  6. **    ==================================================================================================    
  7. **    类名:CLASS_CONFUSION  
  8. **    功能:JS混淆    
  9. **    示例:    
  10.     ---------------------------------------------------------------------------------------------------    
  11.     
  12.             var xx        = new CLASS_CONFUSION(code);              
  13.  
  14.             document.getElementById("display").innerHTML = xx.confusion();   
  15.     
  16.     ---------------------------------------------------------------------------------------------------    
  17. **    作者:ttyp    
  18. **    邮件:ttyp@21cn.com    
  19. **    日期:2006-3-20    
  20. **    版本:0.12  
  21. **    ==================================================================================================    
  22. **/     
  23.   
  24. function CLASS_CONFUSION(code){   
  25.     //哈希表类   
  26.     function Hashtable(){   
  27.         this._hash        = new Object();   
  28.         this.add        = function(key,value){   
  29.                             if(typeof(key)!="undefined"){   
  30.                                 if(this.contains(key)==false){   
  31.                                     this._hash[key]=typeof(value)=="undefined"?null:value;   
  32.                                     return true;   
  33.                                 } else {   
  34.                                     return false;   
  35.                                 }   
  36.                             } else {   
  37.                                 return false;   
  38.                             }   
  39.                         }   
  40.         this.remove        = function(key){delete this._hash[key];}   
  41.         this.count        = function(){var i=0;for(var k in this._hash){i++;} return i;}   
  42.         this.items        = function(key){return this._hash[key];}   
  43.         this.contains    = function(key){return typeof(this._hash[key])!="undefined";}   
  44.         this.clear        = function(){for(var k in this._hash){delete this._hash[k];}}   
  45.   
  46.     }   
  47.   
  48.     function VariableMap(parent){   
  49.         this.table = new Hashtable();   
  50.         this.level = parent?parent.level+1:0;   
  51.         this.parent= parent;   
  52.         this.add = function(key,value){this.table.add(key,value)};   
  53.         this.items = function(key){return this.table.items(key)};   
  54.         this.count = function(){return this.table.count()};   
  55.         this.contains = function(key){return this.table.contains(key);}   
  56.         this.isParameter    = false;   
  57.     }   
  58.   
  59.     this._caseSensitive = true;   
  60.   
  61.     //字符串转换为哈希表   
  62.     this.str2hashtable = function(key,cs){   
  63.            
  64.         var _key    = key.split(/,/g);   
  65.         var _hash    = new Hashtable();    
  66.         var _cs        = true;   
  67.   
  68.        
  69.         if(typeof(cs)=="undefined"||cs==null){   
  70.             _cs = this._caseSensitive;   
  71.         } else {   
  72.             _cs = cs;   
  73.         }   
  74.   
  75.         for(var i in _key){   
  76.             if(_cs){   
  77.                 _hash.add(_key[i]);   
  78.             } else {   
  79.                 _hash.add((_key[i]+"").toLowerCase());   
  80.             }   
  81.   
  82.         }   
  83.         return _hash;   
  84.     }   
  85.   
  86.     //获得需要转换的代码   
  87.     this._codetxt        = code;   
  88.   
  89.     if(typeof(syntax)=="undefined"){   
  90.         syntax = "";   
  91.     }   
  92.   
  93.     this._deleteComment = false;   
  94.     //是否大小写敏感   
  95.     this._caseSensitive    = true;   
  96.     //得到关键字哈希表   
  97.     this._keywords        =    
  98.         this.str2hashtable("switch,case,delete,default,typeof,for,in,function,void,this,boolean,"  
  99.                 + "while,if,return,new,true,false,try,catch,throw,null,else,do,var");   
  100.     this._function        = this.str2hashtable("function");   
  101.     this._var            = "var";   
  102.     this._beginBlock    = "{";   
  103.     this._endBlock        = "}";   
  104.        
  105.     this._window        = this.str2hashtable("alert,escape,unescape,document,parseInt,parseFloat");   
  106.     //得到内建对象哈希表   
  107.     this._commonObjects = this.str2hashtable("String,Number,Boolean,RegExp,Error,Math,Date,Object,Array,Global");   
  108.     //得到分割字符   
  109.     this._wordDelimiters= "  ,.?!;:\\/<>(){}[]\"'\r\n\t=+-|*%@#$^&";   
  110.     //引用字符   
  111.     this._quotation        = this.str2hashtable("\",'");   
  112.     //行注释字符   
  113.     this._lineComment    = "//";   
  114.     //转义字符   
  115.     this._escape        = "\\";  
  116.     //多行引用开始  
  117.     this._commentOn        = "/*";  
  118.     //多行引用结束  
  119.     this._commentOff    = "*/";  
  120.     this._execute        = "eval";  
  121.     //引用调用字符  
  122.     this._call            = ".";  
  123.     this._varPause        = "=";  
  124.     this._varContinue    = ",";  
  125.     //变量个数  
  126.     this._varNum = 0;  
  127.  
  128.     this.confusion    = function() {  
  129.         var codeArr = new Array();  
  130.         var word_index = 0;  
  131.         var htmlTxt = new Array();  
  132.  
  133.  
  134.         //得到分割字符数组(分词)  
  135.         for (var i = 0; i < this._codetxt.length; i++) {  
  136.               
  137.             if (this._wordDelimiters.indexOf(this._codetxt.charAt(i)) == -1) {        //找不到关键字  
  138.                 if (codeArr[word_index] == null || typeof(codeArr[word_index]) == 'undefined') {  
  139.                     codeArr[word_index] = "";  
  140.                 }  
  141.                 codeArr[word_index] += this._codetxt.charAt(i);  
  142.             } else {  
  143.                 if (typeof(codeArr[word_index]) != 'undefined' && codeArr[word_index].length > 0)  
  144.                     word_index++;  
  145.                 codeArr[word_index++] = this._codetxt.charAt(i);                  
  146.             }   
  147.         }  
  148.  
  149.  
  150.         var quote_opened                = false;    //引用标记  
  151.         var slash_star_comment_opened    = false;    //多行注释标记  
  152.         var slash_slash_comment_opened    = false;    //单行注释标记  
  153.         var line_num                    = 1;        //行号  
  154.         var quote_char                    = "";        //引用标记类型  
  155.         var call_opened                    = false;  
  156.         var call_string                    = "";  
  157.         var var_opened                    = false;  
  158.         var var_pause                    = false;  
  159.         var function_opened                = false;  
  160.         var parameter_opened            = false;  
  161.  
  162.         var var_map                        = new VariableMap();  
  163.         var cur_var_map                    = var_map;  
  164.         var execute_opened                = false;  
  165.  
  166.         //按分割字,分块显示  
  167.         for (var i=0; i <=word_index; i++){  
  168.  
  169.             //单独处理指针引用  
  170.             if(call_opened&&typeof(codeArr[i])!="undefined"){                  
  171.                 if(call_string.length==0){  
  172.                     if(this.isVar(codeArr[i])){  
  173.                         call_string +=codeArr[i];  
  174.                     }else{  
  175.                         htmlTxt[htmlTxt.length] = "[\"" + this.toHex(call_string) + "\"]";   
  176.                         if(codeArr[i]!=this._call){   
  177.                             htmlTxt[htmlTxt.length] = codeArr[i];                           
  178.                             call_opened = false;           
  179.                         }   
  180.                         call_string = "";   
  181.                     }   
  182.                 } else {   
  183.                     if(!this.isVar(codeArr[i])){   
  184.                         htmlTxt[htmlTxt.length] = "[\"" + this.toHex(call_string) + "\"]";   
  185.                         if(codeArr[i]!=this._call){   
  186.                             htmlTxt[htmlTxt.length] = codeArr[i];                               
  187.                             call_opened = false;       
  188.                         }   
  189.                         call_string = "";   
  190.                     }else{   
  191.                         htmlTxt[htmlTxt.length] = "[\"" + this.toHex(call_string) + "\"]";   
  192.                     }   
  193.                 }   
  194.                 continue;   
  195.             }   
  196.                
  197.             //处理空行(由于转义带来)   
  198.             if(typeof(codeArr[i])=="undefined"||codeArr[i].length==0){   
  199.                 continue;   
  200.             } else if(codeArr[i]==" "){   
  201.                 htmlTxt[htmlTxt.length] = " ";   
  202.             } else if(codeArr[i]=="\n"){   
  203.             //处理换行   
  204.             } else if (codeArr[i] == "\r"){                                                                       
  205.                 slash_slash_comment_opened = false;           
  206.                 quote_opened = false;   
  207.                 var_opened = false;   
  208.                 htmlTxt[htmlTxt.length] = "\r\n";       
  209.                 line_num++;   
  210.             //处理function里的参数标记   
  211.             } else if (!slash_slash_comment_opened&&!slash_star_comment_opened && !quote_opened &&this.isFunction(codeArr[i])){   
  212.                 htmlTxt[htmlTxt.length] = codeArr[i];   
  213.                 function_opened = true;   
  214.             } else if (!slash_slash_comment_opened&&!slash_star_comment_opened && !quote_opened &&codeArr[i]=="("){   
  215.                 htmlTxt[htmlTxt.length] = codeArr[i];   
  216.                 if(function_opened == true){   
  217.                     function_opened =false;   
  218.                     var_opened = true;   
  219.                     cur_var_map = new VariableMap(cur_var_map);   
  220.                     cur_var_map.isParameter = true;   
  221.                 }   
  222.             } else if (!slash_slash_comment_opened&&!slash_star_comment_opened && !quote_opened &&codeArr[i]==")"){   
  223.                 htmlTxt[htmlTxt.length] = codeArr[i];   
  224.                 //处理var a = new Class(),b=new Date();类似的问题   
  225.                 if(cur_var_map.isParameter){   
  226.                     var_opened = false;   
  227.                     var_pause = false;   
  228.                 }   
  229.             } else if (!slash_slash_comment_opened&&!slash_star_comment_opened && !quote_opened &&codeArr[i]==";"){   
  230.                 htmlTxt[htmlTxt.length] = codeArr[i];   
  231.                 var_opened = false;   
  232.                 var_pause = false;   
  233.                 if(execute_opened){       
  234.                     execute_opened = false;   
  235.                 }   
  236.             } else if (!slash_slash_comment_opened&&!slash_star_comment_opened && !quote_opened &&codeArr[i]==this._var){   
  237.                 htmlTxt[htmlTxt.length] = codeArr[i];   
  238.                 var_opened = true;   
  239.                 var_pause = false;   
  240.             } else if(!slash_slash_comment_opened&&!slash_star_comment_opened && !quote_opened &&codeArr[i]==this._varPause){   
  241.                 htmlTxt[htmlTxt.length] = codeArr[i];   
  242.                 var_pause = true;   
  243.             } else if(!slash_slash_comment_opened&&!slash_star_comment_opened && !quote_opened &&codeArr[i]==this._varContinue){   
  244.                 htmlTxt[htmlTxt.length] = codeArr[i];   
  245.                 var_pause = false;   
  246.             } else if(!slash_slash_comment_opened&&!slash_star_comment_opened && !quote_opened &&codeArr[i]==this._beginBlock){   
  247.                 cur_var_map = new VariableMap(cur_var_map);   
  248.                 var_opened = false;   
  249.                 htmlTxt[htmlTxt.length] = codeArr[i];   
  250.             } else if(!slash_slash_comment_opened&&!slash_star_comment_opened && !quote_opened &&codeArr[i]==this._endBlock){   
  251.                 cur_var_map = cur_var_map.parent;   
  252.                 if(cur_var_map.isParameter){   
  253.                     cur_var_map = cur_var_map.parent;   
  254.                 }   
  255.                 htmlTxt[htmlTxt.length] = codeArr[i];   
  256.             //处理引用调用   
  257.             } else if (!slash_slash_comment_opened&&!slash_star_comment_opened && !quote_opened &&codeArr[i]==this._call){   
  258.                 //判断引用(.)后面第一个是否为字母货_$   
  259.                 if(i<word_index-1){   
  260.                     if(this.isVar(codeArr[i+1])){                           
  261.                         if(call_opened){   
  262.                             htmlTxt[htmlTxt.length] = this.toHex(call_string);   
  263.                         }   
  264.                         call_opened = true;       
  265.                     }else{   
  266.                         htmlTxt[htmlTxt.length] = this._call;   
  267.                     }   
  268.                 }else{   
  269.                     htmlTxt[htmlTxt.length] = this._call;   
  270.                 }   
  271.             //处理关键字   
  272.             } else if (!slash_slash_comment_opened&&!slash_star_comment_opened && !quote_opened && this.isKeyword(codeArr[i])){           
  273.               htmlTxt[htmlTxt.length] = codeArr[i];   
  274.             //处理eval后的字符串   
  275.             } else if (!slash_slash_comment_opened&&!slash_star_comment_opened && !quote_opened && codeArr[i]==this._execute){           
  276.               htmlTxt[htmlTxt.length] = "window[\"" + this.toHex(codeArr[i]) + "\"]";   
  277.               execute_opened = true;   
  278.             //window内置对象   
  279.             } else if (!slash_slash_comment_opened&&!slash_star_comment_opened && !quote_opened && this.isWindow(codeArr[i])){           
  280.               htmlTxt[htmlTxt.length] = "window[\"" + this.toHex(codeArr[i]) + "\"]";   
  281.             //处理普通对象   
  282.             } else if (!slash_slash_comment_opened&&!slash_star_comment_opened && !quote_opened && this.isCommonObject(codeArr[i])){       
  283.                 htmlTxt[htmlTxt.length] =  "window[\"" + this.toHex(codeArr[i]) + "\"]";   
  284.             //处理双引号(引号前不能为转义字符)       
  285.             } else if (!slash_star_comment_opened&&!slash_slash_comment_opened&&this._quotation.contains(codeArr[i])){                                                       
  286.                 if (quote_opened){   
  287.                     //是相应的引号   
  288.                     if(quote_char==codeArr[i]){   
  289.                         htmlTxt[htmlTxt.length] = codeArr[i];                       
  290.                         quote_opened    = false;   
  291.                         quote_char        = "";   
  292.                     } else {   
  293.                         htmlTxt[htmlTxt.length] = this.toHex(codeArr[i]);               
  294.                     }   
  295.                 } else {   
  296.                     htmlTxt[htmlTxt.length] =  codeArr[i];   
  297.                     quote_opened    = true;   
  298.                     quote_char        = codeArr[i];   
  299.                 }                       
  300.             //处理转义字符   
  301.             } else if(codeArr[i] == this._escape){       
  302.                 htmlTxt[htmlTxt.length] = codeArr[i];    
  303.                 if(i<word_index-1){   
  304.                     if(codeArr[i+1].charCodeAt(0)>=32&&codeArr[i+1].charCodeAt(0)<=127){   
  305.                         htmlTxt[htmlTxt.length] = codeArr[i+1].substr(0,1);   
  306.                         htmlTxt[htmlTxt.length] = this.toHex(codeArr[i+1].substr(1));   
  307.                         i=i+1;   
  308.                     }   
  309.                 }               
  310.             //处理多行注释的开始   
  311.             } else if (!slash_slash_comment_opened && !slash_star_comment_opened&&!quote_opened&&this.isStartWith(this._commentOn,codeArr,i)){                                                   
  312.                 slash_star_comment_opened = true;   
  313.                 htmlTxt[htmlTxt.length] = this._commentOn;   
  314.                 i = i + this.getSkipLength(this._commentOn);       
  315.             //处理单行注释   
  316.             } else if (!slash_slash_comment_opened && !slash_star_comment_opened&&!quote_opened&&this.isStartWith(this._lineComment,codeArr,i)){                                                   
  317.                 slash_slash_comment_opened = true;   
  318.                 if(!this._deleteComment){   
  319.                     htmlTxt[htmlTxt.length] =  this._lineComment;   
  320.                 }   
  321.                 i = i + this.getSkipLength(this._lineComment);       
  322.             //处理忽略词   
  323.             } else if (!slash_slash_comment_opened && !slash_star_comment_opened&&!quote_opened&&this.isStartWith(this._ignore,codeArr,i)){                                                   
  324.                 slash_slash_comment_opened = true;   
  325.                 htmlTxt[htmlTxt.length] = this._ignore;   
  326.                 i = i + this.getSkipLength(this._ignore);                       
  327.             //处理多行注释结束       
  328.             } else if (!quote_opened&&!slash_slash_comment_opened&&this.isStartWith(this._commentOff,codeArr,i)){                                   
  329.                 if (slash_star_comment_opened) {   
  330.                     slash_star_comment_opened = false;   
  331.                     if(!this._deleteComment){   
  332.                         htmlTxt[htmlTxt.length] =  this._commentOff;   
  333.                     }   
  334.                     i = i + this.getSkipLength(this._commentOff);           
  335.                 }   
  336.             } else {   
  337.                 //不是在字符串中   
  338.                 if(!quote_opened){   
  339.                     //如果不是在注释重   
  340.                     if(!slash_slash_comment_opened && !slash_star_comment_opened){       
  341.                         //不是在定义变量时   
  342.                         if(!var_opened){   
  343.                             if(this.translateVar(cur_var_map,codeArr[i])==""){   
  344.                                 htmlTxt[htmlTxt.length] = codeArr[i];   
  345.                             }else{   
  346.                                 htmlTxt[htmlTxt.length] = this.translateVar(cur_var_map,codeArr[i]);   
  347.                             }   
  348.                         }else{   
  349.                             //不是在暂停变量定义时   
  350.                             if(var_pause){   
  351.                                 if(this.translateVar(cur_var_map,codeArr[i])==""){   
  352.                                     htmlTxt[htmlTxt.length] = codeArr[i];   
  353.                                 }else{   
  354.                                     htmlTxt[htmlTxt.length] = this.translateVar(cur_var_map,codeArr[i]);   
  355.                                 }                                   
  356.                             }else{   
  357.                                 //变量符合命名规则,并且(变量前为空格或制表符或逗号如:var a;var    a;var a,b;,还有如果是函数参数,如:function(a,b,c)   
  358.                                 if(this.isVar(codeArr[i])&&(i>0&&codeArr[i-1]==" "  
  359.                                     ||codeArr[i-1]=="\t"||codeArr[i-1]==this._varContinue   
  360.                                     ||cur_var_map.isParameter)){   
  361.                                     var name = this.getRandName();                                   
  362.                                     cur_var_map.add(codeArr[i],name);   
  363.                                     htmlTxt[htmlTxt.length] = this.translateVar(cur_var_map,codeArr[i]);   
  364.                                 }else{   
  365.                                     htmlTxt[htmlTxt.length] = codeArr[i];   
  366.                                 }   
  367.                             }   
  368.                         }   
  369.                     //注释中                               
  370.                     }else{   
  371.                         if(!this._deleteComment){   
  372.                             htmlTxt[htmlTxt.length] = codeArr[i];   
  373.                         }   
  374.                     }   
  375.                 }else{   
  376.                     if(execute_opened){   
  377.                         if(this.translateVar(cur_var_map,codeArr[i])==""){   
  378.                             htmlTxt[htmlTxt.length] = codeArr[i];   
  379.                         }else{   
  380.                             htmlTxt[htmlTxt.length] = this.translateVar(cur_var_map,codeArr[i]);   
  381.                         }   
  382.                     }else{   
  383.                         htmlTxt[htmlTxt.length] = this.toHex(codeArr[i]);   
  384.                     }   
  385.                 }   
  386.             }   
  387.                
  388.         }   
  389.   
  390.         return htmlTxt.join("");   
  391.     }   
  392.   
  393.     this.isStartWith = function(str,code,index){   
  394.   
  395.         if(typeof(str)!="undefined"&&str.length>0){           
  396.             var cc = new Array();               
  397.             for(var i=index;i<index+str.length;i++){   
  398.                 cc[cc.length] = code[i];   
  399.             }   
  400.             var c = cc.join("");   
  401.             if(this._caseSensitive){   
  402.                 if(str.length>=code[index].length&&c.indexOf(str)==0){   
  403.                     return true;   
  404.                 }   
  405.             }else{   
  406.                 if(str.length>=code[index].length&&c.toLowerCase().indexOf(str.toLowerCase())==0){   
  407.                     return true;   
  408.                 }   
  409.             }   
  410.             return false;   
  411.   
  412.         } else {   
  413.             return false;   
  414.         }   
  415.     }   
  416.   
  417.     this.isFunction = function(val){   
  418.         return this._function.contains(this._caseSensitive?val:val.toLowerCase());   
  419.     }   
  420.        
  421.     this.isKeyword = function(val) {           
  422.         return this._keywords.contains(this._caseSensitive?val:val.toLowerCase());   
  423.     }   
  424.   
  425.     this.isWindow = function(val) {           
  426.         return this._window.contains(this._caseSensitive?val:val.toLowerCase());   
  427.     }   
  428.   
  429.     this.isCommonObject = function(val) {   
  430.         return this._commonObjects.contains(this._caseSensitive?val:val.toLowerCase());   
  431.     }   
  432.   
  433.     this.getSkipLength = function(val){       
  434.         var count = 0;   
  435.         for(var i=0;i<val.length;i++){   
  436.             if(this._wordDelimiters.indexOf(val.charAt(i))>=0){   
  437.                 count++;   
  438.             }   
  439.         }   
  440.         if(count>0){   
  441.             count=count-1;   
  442.         }   
  443.         return count;   
  444.     }   
  445.   
  446.     //字符串转换为16进制形式   
  447.     this.toHex = function(val){   
  448.         var str = new Array();   
  449.         for(var i=0;i<val.length;i++){   
  450.             var c = val.charCodeAt(i);   
  451.             if(c>=0&&c<256){   
  452.                 str[str.length] = "\\x" + val.charCodeAt(i).toString(16);   
  453.             }else{   
  454.                 str[str.length] = "\\u" + val.charCodeAt(i).toString(16);   
  455.             }   
  456.         }   
  457.         return str.join("");   
  458.     }   
  459.   
  460.     //获得变量随机名   
  461.     this.getRandName = function(){   
  462.         var style = parseInt(Math.random()*4);   
  463.         var len = parseInt(Math.random()*9)+1;   
  464.         var n = [];   
  465.   
  466.         this._varNum++;   
  467.         var c = "abcdefghijklmnopqrstuvwsyzABCDEFGHIJKLMNOPQRSTUVWXYZ_$";   
  468.   
  469.         for(var i=0;i<len;i++){   
  470.             n[n.length] = c.charAt(parseInt(Math.random()*54));    
  471.         }   
  472.   
  473.         return n.join("")+this._varNum;   
  474.   
  475.     }   
  476.   
  477.     //是否符合变量命名字首规则   
  478.     this.isVar = function(val){   
  479.         return /^[a-zA-Z_\$].*$/.test(val);   
  480.     }   
  481.   
  482.     //翻译变量,如果返回为空则不存在此变量   
  483.     this.translateVar = function(node,key){   
  484.         if(node.contains(key)){   
  485.             return node.items(key);   
  486.         }   
  487.   
  488.         var cn = node.parent;   
  489.         while(cn!=null){   
  490.             if(cn.contains(key)){   
  491.                 return cn.items(key);   
  492.             }   
  493.             cn = cn.parent;           
  494.         }   
  495.         return "";       
  496.     }   
  497.   
  498.   
  499. }   
  500.   
  501. function doConfusion(o){   
  502.     var htmltxt = "";   
  503.   
  504.     if (o == null){   
  505.         alert("domNode is null!");   
  506.         return;   
  507.     }   
  508.   
  509.     var _codetxt = "";   
  510.        
  511.     if(typeof(o)=="object"){   
  512.         switch(o.tagName){   
  513.             case "TEXTAREA":   
  514.             case "INPUT":   
  515.                 _codetxt = o.value;   
  516.                 break;   
  517.             case "DIV":   
  518.             case "SPAN":   
  519.                 _codetxt = o.innerText;   
  520.                 break;   
  521.             default:   
  522.                 _codetxt = o.innerHTML;   
  523.                 break;   
  524.         }   
  525.     }else{   
  526.         _codetxt = o;   
  527.     }   
  528.   
  529.     var _syn = new CLASS_CONFUSION(_codetxt);   
  530.     htmltxt = _syn.confusion();   
  531.     return  htmltxt;   
  532. }   
  533.   
  534.   
  535. function go()   
  536. {   
  537.     var code    = document.getElementById("code").value;   
  538.     var xx      = new CLASS_CONFUSION(code);       
  539.     var a       = new Date();   
  540.     document.getElementById("display").value = xx.confusion();   
  541.     alert("共花:" + (new Date().getTime()-a.getTime()) + "ms");   
  542. }   
  543. //-->   
  544. </SCRIPT>   
  545. <TEXTAREA id=code rows=12 cols=100>   
  546. /*  
  547. 这个是一个类  
  548. */  
  549. function xx(num,str)   
  550. {   
  551. //说明   
  552. var a = num;   
  553. this.aa = a;   
  554. this.bb = function(){alert(str);}   
  555. this.cc = function(){for(var i=0;i<10;i++){document.title=i;}}   
  556. }   
  557.   
  558. xx.prototype.dd= function(){   
  559. alert("dd");   
  560. }   
  561.   
  562. var a = new xx(100,"hello"),b=new xx(0,"ttyp");   
  563. eval("a.aa=20");   
  564. a.bb();   
  565. b.dd();   
  566. alert(a.aa);   
  567.   
  568. </TEXTAREA> <BR><INPUT onclick=go() type=button value=go><br>   
  569. <textarea id=display rows=12 cols=100>   
  570. </textarea>   
  571. </BODY></HTML>  
  1. da shang
    donate-alipay
               donate-weixin weixinpay

发表评论↓↓