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

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

Repaints and Reflows  ÖØ»æºÍÖØÅÅ°æ
    Once the browser has downloaded all the components of a page—HTML markup, JavaScript, CSS, images—it parses through the files and creates two internal data structures:
    µ±ä¯ÀÀÆ÷ÏÂÔØÍêËùÓÐÒ³ÃæHTML±ê¼Ç£¬JavaScript£¬CSS£¬Í¼Æ¬Ö®ºó£¬Ëü½âÎöÎļþ²¢´´½¨Á½¸öÄÚ²¿Êý¾Ý½á¹¹£º
A DOM tree
    A representation of the page structure
Ò»¿ÃDOMÊ÷
    ±íʾҳÃæ½á¹¹
A render tree
    A representation of how the DOM nodes will be displayed
Ò»¿ÃäÖȾÊ÷
    ±íʾDOM½ÚµãÈçºÎÏÔʾ
    The render tree has at least one node for every node of the DOM tree that needs to be displayed (hidden DOM elements don't have a corresponding node in the render tree). Nodes in the render tree are called frames or boxes in accordance with the CSS model that treats page elements as boxes with padding, margins, borders, and position. Once the DOM and the render trees are constructed, the browser can display ("paint") the elements on the page.
    äÖȾÊ÷ÖÐΪÿ¸öÐèÒªÏÔʾµÄDOMÊ÷½Úµã´æ·ÅÖÁÉÙÒ»¸ö½Úµã£¨Òþ²ØDOMÔªËØÔÚäÖȾÊ÷ÖÐûÓжÔÓ¦½Úµã£©¡£äÖȾÊ÷ÉϵĽڵã³ÆΪ“¿ò”»òÕß“ºÐ”£¬·ûºÏCSSÄ£Ð͵Ķ¨Ò壬½«Ò³ÃæÔªËØ¿´×÷Ò»¸ö¾ßÓÐÌî³ä¡¢±ß¾à¡¢±ß¿òºÍλÖõĺС£Ò»µ©DOMÊ÷ºÍäÖȾÊ÷¹¹ÔìÍê±Ï£¬ä¯ÀÀÆ÷¾Í¿ÉÒÔÏÔʾ£¨»æÖÆ£©Ò³ÃæÉϵÄÔªËØÁË¡£
    When a DOM change affects the geometry of an element (width and height)—such as a change in the thickness of the border or adding more text to a paragraph, resulting in an additional line—the browser needs to recalculate the geometry of the element as well as the geometry and position of other elements that could have been affected by the change. The browser invalidates the part of the render tree that was affected by the change and reconstructs the render tree. This process is known as a reflow. Once the reflow is complete, the browser redraws the affected parts of the screen in a


Ïà¹ØÎĵµ£º

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

µÚÈýÕ  DOM Scripting  DOM±à³Ì
    DOM scripting is expensive, and it's a common performance bottleneck in rich web applications. This chapter discusses the areas of DOM scripting that can have a negative effect on an application's responsiveness and gives recommendations o ......

[·­Òë]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().
 &nbs ......

javaScript¹Ø±Õä¯ÀÀÆ÷ (²»µ¯³öÌáʾ¿ò)

£¼script language="javaScript"£¾
function closeWindow()
{
¡¡window.opener = null;
¡¡window.open(' ', '_self', ' ');
¡¡window.close();
}
£¼/script£¾
£¼input type='button' value='¹Ø±Õ´°¿Ú' onClick="closeWindow()"£¾
»ò
£¼input type="button" value="¹ ......

Javascript¼ì²éÈÕÆÚ¸ñʽÊÇ·ñºÏ·¨µÄÒ»ÖÖ¼ò»¯·½·¨¡£

³£¹æµÄ·½·¨Êǽ«ÄêÔÂÈÕÈ¡³ö£¬È»ºó·Ö±ðÅжϷ¶Î§£¬È»ºó¾ÍÅжÏÈòÄê2ÔµÄÌìÊý
¿ÉÒÔͨ¹ýnew Date(string)µÄ¹¹Ô죬±È½ÏÄêÔÂÈÕ×Ö·ûÊÇ·ñ·¢Éú±ä»¯Åжϡ£
function CheckDate(text) {
if (!text) return false;
text = text.replace(/[\/-]0?/g, "/");
if (!text.match(/^\d{4}\/\d{1,2}\/\d{1,2}$/)) return true; ......

javascriptʵÏÖ×Ô¶¯ÇóºÍ

function total(){
var i=0;
for(j=1;j<=20;j++)
{
var step="step"+j;
if(document.getElementById(step)){
if(document.getElementById(step).checked==true)
{
i=i+parseInt(document.getElementById(step).value);
}
}
}
document.getElementById("total").innerHTML = i;
}
function Resetvalue(){
......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ