JavaScript FAQ£¨¶þÊ®ËÄ£©
¶þʮһ¡¢ÉùÒô
1¡¢¿ÉÒÔ²¥·ÅÉùÒôµÄä¯ÀÀÆ÷£¨Audio-enabled Browsers£©
Q£ºÊ²Ã´¿ÉÒÔä¯ÀÀÆ÷¿ÉÒÔÖ´Ðв¥·ÅÉùÒôµÄ½Å±¾£¿
A£ºÈç¹ûÔÚÉùÒô²¥·ÅÃèÊöµÄ¼¼Êõ¿ÉÒÔÔÚMiscrosoft Internet Explorer 4.0¼°Æä¸üа汾Öй¤×÷£¬ÄÇôͬÑù¿ÉÒÔÔÚNetscape Navigator 3.0¼°Æä¸üа汾Öй¤×÷¡£ÒªÔÚInternet ExplorerÖв¥·ÅÉùÒô£¬ÔÚ4.0ÒÔ¼°ºóÀ´°æ±¾ÖвâÊÔ¾Í×ã¹»ÁË¡£È»ºóÔÚNetscape NavigatorÖУ¬Äã±ØÐëÈ·±£ÒÔϼ¸µã£º
ä¯ÀÀÆ÷°æ±¾ÊÇ3.0»òÕ߸üа汾
ÆôÓÃJava£¨²»½ö½öÊÇJavaScript£¡£©
ä¯ÀÀÆ÷Äܹ»Ê¶±ðÄãÒª²¥·ÅÒôƵÎļþµÄmimeÀàÐÍ
LiveAudio²å¼þ¿ÉÓÃ
ÀýÈ磬Èç¹ûÄãÏëÔÚÏÂÃæµÄEMBED±ê¼ÇÖв¥·ÅÉùÒôÎļþmySound.mid
<EMBED NAME="mySound" SRC="mySound.mid" mce_SRC="mySound.mid"
LOOP=FALSE AUTOSTART=FALSE HIDDEN=TRUE MASTERSOUND>
ÄÇô£¬¾ÍÐèҪʹÓÃÏÂÃæµÄ´úÂë½øÐвâÊÔ£º
ver=parseInt(navigator.appVersion)
if (ver>2 && navigator.appName=="Netscape"
&& navigator.mimeTypes['audio/x-midi']
&& navigator.javaEnabled()
&& document.mySound.IsReady() )
{
// put Netscape-specific code here
}
if (ver>3 && navigator.appName.indexOf("Microsoft")!=-1)
{
// put Explorer-specific code here
}
2¡¢ÒôƵÎļþ¸ñʽ£¨Audio File Formats£©
Q£ºÍøÒ³¿ÉÒÔ²¥·ÅÄÇЩÀàÐ͵ÄÒôƵÎļþ£¿
A£ºËùÓÐÆôÓÃÒôƵµÄä¯ÀÀÆ÷¶¼Ö§³Ö»Ø·ÅWAVºÍMIDI¸ñʽ£¨.mid¡¢.midiºÍ.wavÎļþ£©µÄÒôƵÎļþ¡£¸ù¾ÝÓû§ä¯ÀÀÆ÷ºÍϵͳÅäÖõIJ»Í¬µÄ£¬ÆäËû¸ñʽÎļþÒ²ÐíÖ§³Ö»ò²»Ö§³Ö¡£ÀýÈ磬ReadAudioÖ»ÄÜÓû§°²×°ÁËRealPlayer²Å¿ÉÒԻطš£
3¡¢Ê¹ÓÃJavaScript²¥·ÅÉùÒô£¨Playing Sound from JavaScript£©
Q£ºÎÒÈçºÎ±àдһ¸ö²¥·ÅÉùÒôJavaScript½Å±¾ÄØ£¿
A£ºÓм¸ÖÖ²»Í¬µÄ·½Ê½¿ÉÒÔͨ¹ýJavaScript²¥·ÅÉùÒô¡£ÎÒÃÇÀ´¿´¼¸¸öÀý×Ó£º
ʾÀý1. ÕâÊÇÒ»¸ö×î¼òµ¥µÄ²¥·ÅÉùÒôÎļþµÄ¿çä¯ÀÀÆ÷½Å±¾£º
self.location="AUDIO_FILE_URL"
µã»÷ÕâÀï²âÊÔʾÀý1´úÂë¡£ä¯ÀÀÆ÷»á´ò¿ªÒ»¸öµ¥¶ÀµÄÉùÒô¿ØÖÆ´°¿Ú¡£ÄÇôÓû§ÐèÒªÊÖ¶¯¹Ø±ÕÕâ¸ö´°¿Ú¡£×¢Ò⣬ʾÀý1¶ÔÓû§²¢²»ÓѺãºÓû§Ã¿Ò»´Îµã»÷ÔËÐнű¾£¬ä¯ÀÀÆ÷¶¼»á´ò¿ªÒ»¸öеÄÉùÒô¿ØÖÆ´°¿Ú£¬¼´Ê¹ÒѾÓÐÒôƵ´°¿ÚÒѾÔÚ²¥·ÅͬÑùµÄÎļþ£¡
ʾÀý2. ÕâÊÇÒ»¸ö¸ü¼Ó¸´ÔÓµÄÀý×Ó£¬Õâ¸öÀý×ÓûÓе¥¶ÀµÄÉùÒô¿ØÖÆ´°¿Ú¡££¨ÏÂÃæÓйØÓÚÕâ¸öÀý×ÓµÄÌÖ
Ïà¹ØÎĵµ£º
±Õ°ü£¨closure£©ÊÇJavascriptÓïÑÔµÄÒ»¸öÄѵ㣬ҲÊÇËüµÄÌØÉ«£¬ºÜ¶à¸ß¼¶Ó¦Óö¼ÒªÒÀ¿¿±Õ°üʵÏÖ¡£
ÏÂÃæ¾ÍÊÇÎÒµÄѧϰ±Ê¼Ç£¬¶ÔÓÚJavascript³õѧÕßÓ¦¸ÃÊǺÜÓÐÓõġ£
Ò»¡¢±äÁ¿µÄ×÷ÓÃÓò
ÒªÀí½â±Õ°ü£¬Ê×ÏȱØÐëÀí½âJavascriptÌØÊâµÄ±äÁ¿×÷ÓÃÓò¡£
±äÁ¿µÄ×÷ÓÃÓòÎ޷ǾÍÊÇÁ½ÖÖ£ºÈ«¾Ö±äÁ¿ºÍ¾Ö²¿±äÁ¿¡£
JavascriptÓïÑÔµÄÌØÊâÖ®´¦£¬¾ÍÔ ......
ÔÚÍøÉÏÕÒµ½ÔÚIEϲÙ×÷IFrameÄÚÈݵĴúÂë:
document.frames["MyIFrame"].document.getElementById("s").style.color="blue";
µ«ÊÇÕâÔÚFirefoxÏÂÎÞЧ¡£
ËùÒÔ£¬Ïëµ½ÔÚFirefoxÏÂÓÃFireBugÀ´µ÷ÊÔ¡£¾¹ýµ÷ÊÔ·¢ÏÖÔÚFirefoxÏ¿ÉÓÃÒÔÏ´úÂëÀ´ÊµÏÖ:
document.getElementById("MyIFr ......
Èç¹ûÄãÍêÈ«²»¶®£¬ÄÇôÆÚÍû1-2ÖÜ¿´ÍêÒ»±éÀµ¹....²»Óÿ´µÄÌ«×Ðϸ£¬ºóÃæÔÙ¿´µ½²»¶®µÄʱºò»ØÍ·È¥¿´ÕâЩ¶«Î÷ºÃÁË¡£
1. Ç°ÑÔºÍ×¼±¸¹¤×÷
ÕâÀï²»»á½éÉÜʲôÈí¼þµÄÓ÷¨Ò»ÀàµÄ¶«Î÷¡£Èç¹û¾õµÃÊÖд´úÂëÊÇÔÚ×°µÄÈË¿ÉÒÔ³öÈ¥ÁË£¬Ð»Ð»¡£
Ê×ÏÈÄãÒªÓÐ̨µçÄÔ¡£È»ºóËüÓ¦¸Ã×°×Åwindows ºÍ IE¡£ÏÂÃæËù̸µ½µÄ´úÂë ......
<a href="#" onclick="ChildNode(this);">aaa</a>Òª¸ÄΪ
<a href="#" onclick="ChildNode(event);">aaa</a>
ÎÞ·¨È¡µÃthis¶ÔÏó£¬ÒªÓÃÒÔÏ·½·¨À´È¡µÃ¡£
function ChildNode(e)
{
var evt = e ? e : (window.event ? window.event : null); //´Ë·½·¨ÎªÁËÔÚfirefoxÖеļæÈÝ
var node = evt.srcEl ......