<DIV ID="div1"></DIV>µM«á§A¦bºô¶¨ä¥L¦a¤è´¡¤J Script ¥[¥H°õ¦æ¤U±ªº±Ôz¡G
var str="",obj; for (obj in document.layers) {str+=obj+" : "+document.layers[obj]+"\n";} alert(str);µ²ªG¬O - length:0 -¡Aªí¥Ü¸Óºô¶¨S¦³ layer ¤¸¥óªº¦s¦b¡A³o®É§A¦A§âè¤~¨ºÓ DIV ¼ÐÅÒ§ï¤@¤U¡G
<DIV ID="div1" STYLE="position:absolute"></DIV>µM«á¦A°õ¦æ¤@¤Uè¤~ªº Script ¡A§A·|µoıµ²ªG¬O¡G
length:1 div1:[object layer]³oªí¥Ü쥻 HTML ªº DIV ¼ÐÅÒ¡A³o·|¦¨¤F layers ¶°¦Xªº¤@³¡¥÷¡A¤É®æ¨ì¥i¥H¹³ LAYER ¤@¼Ë§ïÅÜÅã¥ÜÄݩʤΦ³«·s§ï¼g¯à¤O¤F¡C¨ä¹ê¤£¥u DIV ¡A¨ä¥L HTML ¤¤¥i°µ ¥]ÂФå¦r¤º®eªº¼ÐÅÒ¡A¦p <SPAN>,<P>......µ¥¡A³q³q¥i¥H¥Î³o¤è¦¡¤É®æ ¦¨·Ç LAYER ¤¸¥ó¨Ó¨Ï¥Î¡C³o¤~¬O Netscape ¦w±Æ¯u¥¿ªº¥Î·N¡A´N¬O LAYER ªº´£¥X¡A ¤£¥u¦³ LAYER ¤@Ó¼ÐÅÒ¯à¥Î¡A¦Ó¬O¨ä¥L¥]ÂмÐÅÒ¤]¯à¨Ï¥Î¡A¦b§OªºÂsÄý¾¹¤¤§â¥¦Ì ·í°µ DIV,SPAN,P ³B²z¡A¦Ó Netscape «h¤@·§·í°µ LAYER ¨Ó¸Ñ¨M¡C¨º»ò Cross Browser ¦b Netscape ùدuªº³o»òÃø¶Ü¡HÁÙ¬O§A¤@¦V»~¸Ñ¤F Netscape¡H ¦^¿ï³æ
item0.style.visibility="visible" /* or */ item0.style.visibility="hidden" /* ¦]¬° visibility ¬O style ª«¥óªºªþÄÝÄÝ©Ê */¦ý¦pªG¬O Netscape ¡AÁöµM¥¦ªº Layer ¤@¼Ë¤ä´© ID ÄݩʡA¦ý¥i¤£ªí¥Ü¥¦¥i¹³ Explorer ¤@¼Ë¡Aª½±µ©I¥s item0 ´N¥i¥H¤F¡A§AÁÙ¬On«ö·Ó Netscape ¤@¦Vªº¶¥¼h ª«¥ó©I¥sªº¤è¦¡¡A¦p¡G
document.item0.visibility="visible or hidden"; /* or */ document.layers.item0.visibility="visible or hidden"; /* 1.«ØÄ³¨Ï¥Î«á¤@ºØ©I¥s¡A¦]¬°¬O¤@¯ëªº°ò¥»ªk«h¡C 2.visibility ¬O Layer ªºª½±µÄݩʡA¤£»Ý¥[ style ¡A¤]¨S¦³ style ³oªF¦è¡C */¦ý¹³¥»½d¨Ò¬O±Ä¥Î¨â¼h¥]»qªº DIV ¼ÐÅÒ¡A¦p¡G
<DIV ID="MenuLine" ...> <DIV ID="item0" ...> /* ............. */ </DIV> </DIV>ÁöµM Explorer ªº©I¥s¤è¦¡¤£ÅÜ¡A¦ý Netscape «on§ï¦¨¡G
document.layers.MenuLine.layers.item0.visibility="visible or hidden"; /* ¥H¤W¬O¨â¼h layer ©I¥s¡A¦pªG¤T¼h¨º´N¬O¡G */ document.layers.MenuLine.layers.subgroup.layers.item0.visibility="visible or hidden"; /* ¦pªG¥|¼h¡A¤Ñ§o§O»¡¤F¡AÂsÄý¾¹n¶ëÃz¤F¡C */¦Ü©ó¤À§O¨ÌÂsÄý¾¹°õ¦æ¤£¦Pµ{¦¡½X¡A§Ú̱˱ó³Ì±`¥Î°»´úÂsÄý¾¹ª«¥ó navigator ÄÝ©ÊȪº¤èªk¡A¦Ó§ï¥Î¯S®íª«¥ó°»´úªk¡CÄ´¦p Explorer document ©³¤U¦³Ó all ¶°¦Xª«¥ó¡A¨º§ÚÌ´N¥i¥Î¡G
if (document.all) { /* ...... IE ª«¥ó¾Þ§@±Ôz */ } /* ¦]¬° Explorer ùئ³ all ³oÓ¶°¦Xª«¥ó¡A©Ò¥H·|¶Ç¦^¯uÈ¡A°õ¦æ if °Ï¬qùتº Script¡C ¦ý Navigator ¦]¬°¨S¦³ all ¶°¦Xª«¥ó¡A©Ò¥H¶Ç¦^°°È¡A¤£°õ¦æ if °Ï¬qùتº Script¡C */¦P¼Ëªº¡A¥u¦³ Navigator 4.0 ¥H«áªºª©¥»¤~¦³ layer ¼ÐÅÒ¡A©Ò¥H¦P²z§ÚÌ¥i¥H¡G
if (document.layers) { /* ...... NS ª«¥ó¾Þ§@±Ôz */ } /* ¤§©Ò¥H¥Î layers ½Æ¼Æ¡A¦Ó¤£¬O layer ³æ¼Æ¡A¬O¦]¬° layer ¬O¥H¶°¦Xª¬ºAÁõÄÝ©ó document */¦n¤F¡A¥»½d¨Ò IE ©M NS ³q¥Î¤U©Ô¿ï³æ°ò¥»ì²z¤j·§´N¬O³o¼Ë¡A©¹¤U§Ú±N¬°¤j®a ¸Ñ»¡¥»½d¨Ò¹ê°µ¤è¦¡¡C ¦^¿ï³æ
<!-- ¿ï³æ¸s²Õ°Ï¬q¶}©l¡A¥»°Ï¬qªº«ÂI¬O STYLE="position:absolute;" ªº³]©w¡A·N«ä¬On¦b Netscape ¤¤·í°µ LAYER ¨Ó³B²z¡C --> <DIV ID="MenuLine" STYLE="position:absolute;..."> <!-- ¤@¯ëì«h¼u¥X°Ï¬q¶}©l¡A¥»°Ï¬q«ÂI¬O visibility="hidden" ¡A·N«ä¬O¤@¶}©l¬OÁôÂ꺡A¨ä¥L´XÓ¿ï³æ¼u¥X°Ï¤]¬O¦p¦¹¡C --> <DIV ID="item0" STYLE="position:absolute;...visibility:hidden;"> </DIV> <!-- ¤@¯ëì«h¼u¥X°Ï¬qµ²§ô --> <!-- ...¨ä¥L¼u¥X°Ï¬q... --> </DIV> <!-- ¿ï³æ¸s²Õ°Ï¬qµ²§ô --> <!-- ¥»¤å»¡©ú°Ï¬q¶}©l¡A¨S¦³ position ªº³]©w¡A·N«ä¬O¤£»Ýn°µ Layer ³B²z¡C --> <DIV ID="Content"> </DIV> <!-- ¥»¤å»¡©ú°Ï¬qµ²§ô -->¦^¿ï³æ
<!-- ¿ï³æ¸s²Õ°Ï¬q¶}©l --> <DIV ID="MenuLine" STYLE="position:absolute;..."> <!-- ¿ï³æÄ²µo¾¹°Ï¬q¶}©l --> <DIV ID="MenuBar" STYLE="position:absolute;..."> <!-- ...... --> </DIV> <!-- ¿ï³æÄ²µo¾¹°Ï¬qµ²§ô --> <!-- ¤@¯ëì«h¼u¥X°Ï¬q¶}©l --> <DIV ID="item0" STYLE="position:absolute;..."> <!-- ...¨ä¥L¼u¥X°Ï¬q... --> </DIV> <!-- ¿ï³æ¸s²Õ°Ï¬qµ²§ô -->¦w±Æ°µ¬°²Ä¤@ӰϬqªº¥Î·N¬O°µ¬°«á±¼u¥X°Ï¬q©w¦ìªº¥Î·N¡C¦Ü©ó¦b¦¹Ä²µo¨Æ¥ó±µ¦¬ °Ï¬q¸Ó¥Î¤°»òºô¶¼ÐÅÒ°µ¨Æ¥ó±µ¦¬¾¹©O¡H¦Ò¼{¤@¯ëµøµ¡µ{¦¡¥\¯à¿ï³æªº°Ê§@¬O MouseClick ®É¼u¥X¿ï³æ¡AMouseMove ®É¤Á´«¿ï³æ¡A¦]¦¹³oÓ¼ÐÅÒÀ³¸Ón¹ï onmouseover,onmouseout,onclick µ¥¨Æ¥ó³£n¦³¤ÏÀ³¡A¦b¦¹¦Ò¶q¤U¡ANetscape ªººô¶ ¼ÐÅÒ¤¤¡A¥u¦³°µ¬° Link ¤¸¥óªº <A> ¼ÐÅҳ̦X¾A¡A¦]¦¹¦b¨Æ¥óIJµo°Ï¬q¡A§ÚÌ ¹ï¨Æ¥ó±µ¦¬¾¹ªº³]©w¬O¡G
<!-- ¿ï³æÄ²µo¾¹°Ï¬q¶}©l --> <DIV ID="MenuBar" STYLE="position:absolute;..."> <A HREF="#" /* ·í·Æ¹«¶i¤J´N¤Á´«¨ì¥»¶µªþÄÝªí³æªº¼u¥X¡A°Ñ¼Æ index ªí¼u¥Xªí³æÃ丹¡C */ onmouseover="ShowItem(index);return false;" /* ·í·Æ¹«Â÷¶}´N¸Ñ°£ªþÄݼu¥Xªí³æªºÂê©wª¬ºA */ onmouseout="UnLock();return false;" /* ·í·Æ¹««ö¤U´N¼u¥XªþÄÝªí³æ¡A¨Ã¥[¥HÂê©w¡AÁ×§K³QÃö³¬¡C */ onclick="PopupItem(index);return false;">¤@¯ëì«h</A> <A HREF="#" /* ...¨ä¥L¨Æ¥ó±µ¦¬¾¹³]©w... */ </DIV> <!-- ¿ï³æÄ²µo¾¹°Ï¬qµ²§ô -->¦^¿ï³æ
<!-- ¤@¯ëì«h¼u¥X°Ï¬q¶}©l --> <DIV ID="item0" STYLE="...top:1em;left:0em;..."> <!-- ½d¨Ò¹ê§@¼u¥X°Ï¬q¶}©l --> <DIV ID="item1" STYLE="...top:1em;left:4.7em;..."> <!-- ª`·N¨Æ¶µ¼u¥X°Ï¬q¶}©l --> <DIV ID="item2" STYLE="...top:1em;left:9.5em;..."> <!-- ºô¯¸Ápµ²¼u¥X°Ï¬q¶}©l --> <DIV ID="item3" STYLE="...top:1em;left:14.2em;...">¦Ü©ó³o¨Ç¦ì²¾È«ç»ò¨Óªº¡H·íµM¬OÃä¬ÝÃä§ïªº¥Ø´úªkÅo¡C¦Ü©ó§A¤@©wn°l°Ý¨ºn¥\¯àªí ¸m¤¤¡B¸m¥k«ç»ò¿ì¡H§Ú¥u¯àµªÂЧA¡A·íµM¾ãÓ·|¶Ã±¼¡A¦ý¨º¤w¸g¬O¥t¤@Ó¥DÃD¡Aºô¶ ¤¸¥ó©w¦ì°ÝÃD¡A¶W¥X¤F¥»½d¨Ò°Q½×½d³ò¡C ¦^¿ï³æ
/* Åã¥Ü¤l¿ï³æ¡Aitem °Ñ¼Æªí¥ÜÅã¥Ü¨º¤@Ó¤l¿ï³æ¡C */ function ItemVisible(item) { var ShowArea,OK=false; /* document ¦³ all ª«¥ó¡Aªí¥ÜÂsÄý¾¹¬O IE 4.0 ¥H¤W¡A «h ShowArea ÅܼÆn°Ñ·Óºô¶¤¸¥óªº style ªþÄݪ«¥ó¡C */ if (document.all) {OK=true;ShowArea=eval(item+".style");} /* document ¦³ layers ª«¥ó¡Aªí¥ÜÂsÄý¾¹¬O NS 4.0 ¥H¤W¡A «h ShowArea ÅܼÆn°Ñ·Óºô¶ªº layer ª«¥ó¡C */ if (document.layers) {OK=true; ShowArea=eval("document.layers.MenuLine.layers."+item);} /* ¨Ï¤¸¥ó¥i¨£ */ if (OK) {ShowArea.visibility="visible";} } /* Ãö³¬¤l¿ï³æ¡Aitem °Ñ¼Æªí¥ÜÅã¥Ü¨º¤@Ó¤l¿ï³æ¡C */ function ItemHidden(item) { var ShowArea,OK=false; if (document.all) {OK=true;ShowArea=eval(item+".style");} if (document.layers) {OK=true; ShowArea=eval("document.layers.MenuLine.layers."+item);} /* ¨Ï¤¸¥ó¤£¥i¨£ */ if (OK) {ShowArea.visibility="hidden";} }·í§A°µ¦n³o³¡¥÷«á¡A°t¦X¨Æ¥ó±µ¦¬¾¹ªº Script¡G
onmouseover="ShowItem(index);return false;"¤U±³o¬q±Ôz¨â®aÂsÄý¾¹¥Î°_¨Ó´N²@µL»Ùê¤F¡G
/* ¼u¥X¤l¿ï³æ */ function PopupItem(idx) { /* Ãö±¼©Ò¦³¿ï³æ */ for (var i=0;i<layernumber;i++) {ItemHidden(childlayer+i);} /* ¼u¥X©Ò¿ï¾Üªº¿ï³æ */ ItemVisible(childlayer+idx); /* ¼Ð©ú¿ï³æ¤w¼u¥X */ pop=true; /* Âê¦í¼u¥X¿ï³æ */ lock=true; }¥H¤W´N¬O¥»½d¨Ò Script ±Ôzªº«ÂI¡A¨ä¥L´N¤£¤@¦A«ÂФF¡A¬Ý¬Ý¥»¶ªº Script ¡A §AÀ³¸Ó«Ü®e©ö´N»â·|¤F¡C ¦^¿ï³æ