¼ÓËÙ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;
}
Ïà¹ØÎĵµ£º
1. ¿Í»§¶Ë //Ö÷ÒªÕë¶Ô±¾µØIEä¯ÀÀÆ÷·ÃÎÊ
<script
language="javascript">
function FileExist()
{
var sfso=new
ActiveXObject("Scripting.FileSystemObject");
var fPath="[The path of the
file]";
if(sfso.FileExists(fP ......
Ò»¡¢¹¦ÄÜʵÏÖºËÐÄ£ºFileSystemObject ¶ÔÏó
ÒªÔÚjavascriptÖÐʵÏÖÎļþ²Ù×÷¹¦ÄÜ£¬Ö÷Òª¾ÍÊÇÒÀ¿¿FileSystemobject¶ÔÏó¡£
¶þ¡¢FileSystemObject±à³Ì
ʹÓÃFileSystemObject ¶ÔÏó½øÐбà³ÌºÜ¼òµ¥£¬Ò»°ãÒª¾¹ýÈçϵIJ½Ö裺 ´´½¨FileSystemObject¶ÔÏó¡¢Ó¦ÓÃÏà¹Ø·½·¨¡¢·ÃÎʶÔÏóÏà¹ØÊôÐÔ ¡£
£¨Ò»£©´´½¨FileSy ......
ÍøÒ³¿É¼ûÇøÓò¿í£ºdocument.body.clientWidth;
ÍøÒ³¿É¼ûÇøÓò¸ß£ºdocument.body.clientHeight;
ÍøÒ³¿É¼ûÇøÓò¸ß£ºdocument.body.offsetWidth (°üÀ¨±ßÏߵĿí);
ÍøÒ³¿É¼ûÇøÓò¸ß£ºdocument.body.offsetHeight (°üÀ¨±ßÏߵĿí);
ÍøÒ³ÕýÎÄÈ«ÎÄ¿í£ºdocument.body.scrollWidth;
ÍøÒ³ÕýÎÄÈ«Îĸߣºdocument.body.scrollHeight;
......
¸ø Java SE ×¢Èë½Å±¾ÓïÑԵĻîÁ¦
Mustang µÄ½Å±¾ÓïÑÔÐÂÌØÐÔ
ÎĵµÑ¡Ïî
½«´ËÒ³×÷Ϊµç×ÓÓʼþ·¢ËÍ
½«´ËÒ³×÷Ϊµç×ÓÓʼþ·¢ËÍ
¼¶±ð£º Öм¶
Îâ 玥ò« (wuyuehao@cn.ibm.com), Èí¼þ¹¤³Ìʦ, IBM
2006 Äê 10 ÔÂ 30 ÈÕ
ÔÚ¼´½«·¢²¼µÄ Java SE6£¨Mustang£©ÖУ¬Ôö¼ÓÁ˶Խű¾ÓïÑÔµÄÖ§³Ö¡£Í¨¹ý¶Ô½Å± ......
ÔÚ¿ª·¢Ò»¸ö½É·Ñ½»Ò×ʱ£¬ÏÈ·¢ËͲéѯÇëÇóµ½ÏµÍ³A£¬ÏµÍ³A·µ»ØÒ»¸ö×Ö·û´®¸ñʽµÄÇ··Ñ½ð¶î£¬ÒòΪÊǶ¨³¤µÄ£¬ËùÒÔ¶¼ÊÇÇ°²¹0£¬±¾À´ÐèÒªÏÈ×ö´¦ÀíµÄ£¬µ«ÊÇÓÉÓÚ²éѯ½á¹ûÈç¹ûÊÇÇ··ÑµÄ£¬¿Í»§·¢Æð½É·Ñ½»Ò×ʱ£¬»áË͸øϵͳBµÄ¸ñʽ£¬ÓëϵͳA·µ»ØµÄÊÇÒ»ÑùµÄ£¬Òò´Ë¾ÍÔÑù±£´æÈ»ºóÉÏËÍ£¬¿ÉÊÇÔÚϵͳ²âÊÔʱ£¬È´·¢ÏÖÁËÒ»¸öÆæ¹ÖµÄÏÖÏó£¬ÏµÍ³A·µ»ØµÄ²é ......