Ò׽ؽØÍ¼Èí¼þ¡¢µ¥Îļþ¡¢Ãâ°²×°¡¢´¿ÂÌÉ«¡¢½ö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»ñµÃurl²ÎÊý

Ò³ÃæÌá½»Êý¾ÝÒ»°ãÓÐÁ½ÖÖ·½·¨£ºget,post¡£post¾ÍÊÇËùνµÄformÌá½»£¬Ê¹ÓÃÊÓͼ£»getÊÇͨ¹ýurlÌá½»¡£
Get·½·¨Ò»°ãÓúǫ́´úÂ루Èçasp,asp.net£©»ñµÃ²ÎÊý£¬´úÂëºÜ¼òµ¥£ºRequest.QueryString["id"];¼´¿É»ñÈ¡¡£ 
ÓÐЩʱºòÐèÒªÖ±½ÓÔÚǰ̨»ñÈ¡url²ÎÊý£¬ÒªÓõ½javascript£¬jsûÓÐÖ±½Ó»ñÈ¡url²ÎÊýµÄ·½·¨£¬ÄÇô£¬ÎÒÃÇÈçºÎͨ¹ýjs ......

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ѧϰ±Ê¼Ç£¨Áù£©

1.DOMÊÇÕë¶ÔXMLµÄ»ùÓÚÊ÷µÄAPI¡£Ê¹ÓÃDOM£¬Ö»Ðè½âÎö´úÂëÒ»´ÎÀ´´´½¨Ò»¸öÊ÷µÄÄ£ÐÍ¡£ÔÚÕâ¸ö³õʼ½âÎö¹ý³ÌÖ®ºó£¬XMLÒѾ­Íêȫͨ¹ýDOMÄ£ÐͱíÏÖ³öÀ´£¬Í¬Ê±Ò²²»ÔÙÐèҪԭʼµÄ´úÂë¡£
   NB
£ºDOMÊÇÓïÑÔÎ޹صÄAPI£¬Ëü²¢²»ÓëJava¡¢JavaScript»òÆäËûÓïÑ԰󶨡£ ......

javascript location.reload()

¹¦ÄÜ£º
ÖØÐ¼ÓÔØÎĵµ¡£
Óï·¨£º
location.reload(force)
²ÎÊý£º
force£º¿ÉÑ¡²ÎÊý£¬ÊÇÒ»¸ö²¼¶ûÖµ¡£
      Èç¹ûÊ¡ÂÔ²ÎÊý£¬»òÕß²ÎÊýÊÇfalse£¬Ëü¾Í»áÓÃHTTPÍ·If-Modified-SinceÀ´¼ì²â·þÎñÆ÷ÉϵÄÎĵµÊÇ·ñÒѸı䡣Èç¹ûÎĵµÒѸÄ
±ä£¬reload()»áÔÙ´ÎÏÂÔØ¸ÃÎĵµ¡£Èç¹ûÎĵµÎ´¸Ä±ä£¬Ôò¸Ã·½·¨½«´Ó»º´æÖÐ ......

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

Nested Members  ǶÌ׳ÉÔ±
    Since object members may contain other members, it's not uncommon to see patterns such as window.location.href in JavaScript code. These nested members cause the JavaScript engine to go through the object member resolution process each time a dot is ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØÍ¼ | ¸ÓICP±¸09004571ºÅ