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

¼ÓËÙJavascript£ºDOM²Ù×÷ÓÅ»¯

Ô­ÎÄ£º¡¶Speeding up JavaScript: Working with the DOM¡·
×÷Õߣº KeeKim Heng, Google Web Developer
ÔÚÎÒÃÇ¿ª·¢»¥ÁªÍø¸»Ó¦Óã¨RIA£©Ê±£¬ÎÒÃǾ­³£Ð´Ò»Ð©javascript½Å±¾À´Ð޸ĻòÕßÔö¼ÓÒ³ÃæÔªËØ£¬ÕâЩ¹¤×÷×îÖÕÊÇDOM——»òÕß˵Îĵµ¶ÔÏóÄ£ÐÍ——À´Íê³ÉµÄ£¬¶øÎÒÃǵÄʵÏÖ·½Ê½»áÓ°Ïìµ½Ó¦ÓõÄÏìÓ¦Ëٶȡ£
DOM²Ù×÷»áµ¼ÖÂä¯ÀÀÆ÷ÖؽâÎö(reflow)£¬ÕâÊÇä¯ÀÀÆ÷µÄÒ»¸ö¾ö¶¨Ò³ÃæÔªËØÈçºÎÕ¹ÏֵļÆËã¹ý³Ì¡£Ö±½ÓÐÞ¸ÄDOM£¬ÐÞ¸ÄÔªËصÄCSSÑùʽ£¬ÐÞ¸Ää¯ÀÀÆ÷µÄ´°¿Ú´óС£¬¶¼»á´¥·¢ÖؽâÎö¡£¶ÁÈ¡ÔªËصIJ¼¾ÖÊôÐÔ±ÈÈçoffsetHeithe»òÕßoffsetWidthÒ²»á´¥·¢ÖؽâÎö¡£ÖؽâÎöÐèÒª»¨·Ñ¼ÆËãʱ¼ä£¬Òò´ËÖؽâÎö´¥·¢µÄÔ½ÉÙ£¬Ó¦ÓþͻáÔ½¿ì¡£
DOM²Ù×÷ͨ³£Òª²»¾ÍÊÇÐÞ¸ÄÒѾ­´æÔÚµÄÒ³ÃæÉϵÄÔªËØ£¬Òª²»¾ÍÊÇ´´½¨ÐµÄÒ³ÃæÔªËØ¡£ÏÂÃæµÄ4ÖÖÓÅ»¯·½°¸¸²¸ÇÁËÐ޸ĺʹ´½¨DOM½ÚµãÁ½ÖÖ·½Ê½£¬°ïÖúÄã¼õÉÙ´¥·¢ä¯ÀÀÆ÷ÖؽâÎöµÄ´ÎÊý¡£
·½°¸Ò»£ºÍ¨¹ýCSSÀàÃûÇл»À´ÐÞ¸ÄDOM
Õâ¸ö·½°¸ÈÃÎÒÃÇ¿ÉÒÔÒ»´ÎÐÔÐÞ¸ÄÒ»¸öÔªËغÍËüµÄ×ÓÔªËصĶà¸öÑùʽÊôÐÔ¶øÖ»´¥·¢Ò»´ÎÖؽâÎö¡£
ÐèÇó£º
£¨emu×¢£ºÔ­ÎÄ×÷Õßдµ½ÕâÀïµÄʱºòÄÔ×ÓÏÔÈ»¶Ì·ÁËһϣ¬°ÑºóÃæµÄOut-of-the-flow DOM ManipulationģʽҪ½â¾öµÄÎÊÌâ¸ø°Úµ½ÕâÀïÀ´ÁË£¬²»¹ý´Óʾ·¶´úÂëÖкÜÈÝÒ×Ã÷°××÷ÕßÕæÕýÏëÃèÊöµÄÎÊÌ⣬Òò´Ëemu¾Í²»ÕÕ·­Ô­ÎÄÁË£©
ÎÒÃÇÏÖÔÚÐèҪдһ¸öº¯ÊýÀ´ÐÞ¸ÄÒ»¸ö³¬Á´½ÓµÄ¼¸¸öÑùʽ¹æÔò¡£ÒªÊµÏֺܼòµ¥£¬°ÑÕ⼸¸ö¹æÔò¶ÔÓ¦µÄÊôÐÔÖðÒ»¸ÄÁ˾ͺÃÁË¡£µ«ÊÇ´øÀ´µÄÎÊÌâÊÇ£¬Ã¿ÐÞ¸ÄÒ»¸öÑùʽÊôÐÔ£¬¶¼»áµ¼ÖÂÒ»´ÎÒ³ÃæµÄÖؽâÎö¡£
function selectAnchor(element) {  
  element.style.fontWeight = 'bold';  
  element.style.textDecoration = 'none';  
  element.style.color = '#000';  

function selectAnchor(element) {
  element.style.fontWeight = 'bold';
  element.style.textDecoration = 'none';
  element.style.color = '#000';
}
½â¾ö·½°¸
Òª½â¾öÕâ¸öÎÊÌ⣬ÎÒÃÇ¿ÉÒÔÏÈ´´½¨Ò»¸öÑùʽÃû£¬²¢ÇÒ°ÑÒªÐ޸ĵÄÑùʽ¹æÔò¶¼·Åµ½Õâ¸öÀàÃûÉÏ£¬È»ºóÎÒÃǸø³¬Á´½ÓÌí¼ÓÉÏÕâ¸öÐÂÀàÃû£¬¾Í¿ÉÒÔʵÏÖÌí¼Ó¼¸¸öÑùʽ¹æÔò¶øÖ»´¥·¢Ò»´ÎÖؽâÎöÁË¡£Õâ¸öģʽ»¹ÓиöºÃ´¦ÊÇҲʵÏÖÁ˱íÏÖºÍÂß¼­Ïà·ÖÀë¡£
.selectedAnchor {  
  font-weight: bold;  
  text-decoration: none;  
  color: #000;  


Ïà¹ØÎĵµ£º

JavaScript ÅжÏÎļþÊÇ·ñ´æÔÚ

1. ¿Í»§¶Ë //Ö÷ÒªÕë¶Ô±¾µØIEä¯ÀÀÆ÷·ÃÎÊ
<script
language="javascript">
function FileExist()
{
     var sfso=new
ActiveXObject("Scripting.FileSystemObject");
     var fPath="[The path of the
file]";
     if(sfso.FileExists(fP ......

JavaScriptÎļþ²Ù×÷

Ò»¡¢¹¦ÄÜʵÏÖºËÐÄ£ºFileSystemObject ¶ÔÏó
    ÒªÔÚjavascriptÖÐʵÏÖÎļþ²Ù×÷¹¦ÄÜ£¬Ö÷Òª¾ÍÊÇÒÀ¿¿FileSystemobject¶ÔÏó¡£
¶þ¡¢FileSystemObject±à³Ì
ʹÓÃFileSystemObject ¶ÔÏó½øÐбà³ÌºÜ¼òµ¥£¬Ò»°ãÒª¾­¹ýÈçϵIJ½Ö裺 ´´½¨FileSystemObject¶ÔÏó¡¢Ó¦ÓÃÏà¹Ø·½·¨¡¢·ÃÎʶÔÏóÏà¹ØÊôÐÔ ¡£
£¨Ò»£©´´½¨FileSy ......

JavaScript »ñÈ¡ä¯ÀÀÆ÷µÄÏÔʾÇøÓò´óСÐÅÏ¢

ÍøÒ³¿É¼ûÇøÓò¿í£ºdocument.body.clientWidth;
ÍøÒ³¿É¼ûÇøÓò¸ß£ºdocument.body.clientHeight;
ÍøÒ³¿É¼ûÇøÓò¸ß£ºdocument.body.offsetWidth (°üÀ¨±ßÏߵĿí);
ÍøÒ³¿É¼ûÇøÓò¸ß£ºdocument.body.offsetHeight (°üÀ¨±ßÏߵĿí);
ÍøÒ³ÕýÎÄÈ«ÎÄ¿í£ºdocument.body.scrollWidth;
ÍøÒ³ÕýÎÄÈ«Îĸߣºdocument.body.scrollHeight; ......

Java 6 ÖÐÒ²¿ÉÒÔÔËÐÐ javascript ච(ת)

¸ø Java SE ×¢Èë½Å±¾ÓïÑԵĻîÁ¦
Mustang µÄ½Å±¾ÓïÑÔÐÂÌØÐÔ

ÎĵµÑ¡Ïî

½«´ËÒ³×÷Ϊµç×ÓÓʼþ·¢ËÍ

½«´ËÒ³×÷Ϊµç×ÓÓʼþ·¢ËÍ



¼¶±ð£º Öм¶
Îâ 玥ò« (wuyuehao@cn.ibm.com), Èí¼þ¹¤³Ìʦ, IBM
2006 Äê 10 ÔÂ 30 ÈÕ
ÔÚ¼´½«·¢²¼µÄ Java SE6£¨Mustang£©ÖУ¬Ôö¼ÓÁ˶Խű¾ÓïÑÔµÄÖ§³Ö¡£Í¨¹ý¶Ô½Å± ......

Ò»´Î¾ªÏÕµÄjavascript¾­Àú£¬º¹£¬ÏÖÔÚÏëÏ붼ºóÅÂ

ÔÚ¿ª·¢Ò»¸ö½É·Ñ½»Ò×ʱ£¬ÏÈ·¢ËͲéѯÇëÇóµ½ÏµÍ³A£¬ÏµÍ³A·µ»ØÒ»¸ö×Ö·û´®¸ñʽµÄÇ··Ñ½ð¶î£¬ÒòΪÊǶ¨³¤µÄ£¬ËùÒÔ¶¼ÊÇÇ°²¹0£¬±¾À´ÐèÒªÏÈ×ö´¦ÀíµÄ£¬µ«ÊÇÓÉÓÚ²éѯ½á¹ûÈç¹ûÊÇÇ··ÑµÄ£¬¿Í»§·¢Æð½É·Ñ½»Ò×ʱ£¬»áË͸øϵͳBµÄ¸ñʽ£¬ÓëϵͳA·µ»ØµÄÊÇÒ»ÑùµÄ£¬Òò´Ë¾ÍÔ­Ñù±£´æÈ»ºóÉÏËÍ£¬¿ÉÊÇÔÚϵͳ²âÊÔʱ£¬È´·¢ÏÖÁËÒ»¸öÆæ¹ÖµÄÏÖÏó£¬ÏµÍ³A·µ»ØµÄ²é ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ