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

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

Dynamic Script Elements  ¶¯Ì¬½Å±¾ÔªËØ
    The Document Object Model (DOM) allows you to dynamically create almost any part of an HTML document using JavaScript. At its root, the <script> element isn't any different than any other element on a page: references can be retrieved through the DOM, and they can be moved, removed from the document, and even created. A new <script> element can be created very easily using standard DOM methods:
    Îĵµ¶ÔÏóÄ£ÐÍ£¨DOM£©ÔÊÐíÄãʹÓÃJavaScript¶¯Ì¬´´½¨HTMLµÄ¼¸ºõÈ«²¿ÎĵµÄÚÈÝ¡£Æä¸ù±¾ÔÚÓÚ£¬<script>ÔªËØÓëÒ³ÃæÆäËûÔªËØûÓÐʲô²»Í¬£ºÒýÓñäÁ¿¿ÉÒÔͨ¹ýDOM½øÐмìË÷£¬¿ÉÒÔ´ÓÎĵµÖÐÒƶ¯¡¢É¾³ý£¬Ò²¿ÉÒÔ±»´´½¨¡£Ò»¸öеÄ<script>ÔªËØ¿ÉÒԷdz£ÈÝÒ×µØͨ¹ý±ê×¼DOMº¯Êý´´½¨£º
var script = document.createElement_x("script");
script.type = "text/javascript";
script.src = "file1.js";
document.getElementsByTagName("head")[0].appendChild(script);
    This new <script> element loads the source file file1.js. The file begins downloading as soon as the element is added to the page. The important thing about this technique is that the file is downloaded and executed without blocking other page processes, regardless of where the download is initiated. You can even place this code in the <head> of a document without affecting the rest of the page (aside from the one HTTP connection that is used to download the file).
    еÄ<script>ÔªËؼÓÔØfile1.jsÔ´Îļþ¡£´ËÎļþµ±ÔªËØÌí¼Óµ½Ò³ÃæÖ®ºóÁ¢¿Ì¿ªÊ¼ÏÂÔØ¡£´Ë¼¼ÊõµÄÖصãÔÚÓÚ£ºÎÞÂÛÔںδ¦Æô¶¯ÏÂÔØ£¬ÎļþµÄÏÂÔغÍÔËÐж¼²»»á×èÈûÆäËûÒ³Ãæ´¦Àí¹ý³Ì¡£ÄãÉõÖÁ¿ÉÒÔ½«ÕâЩ´úÂë·ÅÔÚ<head>²¿·Ö¶ø²»»á¶ÔÆäÓಿ·ÖµÄÒ³Ãæ´úÂëÔì³ÉÓ°Ï죨³ýÁËÓÃÓÚÏÂÔØÎļþµÄHTTPÁ¬½Ó£©¡£
    When a file is downloaded using a dynamic script node, the retrieved code is typically executed immediately (except in Firefox and Opera, which will wait until any previous dynamic script nodes have executed). This works well when the script is self-executing but


Ïà¹ØÎĵµ£º

JavaScript ¹¹Ô캯Êý myhere

/**
* JavaScript ÊÇÃæÏò¶ÔÏóµÄÓïÑÔ£¬µ«ÊÇËûµÄÃæÏò¶ÔÏó²»ÊÇ»ùÓÚÀàµÄ£¬ÊÇ»ùÓÚÔ­Ð͵Ä;
* µ«ÊÇËûµÄһЩÌØÐÔ(º¯ÊýÊÇÊý¾Ý)£¬Ê¹µÃËü¿ÉÒÔÄ£Äâ»ùÓÚÀàµÄÃæÏò¶ÔÏ󣬵«ÊÇ JavaScript ²¢²»Ö§³ÖºÍ Java Ò»ÑùµÄÀ࣬
* Òò´Ë JavaScript ÖеÄ"Àà"¿ÉÒÔ³Æ×÷"αÀà"
*/
//
/**
* ¹¹Ô캯Êý: js ÖÐÓÃÀ´ºÍ new ÔËËã·ûÒ»ÆðʹÓõĺ¯Êý³Æ× ......

Javascript ¶ÔÏóµÄ±È½Ï

Õâ¸öËæ±ÊÆäʵÊÇΪÁ˸ÐлÇå·çЦ¸øµÄÒ»¸öÌáʾ£¬²»½ö½öÊǸæËßÎÒÔõôÅжÏÊý×飬¸üÈÃÎÒÓÐÁËÈÏÕæ¶ÁÒ»¶Á ¡¶javascriptȨÍþÖ¸ÄÏ¡·µÄÏë·¨¡£
±È½ÏºÍ¿½±´ÆäʵÊÇÒ»»ØÊ£¬´úÂëÈçÏ£º
//
//Compare object function
//
function Compare(fobj,sobj)
{
    var ftype = typ ......

javascript³£ÓÃ

calcu()  ----º¯ÊýʵÏÖÁ½¸öÊýÏà³Ë
document.write();  ---´òÓ¡
document.calc.ÔªËØÃû.value;  --»ñµÃ±íµ¥µÄÖµ
document.±íµ¥Ãû¡£±íµ¥ÔªËØÃû¡£value  Ϊ±íµ¥¸³Öµ
¶¨Ò庯Êý£º
 function  Ãû×Ö()
 {
    //javaScriptÔ¤Óï¾ä
 }
 onClick="º¯ÊýÃû";  ......

JavaScriptÖÐDOMÊ÷µÄNode½Ó¿ÚµÄһЩ¼òµ¥Ó¦ÓÃ

1. ÓÃÀàÃû²éÕÒÔªËØ
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN
" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd
">
<html xmlns="http://www.w3.org/1999/xhtml
" >
<head>
<title>Untitled Page</title>
......

JavascriptµÄÔ­ÐͶÔÏóºÍprototypeÊôÐÔ

     JavascriptÖеļ̳лúÖÆÊÇËùνµÄÔ­ÐͶÔÏó¼Ì³Ð£¬Í¨¹ýÊôÐÔ·ÃÎÊ»úÖƵÄÌØÊâÐÔÀ´ÊµÏּ̳еġ£Ö®Ç°ÎÒÒ»Ö±ÒÔΪËùÓжÔÏóµÄÔ­ÐͶÔÏó¾ÍÊÇprototypeËùÖ¸µÄÄǸö¶ÔÏ󡣺óÀ´ÔÚ¿´javascriptÉè¼ÆģʽµÄʱºò·¢ÏÖ×÷Õß×¢ÖÐÓÐÒ»¾ä»°ÓëÎÒ֮ǰµÄÀí½â²»Í¬£¬Ëû˵“ÿ¸ö¶ÔÏó¶¼ÓÐÒ»¸öÔ­ÐͶÔÏ󣬵«Õâ²¢²»Òâζ×Åÿ¸ö¶ÔÏó¶ ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ