Ò׽ؽØͼÈí¼þ¡¢µ¥Îļþ¡¢Ãâ°²×°¡¢´¿ÂÌÉ«¡¢½ö160KB

[·­Òë]High Performance JavaScript(010)

Cloning Nodes  ½Úµã¿Ë¡
    Another way of updating page contents using DOM methods is to clone existing DOM elements instead of creating new ones—in other words, using element.cloneNode() (where element is an existing node) instead of document.createElement().
    ʹÓÃDOM·½·¨¸üÐÂÒ³ÃæÄÚÈݵÄÁíÒ»¸ö;¾¶ÊÇ¿Ë¡ÒÑÓÐDOMÔªËØ£¬¶ø²»ÊÇ´´½¨Ðµė—¼´Ê¹ÓÃelement.cloneNode()£¨elementÊÇÒ»¸öÒÑ´æÔڵĽڵ㣩´úÌædocument.createElement();
    Cloning nodes is more efficient in most browsers, but not by a big margin. Regenerating the table from the previous example by creating the repeating elements only once and then copying them results in slightly faster execution times:
    ÔÚ´ó¶àÊýä¯ÀÀÆ÷ÉÏ£¬¿Ë¡½Úµã¸üÓÐЧÂÊ£¬µ«Ìá¸ß²»Ì«¶à¡£ÓÿË¡½ÚµãµÄ°ì·¨ÖØÐÂÉú³ÉÇ°ÃæÀý×ÓÖÐµÄ±í£¬µ¥ÔªÖ»´´½¨Ò»´Î£¬È»ºóÖظ´Ö´Ðи´ÖƲÙ×÷£¬ÕâÑù×öÖ»ÊÇÉÔ΢¿ìÁËÒ»µã£º
• 2% in IE8, but no change in IE6 and IE7
 ÔÚIE8Öпì2%£¬µ«ÔÚIE6ºÍIE7ÖÐÎޱ仯
• Up to 5.5% in Firefox 3.5 and Safari 4
 ÔÚFirefox 3.5ºÍSafari 4ÖпìÁË5.5%
• 6% in Opera (but no savings in Opera 10)
 ÔÚOperaÖпìÁË6%£¨µ«ÊÇÔÚOpera 10ÖÐÎޱ仯£©
• 10% in Chrome 2 and 3% in Chrome 3
ÔÚChrome 2ÖпìÁË10%£¬ÔÚChrome 3ÖпìÁË3%
    As an illustration, here's a partial code listing for generating the table using element.cloneNode():
    Ò»¸öʾÀý£¬ÕâÀïÊÇʹÓÃelement.cloneNode()´´½¨±íµÄ²¿·Ö´úÂ룺
function tableClonedDOM() {
  var i, table, thead, tbody, tr, th, td, a, ul, li,
  oth = document.createElement('th'),
  otd = document.createElement('td'),
  otr = document.createElement('tr'),
  oa = document.createElement('a'),
  oli = document.createElement('li'),
  oul = document.createElement('ul');
  tbody = document.createElement('tbody');
  for (i = 1; i <= 1000; i++) {
    tr = otr.cloneNode(false);
    td = otd.cloneNode(false);
&nb


Ïà¹ØÎĵµ£º

JavaScriptѧϰ±Ê¼Ç£¨Î壩

1.ÔÚHTMLÖÐʹÓÃ<script>ÔªËØÒýÈëJavaScript¡£
   ¸ÃÔªËØÓÐÁ½¸öÊôÐÔ£¬languageÉùÃ÷ҪʹÓõĽű¾ÓïÑÔ£¬srcÊôÐÔÊÇ¿ÉÑ¡µÄ£¬ÓÃÓÚÒýÓÃÍⲿJavaScriptÎļþ¡£
   NB
£ºÏÖÔÚ´ó¶àʹÓÃtypeÊôÐÔ£¨type=“text/javascript”£©Ìæ´úlanguageÊôÐÔ£¬ÒÔ±ã¸üºÃµØÖ§³ÖXHTML£¨¿ÉÀ©Õ¹HTML£©¡£
2.Ò»°ãÈÏΪ ......

JavascriptÃæÏò¶ÔÏó±à³Ì£¨¶þ£©£º¼Ì³Ð


ZT:http://www.ruanyifeng.com/blog/2010/05/object-oriented_javascript_inheritance.html
ÉÏÒ»´ÎµÄÎÄÕ£¬Ö÷Òª½éÉÜÁËÈçºÎ"·â×°"Êý¾ÝºÍ·½·¨£¬´ÓÔ­ÐͶÔÏóÉú³ÉʵÀý¡£
½ñÌìÒª½éÉܵÄÊÇ£¬¶à¸öÔ­ÐͶÔÏóÖ®¼äÈçºÎ"¼Ì³Ð"¡£
±ÈÈ磬ÏÖÔÚÓÐÒ»¸ö"¶¯Îï"¶ÔÏó£¬
¡¡¡¡function Animal(){
¡¡¡¡¡¡¡¡this.species = "¶¯Îï";
¡¡¡¡}
»¹ÓÐ ......

JavascriptÃæÏò¶ÔÏó±à³Ì£¨Èý£©£º·Çº¯Êý¶ÔÏóµÄ¼Ì³Ð


×òÌ죬ÎÒ±¾À´´òË㣬°ÑÕâ¸ö»°Ìâ½áÊøÁË¡£
µ«ÊÇ£¬Ð´µ½Ò»°ëµÄʱºò£¬ÎÒͻȻÒâʶµ½£¬JavascriptµÄ¼Ì³ÐÓÐÁ½ÖÖ¡£Ò»ÖÖÊÇ»ùÓÚ"º¯Êý¶ÔÏó"µÄ¼Ì³Ð£¬Ò²¾ÍÊÇÒ»¸öfunctionÈ¥¼Ì³ÐÁíÍâÒ»¸öfunction£¬Õâ¸öÎÒÒѾ­ÔÚ×òÌì½éÉܹýÁË¡£
ÁíÒ»ÖÖÔòÊÇ»ùÓÚ"·Çº¯Êý¶ÔÏó"µÄ¼Ì³Ð£¬²»Éæ¼°function¡£ËüµÄ×ö·¨ÓëÇ°Ò»ÖÖÇé¿öÍêÈ«²»Í¬¡£
Ò»¡¢Ê²Ã´ÊÇ"·Çº¯Êý¶ÔÏ ......

phpÖеÄevalºÍJavaScriptÖеÄeval

phpÖеÄevalºÍJavaScriptÖеÄevalÇø±ð£º
Definition and Usage

¶¨ÒåºÍÓ÷¨
The eval() function evaluates a
string as PHP code.
eval()º¯ÊýµÄ×÷ÓÃÊÇ£º·µ»ØÓëPHP´úÂëÏà¶ÔÓ¦µÄ×Ö·û´®¡£
The string
must be valid PHP code and must end with semicolon.
Õâ¸ö×Ö·û´®±ØÐëÊÇÓÐЧµÄPHP´úÂ룬
²¢ÇÒ±ØÐëÒԷֺŽáÊø¡ ......

JavaScriptµÄBASE64

**
* ÎÒÔÚÍøÉÏ¿´µ½¹ýºÜ¶àBASE64µÄJavaScriptËã·¨£¬¶¼¾õµÃ²»ÂúÒ⣬ÓÚÊÇ×Ô¼ºÐ´ÁËÒ»¸ö£¬ÔÚÕâÀï·ÖÏíһϡ£
* ÎҵĴúÂëÔÚÖÊÁ¿µÄЧÂʶ¼½Ï¸ß£¬Ã»ÓÐһЩÈßÓàµÄ²Ù×÷¡£×ÜÌåÀ´½²ÎÒ¾õµÃ·Ç³£²»´í¡£
* Èç¹û´ó¼ÒÓÐʲô²»¶®µÄµØ·½¿ÉÒÔÎÊÎÒ¡£
*/
var BASE64={
    /**
     * ´Ë±äÁ¿Îª±àÂëµÄ ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ