Javascript µÄ´Ê·¨×÷ÓÃÓò¡¢µ÷ÓöÔÏóºÍ±Õ°ü
×÷ÓÃÓò Scope
Javascript Öеĺ¯ÊýÊôÓÚ´Ê·¨×÷ÓÃÓò£¬Ò²¾ÍÊÇ˵º¯ÊýÔÚËü±»¶¨ÒåʱµÄ×÷ÓÃÓòÖÐÔËÐжø²»ÊÇÔÚ±»Ö´ÐÐʱµÄ×÷ÓÃÓòÄÚÔËÐС£ÕâÊÇϬţÊéÉϵÄ˵·¨¡£µ«“¶¨Òåʱ”ºÍ“Ö´ÐУ¨±»µ÷Óã©Ê±”ÕâÁ½¸ö¶«Î÷ÓÐЩÈ˸㲻Çå³þ¡£¼òµ¥À´Ëµ£¬Ò»¸öº¯ÊýAÔÚ“¶¨Òåʱ”¾ÍÊÇ function A(){} Õâ¸öÓï¾äÖ´ÐеÄʱºò¾ÍÊǶ¨ÒåÕâ¸öº¯ÊýµÄʱºò£¬¶øA±»µ÷ÓõÄʱºòÊÇ A() Õâ¸öÓï¾äÖ´ÐеÄʱºò¡£ÕâÁ½¸ö¸ÅÄîÒ»¶¨Òª·ÖÇå³þ¡£
ÄÇ´Ê·¨×÷ÓÃÓò£¨ÒÔϳÆ֮Ϊ“×÷ÓÃÓò”£¬³ý·ÇÌرðÖ¸Ã÷£©µ½µ×ÊÇʲôÄØ£¿ËüÊǸö³éÏóµÄ¸ÅÄ˵°×ÁËËü¾ÍÊÇÒ»¸ö“·¶Î§”£¬scope ÔÚÓ¢ÎÄÀï¾ÍÊÇ·¶Î§µÄÒâ˼¡£Ò»¸öº¯ÊýµÄ×÷ÓÃÓòÊÇËü±»¶¨ÒåʱËüËù´¦µÄ“·¶Î§”£¬Ò²¾ÍÊÇËüÍâ²ãµÄ“·¶Î§”£¬Õâ¸ö“·¶Î§”°üº¬ÁËÍâ²ãµÄ±äÁ¿ÊôÐÔ£¬Õâ¸ö“·¶Î§”±»ÉèÖóÉÕâ¸öº¯ÊýµÄÒ»¸öÄÚ²¿×´Ì¬¡£Ò»¸öÈ«¾Öº¯Êý±»¶¨ÒåµÄʱºò£¬È«¾Ö£¨Õâ¸öº¯ÊýµÄÍâ²ã£©µÄ“·¶Î§”¾Í±»ÉèÖóÉÕâ¸öÈ«¾Öº¯ÊýµÄÒ»¸öÄÚ²¿×´Ì¬¡£Ò»¸öǶÌ׺¯Êý±»¶¨ÒåµÄʱºò£¬±»Ç¶Ì׺¯Êý£¨Íâ²ãº¯Êý£©µÄ“·¶Î§”¾Í±»ÉèÖóÉÕâ¸öǶÌ׺¯ÊýµÄÒ»¸öÄÚ²¿×´Ì¬¡£Õâ¸ö“ÄÚ²¿×´Ì¬”ʵ¼ÊÉÏ¿ÉÒÔÀí½â³É×÷ÓÃÓòÁ´£¬¼ûÏÂÎÄ¡£
µ±Ò»¸öº¯Êý±»µ÷ÓÃʱ£¬ÔÚÕâ¸öº¯ÊýÀËüÄÜ·ÃÎʵ½ËüµÄÕâ¸öÄÚ²¿×´Ì¬£¬Ò²¾Í¿ÉÒÔ·ÃÎÊÕû¸ö×÷ÓÃÓòÁ´ÉϵÄËùÓбäÁ¿£¬µ±È»Ò²¾Í°üÀ¨ÁËÍⲿ±äÁ¿¡££¨Êµ¼ÊÉÏÊÇ´Ó“µ÷ÓöÔÏóÁ´”Àï·ÃÎʵ½µÄ¡£ºÃÏñÓÐÎÊÌâ°É£¬Çë½Ó×ÅÔĶÁ¡££©
ÕÕÒÔÉÏ˵·¨£¬Ò»¸öº¯ÊýµÄ×÷ÓÃÓòÊÇËü±»¶¨ÒåµÄʱºòËù´¦µÄ“·¶Î§”£¬ÄÇô Javascript ÀïµÄº¯Êý×÷ÓÃÓòÊÇÔÚº¯Êý±»¶¨ÒåµÄʱºò¾ÍÈ·¶¨ÁË£¬ËùÒÔËüÊǾ²Ì¬µÄ×÷ÓÃÓò£¬´Ê·¨×÷ÓÃÓòÓÖ³ÆΪ¾²Ì¬×÷ÓÃÓò¡£
µ÷ÓöÔÏó Call Object
Ò»¸öº¯ÊýµÄµ÷ÓöÔÏóÊǶ¯Ì¬µÄ£¬ËüÊÇÔÚÕâ¸öº¯Êý±»µ÷ÓÃʱ²Å±»ÊµÀý»¯µÄ¡£ÎÒÃÇÒѾ֪µÀ£¬µ±Ò»¸öº¯Êý±»¶¨ÒåµÄʱºò£¬ÒѾȷ¶¨ÁËËüµÄ×÷ÓÃÓòÁ´¡£µ± Javascript ½âÊÍÆ÷µ÷ÓÃÒ»¸öº¯ÊýµÄʱºò£¬Ëü»áÌí¼ÓÒ»¸öеĶÔÏ󣨵÷ÓöÔÏ󣩵½Õâ¸ö×÷ÓÃÓòÁ´µÄÇ°Ãæ¡£Õâ¸öµ÷ÓöÔÏóµÄÒ»¸öÊôÐÔ±»³õʼ»¯³ÉÒ»¸öÃû½Ð arguments µÄÊôÐÔ£¬ËüÒýÓÃÁËÕâ¸öº¯ÊýµÄ Arguments ¶ÔÏó£¬Arguments ¶ÔÏóÊǺ¯ÊýµÄʵ¼Ê²ÎÊý¡£ËùÓÐÓà var Óï¾äÉùÃ÷µÄ±¾µØ±äÁ¿Ò²±»¶¨ÒåÔÚÕâ¸öµ÷ÓöÔÏóÀï¡£Õâ¸öʱºò£¬µ÷ÓöÔÏó´¦ÔÚ×÷ÓÃÓòÁ´µÄÍ·²¿£¬±¾µØ±äÁ¿¡¢º¯ÊýÐÎʽ²ÎÊýºÍ Arguments ¶ÔÏóÈ«²¿¶¼ÔÚÕâ¸öº¯ÊýµÄ·¶Î§ÀïÁË¡£µ±È»£¬Õâ¸öʱºò±¾µØ±äÁ¿¡¢º¯ÊýÐÎʽ²ÎÊýºÍ Arguments ¶ÔÏó¾Í¸²¸ÇÁË×÷ÓÃÓòÁ´ÀïͬÃûµÄÊ
Ïà¹ØÎĵµ£º
<!--JavaScript µ÷Óÿͻ§¶ËÓ¦ÓóÌÐò-->
<script type="text/javascript">
function exec(command)
{
window.oldOnError = window.onerror;  ......
Struts Validator Framework provides an easy-to-use mechanism for performing client-side validation. It's very useful to validate some fields on the client-side before sending the data to the server for processing. By this way we can ensure that the data send to the server is valid. Performing valida ......
<script language="javascript">
function closeOpen(Panel) {
var test = document.getElementById('Panel');
if (test.style.display == "none") {
&nb ......
¡¡´Ó2004ÄêÏ°ëÄ꿪ʼѧϰWeb±à³ÌÖÁ½ñ3ÄêÓÐÓà¡£´ÓHTML£¬asp¿ªÊ¼µ½ÏÖÔÚµÄVS2008һ·ѧ¹ýÀ´£¬ÆäÖÐѧµÄ×î¶àµÄ»¹ÊÇ·þÎñÆ÷¶Ë±à³Ì£¬¶Ô¿Í»§¶Ë±à³ÌµÄѧϰ»¹ÊDz»³Éϵͳ¡£ËäÈ»Ôںܶà¸öϵͳÀïÃæÓ¦Óùý½Å±¾£¬ÓÐЩ»¹Æðµ½Á˱ȽÏÖØÒªµÄ×÷Óᣵ«Ò»Ö±ÊÇÖ»ÖªÆäÈ»²»ÖªÆäËùÒÔÈ»£¬ÓõÄÊÇСÐÄÒíÒí¡£ÏÖÔڽű¾±à³Ì´ÓÒÔÇ°µÄ"µñ³æС¼¼"±ä³ÉÁËÒ»¸öWeb¿ª ......