Ò׽ؽØÍ¼Èí¼þ¡¢µ¥Îļþ¡¢Ãâ°²×°¡¢´¿ÂÌÉ«¡¢½ö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ÖÐevent.keycode

javascriptÖÐevent.keycode
 keycode 8 = BackSpace BackSpace
keycode 9 = Tab Tab
keycode 12 = Clear
keycode 13 = Enter
keycode 16 = Shift_L
keycode 17 = Control_L
keycode 18 = Alt_L
keycode 19 = Pause
keycode 20 = Caps_Lock
keycode 27 = Escape Escape
keycode 32 = space space ......

ÀûÓÃhttpµÄrefererÍ·ºÍServletÒþ²ØJavaScript´úÂë

1.       ¶¨ÒåÒ»¸öÓÃÓÚÊä³öJavaScript´úÂë µÄServletÀà¡£
package com.mycompany.response.servlet;
import java.io.IOException;
import java.io.PrintWriter;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServle ......

ÓÉdzµ½ÉîÁ˽âJavaScriptÀà

ÀàÊÇʲô£¿
    
   Ðí¶à¸Õ½Ó´¥±à³ÌµÄÅóÓѶ¼¿ÉÄÜÀí½â²»ÁËÀ࣬ÆäʵÀàÊǶÔÎÒÃÇÕâ¸öÏÖʵÊÀ½çµÄÄ£Ä⣬°ÑËü˵³É“Àà±ð”»òÕß“ÀàÐÍ”¿ÉÄÜ»á¸üÈÝÒ×Àí½âһЩ¡£±ÈÈç“ÈË”ÕâÖÖ¶¯
Îï¾ÍÊÇÒ»¸öÀ࣬¶ø¾ßÌåijһ¸öÈ˾ÍÊÇ“ÈË”Õâ¸öÀàµÄÒ»¸öʵÀý
£¬
“È ......

javascript¿ØÖÆtextbox×ÖÊýµÄ½Å±¾ ·Ç³£ºÃÓÃ

ÒÔǰ×öÏîĿʱºò¾­³£Óõ½¶àÐÐÊäÈë¿ò×ÖÊýµÄ¿ØÖÆÒÔ¼°Í³¼ÆÏÔʾµÄÇé¿ö£¬×ÛºÏÁ˼¸ÖÖÇé¿öºóÏÖÔڹ̶¨ÓÃÁËÕâ¸ö½Å±¾¡£
ÀýÈç ÒªÊäÈëÃèÊötextbox
<div>
<h3>
ÃèÊö£º</h3>
<asp:TextBox runat="server" ID="tbdesciption" Height="200px" TextMode="MultiLine" onkey ......

JavaScriptÀûÓÃDOM¸øÒ³ÃæÌí¼ÓÄÚÈÝ

×Ô¶¨ÒåÒ»¸ölogº¯Êý,Êä³ö´«È뺯ÊýµÄ¶ÔÏó»òÕßÐÅÏ¢.
Log.js
// JScript source code
function
log(category, message, object) {
// If this category is explicitly disabled, do nothing
if
(log.options[category + "Disabled
"]) return
;
// Find the container
var
id = categ ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØÍ¼ | ¸ÓICP±¸09004571ºÅ