JS¼¼Êõ

document.onLoadµÄ´¥·¢Ê±¼ä

×ÖºÅ+ ×÷Õߣº À´Ô´£º    2014-11-17 20:00 ÎÒÒªÆÀÂÛ( )

document.onLoadµÄ´¥·¢Ê±¼ä,ÔĶÁdocument.onLoadµÄ´¥·¢Ê±¼ä,×òÌìÔÚдһ¸öÍøÒ³ÌØЧʱ£¬×ÜÊÇÌáʾ´íÎó¡£Ò»Ö±µ½½ñÌìͨ¹ýÒ»¸öʾÀý²ÅÖªµÀÔ­Òò¡£ÎÒÒ»Ö±ÈÏΪʹÓÃjavascriptµÄdocument.onLoadÖ¸¶¨Ò»¸öº¯Êý£¬¸úÔÚBody±êÇ©ÖмÓÈëonLoadÊÇÒ»ÑùµÄ²»¹ýÄܹý½ñÌìµÄʾÀý·¢ÏÖ£¬d

×òÌìÔÚдһ¸öÍøÒ³ÌØЧʱ£¬×ÜÊÇÌáʾ´íÎó¡£Ò»Ö±µ½½ñÌìͨ¹ýÒ»¸öʾÀý²ÅÖªµÀÔ­Òò¡£

ÎÒÒ»Ö±ÈÏΪʹÓÃjavascriptµÄdocument.onLoadÖ¸¶¨Ò»¸öº¯Êý£¬¸úÔÚBody±êÇ©ÖмÓÈëonLoadÊÇÒ»ÑùµÄ
²»¹ýÄܹý½ñÌìµÄʾÀý·¢ÏÖ£¬document.onLoad²¢²»ÊÇÔÚÒ³Ãæ¼ÓÔØÍê³ÉʱÒý·¢¡£
ʾÀý´úÂëÈçÏ£º£¨²âÊÔ»·¾³Win2003 + IE7£©

 1<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
 2<html>
 3<head>
 4<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
 5<title>ÎÞ±êÌâÎĵµ</title>
 6<script language="JavaScript">
 7function mytest(){
 8    alert(document.getElementById("my2"));
 9}
10document.onLoad = mytest();
11</script>
12</head>
13
14<body>
15<p id="my2">²âÊÔÄÚÈÝ</p>
16</body>
17</html>
´ò¿ªÊ¾ÀýÖеÄhtmÎļþʱ£¬ÔÚÒ³ÃæûÓÐÍêÈ«ÏÔʾ£¬¼´°×ÆÁµÄʱºî¾Íµ¯³öÌáʾ¶Ô»°¿òÁË¡£ËµÃ÷mytestÔÚÒ³ÃæûÓÐÏÔʾÍê³Éʱ¾Í±»µ÷Óá£

×¢Ê͵ôdocument.onLoadÕâ¾ä£¬È»ºóÐÞ¸Äbody±êǩΪ

<body onLoad="mytest()">
ÖØдò¿ªÒ³Ã棬´Ëʱ²ÅÊÇÒ³Ãæ¼ÓÔØÍê³Éºó²Åµ÷ÓÃmytest¡£²»ÖªµÀʲôԭÒò£¬ºÇºÇ¡£

¡¡

1.±¾Õ¾×ñÑ­ÐÐÒµ¹æ·¶£¬ÈκÎתÔصĸå¼þ¶¼»áÃ÷È·±ê×¢×÷ÕߺÍÀ´Ô´£»2.±¾Õ¾µÄÔ­´´ÎÄÕ£¬ÇëתÔØʱÎñ±Ø×¢Ã÷ÎÄÕÂ×÷ÕߺÍÀ´Ô´£¬²»×ðÖØÔ­´´µÄÐÐΪÎÒÃǽ«×·¾¿ÔðÈΣ»3.×÷ÕßͶ¸å¿ÉÄܻᾭÎÒÃDZ༭Ð޸Ļò²¹³ä¡£

Ïà¹ØÎÄÕÂ
  • ѧϰJavaScriptÖ®this,call,apply

    ѧϰJavaScript֮this,call,apply

    2016-01-28 20:45

  • Áã»ù´¡ÈëÃÅѧϰPython£¨10£©£ºº¯Êý - qq_33256568µÄ²©¿Í - ²©¿ÍƵµÀ - CSDN.NET qq_3

    Áã»ù´¡ÈëÃÅѧϰPython£¨10£©£ºº¯Êý - qq_33256568µÄ²©¿Í - ²©¿ÍƵµÀ

    2015-12-15 09:04

  • Swift 2.0ѧϰ±Ê¼Ç£¨Day48£©¡ª¡ªÀàÐͼì²éÓëת»» - ¹Ø¶«Éý - ²©¿ÍƵµÀ - CSDN.NET ¹Ø¶«Éý iO

    Swift 2.0ѧϰ±Ê¼Ç£¨Day48£©¡ª¡ªÀàÐͼì²éÓëת»» - ¹Ø¶«Éý - ²©¿ÍƵµÀ

    2015-12-14 18:16

  • ÓÐȤµÄRuby-ѧϰ±Ê¼Ç1 - ÎÒ¿ÉÒÔ½ÓÊÜʧ°Ü£¬µ«ÎÒ²»ÄܽÓÊÜ·ÅÆú¡£--Âõ¿Ë¶û Çǵ¤ - ²©¿ÍƵµÀ - CSDN.NET

    ÓÐȤµÄRuby-ѧϰ±Ê¼Ç1 - ÎÒ¿ÉÒÔ½ÓÊÜʧ°Ü£¬µ«ÎÒ²»ÄܽÓÊÜ·ÅÆú¡£--Âõ¿Ë

    2015-12-14 17:17

ÍøÓѵãÆÀ
È