<A HREF="#" onmouseover="this.style.color='red';" onmouseout="this.style.color='blue';" onclick="alert('ÃC¦âÅܦ¨¬õ¦âÅo!!');return false;"> §ïÅÜÁpµ²ÃC¦â</A><BR> <-- onmouseover ¬Oªí¥Ü·í·Æ¹«´å¼Ð²¾¤JÁpµ²¼ÐÅҮɡA³oùجO³]¦¨¦r«¬ÂàÅܬ°¬õ¦â¡C --> <-- onmouseout ¬Oªí¥Ü·í·Æ¹«´å¼Ð²¾¥XÁpµ²¼ÐÅҮɡA³oùجO³]¦¨¦r«¬ÂàÅܬ°ÂŦâ¡C --> <-- onclick ¬Oªí¥Ü·í¦bÁpµ²¼ÐÅÒ¤W«ö·Æ¹«Áä®É¡A³oùجOÅã¥Ü¤@°T®§®Ø¡C -->¦pªG§A²{¦b¥Îªº´N IE4 ¥H¤Wª©¥»ªºÂsÄý¾¹¦b¾\Ū¥»ºô¶¡A¨º«ö ³o¸Ì¬Ý¬Ý®ÄªG§a¡C
<A HREF="#" onmouseover="document.layers.layer2.bgColor='yellow';" onmouseout="document.layers.layer2.bgColor='white';" onclick="alert('¥»¼ÐÅÒ·|ÀH·Æ¹«´å¼Ð²¾¤J²¾¥X¦Ó§ó´«I´º¦â');return false;"> <ILAYER ID="layer2">ÀH·Æ¹«´å¼Ð²¾°Ê§ó´«I´ºªºÁpµ²</ILAYER></A> <-- ¥ý¥Î¤@Ó IMG ¼ÐÅÒ¥]¦í¤@Ó ILAYER ¼ÐÅÒ¡AIMG t³d°»´ú·Æ¹«²¾°Ê¡A --> <-- ILAYER t³d¤å¦rÅã¥Ü¤Î©³¦â§ó§ï¡A¨Ã¨ú¦W layer2 ¥H¨Ñ Script ©I¥s¡C --> <-- onmouseover ¬Oªí¥Ü·í·Æ¹«´å¼Ð²¾¤JÁpµ²¼ÐÅҮɡA§â layer2 ©³¦âÂର¶À¦â¡C --> <-- onmouseout ¬Oªí¥Ü·í·Æ¹«´å¼Ð²¾¥XÁpµ²¼ÐÅҮɡA§â layer2 ©³¦âÁÙ쬰¥Õ¦â¡C -->§A«ö ³o¸Ì´N¥i¥H¬Ý¨ì Netscape ©â´« LAYER ¤¸¥ó©³¦âªº®ÄªG¡C©Ò¥H¦pªG³o¼Ëªº®ÄªG´N ¨¬¥Hº¡¨¬§Aªº»Ý¨D¡A¨º»ò Script ½ÆÂø«×¥i¥H»¡¬O³Ì³æ¯Âªººô¶¡A¦Ó¥B°µ Cross Browser Page ¤]¬O³Ì¤Ö§xÂZªººô¶¡A¦]¬°§A¥i¥H§â¤W±ªº ILAYER ¼ÐÅҧאּ <SPAN>«á¡A¦A¬°¨ä³]©w STYLE="position:relative;" ªº CSS ÄÝ©Ê¡A ´N¯à¨Ï Netscape §â³oÓ SPAN ¼ÐÅÒ·í°µÀÀ ILAYER ¼ÐÅÒ¨Ó³B²z¡A±q¦Ó¨ú±o°ÊºA§ïÅÜ SPAN ¼ÐÅÒ bgColor Äݩʪº¯à¤O(¦³Ãö¦p¦ó¥Î CSS position ÄÝ©Ê¨Ó¨Ï Netscape ±N¤@¯ë ºô¶¼ÐÅÒÀÀ LAYER ¤Æªº»¡©ú¡A½Ð¦Û¦æ°Ñ¦Ò ¦p¦ó°µ¤@Ó IE ©M NS Âù¥Îªº¤U©Ô¥\¯à¿ï³æ¤@¤å¡C)©Ò¥Hµy°µ§ó°Ê«áªº HTML ¡A¦b IE ©M NS ùØÅã¥Ü³£¤£¦¨°ÝÃD¡A¦Ü©ó¦b Script ùØ¡A«hnµy¬°§PÂ_¤@¤UÂsÄý¾¹¦p¤U¡G
/* ¾A¥Î NS4 ¡A¦]¬°¥u¦³ NS4 ¦³ layers ¶°¦Xª«¥ó¡C */ if (document.layers) {document.layers.LayerID.bgColor=ColorValue;} /* ¾A¥Î IE4 ¡A¦]¬°¥u¦³ IE4 ¦³ all ¶°¦Xª«¥ó¡C */ if (document.all) {LayerID.style.backgroundColor=ColorValue;}¦Ü©ó§ó§ï«áªº®ÄªG¡A¤£ºÞ§A²{¦b¨Ï¥Îªº¬O IE or NS ¡A¥un 4.0 ª©¥H¤W¡A´N¥i«ö ³o¸Ì¨Ó¸Õ¸Õ¬Ý¡C
var a,b,c; function ChangeFrontColor() { var cvalue=(a)?"black":"red"; a=!a; document.layers.layer1.document.fgColor=cvalue; }¦Ó¥Î write §ï¼g¤èªkªº JavaScript ¬O³o¼Ë¡G
var a,b,c; function WriteFrontColor() { var cvalue=(b)?"black":"red"; b=!b; var doc=document.layers.layer2.document; doc.open(); doc.fgColor=cvalue; doc.write("«¼g§ïÅÜ layer «e´º¦â"); doc.close(); }°õ¦æµ²ªG½Ð«ö³oùØ ³o¸Ì¡C¥Ñ½d¨Ò¶§Yª¾¡Aª½±µ³]©w fgColor ¬O¨S¦³§@¥Îªº¡A§ïÅܤ§¹D¥u¦³«·s write ¤@³~¡A¬JµMn document.write ¡A¨º·íµM layer ¤¤ªº¤å¥ón«ç»ò§ï³£¥i¥H¤F¡A©Ò¥H§@ªÌ ¤p¤pÄÌ¥]¤@µf¡A°µ¤F¯à©ñ¤j¦rÅ骺«ö¶s¡A¨ä JavaScript ¦p¤U¡G
var a,b,c; function WriteFontSize() { var fs=(c)?"":"+2"; c=!c; var doc=document.layers.layer3.document; doc.open(); doc.write('<FONT SIZE="'+fs+'">«¼g§ïÅÜ layer ¦rÅé¤j¤p</FONT>'); doc.close(); }
Link ·í·Æ¹«¨Æ¥ó°»´ú¾¹¡G <LAYER ID="layer1"> <A HREF="#" CLASS="go" onmouseover="ReWriteLink('layer1',true)" onmouseout="ReWriteLink('layer1',false)" onclick="alert('°ÊºA§ï¼g Link ´ú¸Õ');return false;"> §ï¼g¼ÐÅÒ A </A> </LAYER> LAYER ·í·Æ¹«¨Æ¥ó°»´ú¾¹¡G <LAYER ID="layer2" onmouseover="ReWriteLink('layer2',true)" onmouseout="ReWriteLink('layer2',false)"> <A HREF="#" CLASS="go" onclick="alert('°ÊºA§ï¼g Link ´ú¸Õ');return false;"> §ï¼g¼ÐÅÒ B </A> </LAYER>¦Ü©ó°õ¦æµ²ªG½Ð«ö ³oùØ¡C ©Î³\§AÁÙ·|»¡§A¬O¥Î Layer ¥] Link ¤~¦³³o²{¶H¡A¦pªG¬O Link ¥] Layer ¦p¤U¡G
Link ·í·Æ¹«¨Æ¥ó°»´ú¾¹¡G <A HREF="#" CLASS="go" onmouseover="ReWriteLink('layer1',true)" onmouseout="ReWriteLink('layer1',false)" onclick="alert('°ÊºA§ï¼g Link ´ú¸Õ');return false;"> <LAYER ID="layer1"> §ï¼g¼ÐÅÒ A </LAYER> </A>Link ¤£³Q§ï¼g¡A´N¤£·|¦³³o²{¶H¡A¤£©¯ªº¬O¡A¦pªG§A¯u¦p¦¹°µ¡A¨ºÓ <A> ¼ÐÅÒ ®Ú¥»¤£³Q Netscape ©Ó»{ÁÙ¬O Link ¼ÐÅÒ¡A¤]´N¬O»¡¤£ºÞ§A MouseOver,Out,Click ¡A ¤@·§¨S¦³¤ÏÀ³¡A¦¹¤@²{¶H¡A¦p§A¦³¿³½ì¡A½Ð¦Û¦æ´ú¸Õ¡A§ÚÌ´N¤£¦AÁ|¨Ò¤F¡C
<SPAN ID="item1" STYLE="position:absolute;"> <A HREF="#" CLASS="go" onmouseover="ChangeLinklike('item1',true)"> ¿ï¶µ¤@</A> </SPAN> <SPAN STYLE="position:relative;"> <A HREF="#" CLASS="come" onmouseout="ChangeLinklike('item1',false)" onclick="alert('§A«ö¤F²Ä¤@ӿﶵÁpµ²');return false;"> ¿ï¶µ¤@</A> </SPAN> ...... ¨ä¥L¤W¤U¦¨¹ï Link ¼ÐÅÒ²Õ ......µM«á¦b Script °Ï¬q¤¤°µ³o¼Ëªº function¡G
/* ¤Á´«¦U Link ¼ÐÅÒ®e¾¹Åã¥Üª¬ºAªº¦Ûq¨ç¼Æ °Ñ¼Æ lname ¼ÐÅÒ®e¾¹¦WºÙ¡Aisin ·Æ¹«¬O²¾¤JÁÙ¬O²¾¥X¡C */ function ChangeLinklike(lname,isin) { var showstr=(isin)?"hidden":"visible"; var showstyle; if (document.all) {showstyle=eval(lname+".style");} if (document.layers) {showstyle=eval("document.layers."+lname);} showstyle.visibility=showstr; }°õ¦æµ²ªG½Ð«ö ³oùØ¡C ÁöµM½Í¤F¦p¦¹¤§¦h¡Aµ²ªG³º¬Oµ¹§AÓ¤£¬Oì¨Ó°ÝÃDªºµª®×¡A¦ý§ÚÁÙ¬Oı±o³oÓ½d¨Ò¬O ¯àÝÅU Cross Browser ªº¦n¤èªk¡C¦pªG§A¤]ı±o¦p¦¹¡A§Æ±æ¤F¸Ñ¥þ³¡ªº DHTML Code ªº ¦w±Æ¡A½Ð«ö ¥´¥]¤U¸ü¡AÂ÷½u¾\Ū¡C