Ò׽ؽØͼÈí¼þ¡¢µ¥Îļþ¡¢Ãâ°²×°¡¢´¿ÂÌÉ«¡¢½ö160KB

javascript µÄtry catch


Try...Catch Óï¾ä
try...catch ¿ÉÒÔ²âÊÔ´úÂëÖеĴíÎó¡£try ²¿·Ö°üº¬ÐèÒªÔËÐеĴúÂ룬¶ø catch ²¿·Ö°üº¬´íÎó·¢ÉúʱÔËÐеĴúÂë¡£
Óï·¨£º
try
{
//ÔÚ´ËÔËÐдúÂë
}
catch(err)
{
//ÔÚ´Ë´¦Àí´íÎó
}
×¢Ò⣺
try...catch ʹÓÃСд×Öĸ¡£´óд×Öĸ»á³ö´í¡£
ʵÀý 1
ÏÂÃæµÄÀý×ÓÔ­±¾ÓÃÔÚÓû§µã»÷°´Å¥Ê±ÏÔʾ "Welcome guest!" Õâ¸öÏûÏ¢¡£²»¹ý message() º¯ÊýÖÐµÄ alert() ±»ÎóдΪ adddlert()¡£Õâʱ´íÎó·¢ÉúÁË£º
<html>
<head>
<script type="text/javascript">
function message()
{
adddlert("Welcome guest!")
}
</script>
</head>
<body>
<input type="button" value="View message" onclick="message()" />
</body>
</html>
ÎÒÃÇ¿ÉÒÔÌí¼Ó try...catch Óï¾ä£¬ÕâÑùµ±´íÎó·¢Éúʱ¿ÉÒÔ²ÉÈ¡¸üÊʵ±µÄ´ëÊ©¡£
ÏÂÃæµÄÀý×ÓÓà try...catch Óï¾äÖØÐÂÐÞ¸ÄÁ˽ű¾¡£ÓÉÓÚÎóдÁË alert()£¬ËùÒÔ´íÎó·¢ÉúÁË¡£²»¹ýÕâÒ»´Î£¬catch ²¿·Ö²¶»ñµ½ÁË´íÎ󣬲¢ÓÃÒ»¶Î×¼±¸ºÃµÄ´úÂëÀ´´¦ÀíÕâ¸ö´íÎó¡£Õâ¶Î´úÂë»áÏÔʾһ¸ö×Ô¶¨ÒåµÄ³ö´íÐÅÏ¢À´¸æÖªÓû§Ëù·¢ÉúµÄÊÂÇé¡£
<html>
<head>
<script type="text/javascript">
var txt=""
function message()
{
try
{
adddlert("Welcome guest!")
}
catch(err)
{
txt="´ËÒ³Ãæ´æÔÚÒ»¸ö´íÎó¡£\n\n"
txt+="´íÎóÃèÊö: " + err.description + "\n\n"
txt+="µã»÷OK¼ÌÐø¡£\n\n"
alert(txt)
}
}
</script>
</head>
<body>
<input type="button" value="View message" onclick="message()" />
</body>
</html>
ʵÀý 2
ÏÂÒ»¸öÀý×Ó»áÏÔʾһ¸öÈ·ÈÏ¿ò£¬ÈÃÓû§À´Ñ¡ÔñÔÚ·¢Éú´íÎóʱµã»÷È·¶¨°´Å¥À´¼ÌÐøä¯ÀÀÍøÒ³£¬»¹Êǵã»÷È¡Ïû°´Å¥À´»Øµ½Ê×Ò³¡£Èç¹û confirm
·½·¨µÄ·µ»ØֵΪ false£¬´úÂë»á°ÑÓû§Öض¨Ïòµ½ÆäËûµÄÒ³Ãæ¡£Èç¹û confirm ·½·¨µÄ·µ»ØֵΪ true£¬ÄÇô´úÂëʲôҲ²»»á×ö¡£
<html>
<head>
<script type="text/javascript">
var txt=""
function message()
{
try
{
adddlert("Welcome guest!")
}
catch(err)
{
txt="The


Ïà¹ØÎĵµ£º

javascriptÖг£ÓõÄevent¶ÔÏó

JavascriptµÄEvent¶ÔÏóÓÃÀ´ÃèÊöJavascriptµÄʼþ£¬ËüÖ÷Òª×÷ÓÃÓÚIE4ºÍNN4ÒÔºóµÄ¸÷¸öä¯ÀÀÆ÷°æ±¾ÖС£
Event´ú±íʼþ״̬£¬Èçʼþ·¢ÉúµÄÔªËØ£¬¼üÅÌ״̬£¬Êó±êλÖúÍÊó±ê°´Å¥×´Ì¬¡£Ò»µ©Ê¼þ·¢Éú,±ã»áÉú³ÉEvent¶ÔÏó£¬Èçµ¥»÷Ò»¸ö°´Å¥£¬ä¯ÀÀÆ÷µÄÄÚ´æÖоͲúÉúÏàÓ¦µÄ event¶ÔÏó¡£
IE¶ÔʼþµÄÒýÓÃ
ÔÚIE4ÒÔÉÏ°æ±¾ÖУ¬event¶ÔÏó×÷Î ......

javascriptʼþϵͳµÄ·¢Õ¹Ê·2

×Û¹ÛÒ»¸öϵͳµÄ·¢Õ¹£¬ÎÞ·ÇÊÇ·¢ÏÖÒ»¸öÎÊÌâ¾Í°ÑËü¶ÀÁ¢³öÀ´½â¾öµô£¬Òò´ËËüµÄËùÓÐÄ£¿é£¨»òÕß·ÖÖ§£©ÆäʵÕë¶Ô¶ÀÁ¢µÄÎÊÌ⣬ÕâÑùÎÒÃǶÔÕâЩÎÊÌâÈôÓÐʲô¸üºÃµÄ½â¾ö·½·¨£¬Ìæ»»ÏàÓ¦µÄÄ£¿é±ãÊÇ£¬Òª²»´úÂë»ìÔÓÔÚÒ»Æðû·¨¿´ÁË¡£ÉÏÒ»²¿·Ö¾ÍÌáµ½ÁË£¬attachEventµÄʼþÁжӳöÁËЩÎÊÌ⣬ÎÒÃÇÒªÊÖ¶¯¹¹½¨ÁжÓÁË¡£ËùνÁжӾÍÊÇÓÐÏÈÓкóµÄÎÊÌâ£¬Ò ......

JavaScriptÖÐ×ÓÀàµ÷Óø¸Àà·½·¨

ºÜ¾Ã֮ǰ¾ÍÔÚÓÃJavaScriptÁË£¬Ö»ÊÇÓõıȽϱí²ã£¬»áд¼¸¸öº¯Êý¶øÒÑ£¬Ò²Ã»ÓÐÉîÈëµÄÑо¿¹ý¡£×î½üÒ»¶Îʱ¼ä£¬ÓÉÓÚÏîÄ¿µÄÐèÒª£¬¿´ÁËһЩ¹ØÓÚJavaScriptµÄÊ飬ҲдÁ˲»ÉÙµÄJavaScriptµÄ´úÂ룬ÂýÂý¿ªÊ¼¶ÔÕâ¸ö¶«¶«×ÅÃÔÁË¡£ÏÖÔÚJavaScriptÔÚWebÓ¦ÓÃÖеıÈÖØÔ½À´Ô½´ó£¬¸÷ÖÖºÃÓõĿâÒ²²ã³ö²»Ç¼´Ê¹¶ÔJavaScriptÁ˽âµÄ±È½ÏdzÏÔ£¬Ò²¿ÉÒ ......

JavaScript×ÖÄ»¹ö¶¯Ð§¹û

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>ÎÞ±êÌâÒ³</title>

</head>
<body>
<form id ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ