Ò׽ؽØͼÈí¼þ¡¢µ¥Îļþ¡¢Ãâ°²×°¡¢´¿ÂÌÉ«¡¢½ö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¾Í²»ÕÕ·­Ô­ÎÄÁË£©
ÎÒÃÇÏÖÔÚÐèҪдһ¸öº¯ÊýÀ´ÐÞ¸ÄÒ»¸ö³¬Á´½ÓµÄ¼¸¸öÑùʽ¹æÔò¡£ÒªÊµÏֺܼòµ¥£¬°ÑÕ⼸¸ö¹æÔò¶ÔÓ¦µÄÊôÐÔÖðÒ»¸ÄÁ˾ͺÃÁË¡£µ«ÊÇ´øÀ´µÄÎÊÌâÊÇ£¬Ã¿ÐÞ¸ÄÒ»¸öÑùʽ
ÊôÐÔ£¬¶¼»áµ¼ÖÂÒ»´ÎÒ³ÃæµÄÖؽâÎö¡£
view
plain
copy
to clipboard
print
?
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';
}
½â¾ö·½°¸
Òª½â¾öÕâ¸öÎÊÌ⣬ÎÒÃÇ¿ÉÒÔÏÈ´´½¨Ò»¸öÑùʽÃû£¬²¢ÇÒ°ÑÒªÐ޸ĵÄÑùʽ¹æÔò¶¼·Åµ½Õâ¸öÀàÃûÉÏ£¬È»ºóÎÒÃǸø³¬Á´½ÓÌí¼ÓÉÏÕâ¸öÐÂÀàÃû£¬¾Í¿ÉÒÔʵÏÖÌí¼Ó¼¸¸öÑùʽ
¹æÔò¶øÖ»´¥·¢Ò»´ÎÖؽâÎöÁË¡£Õâ¸öģʽ»¹ÓиöºÃ´¦ÊÇҲʵÏÖÁ˱íÏÖºÍÂß¼­Ïà·ÖÀë¡£
view
plain
copy
to clipboard
p


Ïà¹ØÎĵµ£º

107ÌõJavascriptµÄ³£ÓÃÓï¾ä

1.         document.write( " "); Êä³öÓï¾ä
2.JSÖеÄ×¢ÊÍΪ//
3.´«Í³µÄHTMLÎĵµË³ÐòÊÇ:document- >html- >(head,body)
4.Ò»¸öä¯ÀÀÆ÷´°¿ÚÖеÄDOM˳ÐòÊÇ:window- >(navigator,screen,history,location,document)
5.µÃµ½±íµ¥ÖÐÔªËصÄÃû³ÆºÍÖµ:document.getElementById( "±íµ¥ ......

JavaScriptº¯Êý±Õ°ü(closure) µÄÀí½â

×Ô´ÓѧϰJavaScriptÒÔÀ´£¬Ò»Ö±¶Ôº¯Êý±Õ°ü²»ÊÇÌ«Àí½â¡£ÖªµÀ´ó¸ÅÊÇʲô¸öÒâ˼£¬µ«ÊÇÒª½«Ò»¸ö²»»áµÄÈ˽̻ỹÕæ²»ÐС£×ÜÖ®¾ÍÊDz»Äܳ¹µ×µÄÀí½â¡£
½ñÌì¿´µ½µÄÕâƪÎÄÕ¸оõ²»´í£¬ºÍ´ó¼Ò·ÖÏíһϡ£
http://www.felixwoo.com/archives/247 ......

JavaScript constructorÊôÐÔ

Definition and Usage
¶¨ÒåÓëÓ÷¨The constructor property is a reference to the function that created an object.
constructorÊôÐÔÊÇËù½¨Á¢¶ÔÏóµÄº¯Êý²Î¿¼Syntax
Óï·¨object.constructor
Example 1
¾ÙÀý
In this example we will show how to use the constructor property:
ÔÚÕâ¸ö¾ÙÀýÖÐÎÒÃǽ«Õ¹Ê¾ÈçºÎʹÓÃcons ......

Javascript+css ʵÏÖÍøÒ³»»·ô¹¦ÄÜ


ÏÖÔÚÍøÕ¾»»Æ¤·ôÊDZȽϳ£¼ûµÄ¹¦ÄÜ£¬´ó¶àÊýÂÛ̳¶¼Óеģ¬ÒªÏëʵÏÖÕâÑùЧ¹û¿ÉÒÔ¿´ÈçÏ´úÂ룺Html´úÂ벿·Ö:
1.ÒªÓÐÒ»¸ö´øidµÄÑùʽ±íÁ´½Ó,ÎÒÃÇҪͨ¹ý²Ù×÷Õâ¸öÁ´½ÓÀ´µ÷Óò»Í¬µÄhref.
<link href="css/main0.css" rel="stylesheet" type="text/css" id="cssfile" />
2.Ƥ·ôÑ¡Ôñ°´Å¥(ºǫ́Ϊÿ¸öliÌí¼Óonclickʼþ,´¥·¢»»· ......

javascriptÒ»¶Îʱ¼ä´úÂë

<SCRIPT language=javaScript>
<!--
now = new Date(),hour = now.getHours()
if(hour < 6){document.write("Á賿ºÃ!")}
else if (hour < 9){document.write("ÔçÉϺã¡")}
else if (hour < 12){document.write("ÉÏÎçºÃ£¡")}
else if (hour < 14){document.write("ÖÐÎçºÃ£¡")}
else if (hour &l ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ