Javascript±äÁ¿×÷ÓÃÓò
ÇëÏÈ¿´ÏÂÌ⣺
if(true)
{
a = 1;
}
alert(a); //Êä³öɶ£¿
if(true)
{
var a = 1;
}
alert(a); //ÕâÓÖÊä³öʲô£¿
ÔÚfirefox3.5Ï£¬µÚÒ»¸öÊä³ö1;µÚ¶þ¸öÊä³öundefined£¡£¡£¡
ÎªÉ¶ÄØ£¿ºÇºÇ£¬±¾ÈËÔڴ˰àÃÅŪ¸«Ò»Ï£º
Ò»°ãÇé¿öÏÂȱʡvarÉùÃ÷ʱ£¬Ä¬ÈϸñäÁ¿ÎªÈ«¾Ö±äÁ¿¡£Á˽âÕâ¾ä»°£¬ËùÓÐÎÊÌâÒ²¾ÍÓÈжø½âÁË£¡ºÇºÇ£¡
µÚÒ»µÀÌ⣺±äÁ¿aȱʡvarÉùÃ÷£¬¶øÖ±½ÓʹÓ㬹ʶøÄ¬ÈÏΪȫ¾Ö±äÁ¿£¬Êä³ö1
µÚ¶þµÀÌ⣺±äÁ¿a£¬ÔÚif¿éÖÐvarÉùÃ÷£¬Êô¾Ö²¿±äÁ¿£¬Êä³öundefined£¡
Ïà¹ØÎĵµ£º
/**
* JavaScript ÊÇÃæÏò¶ÔÏóµÄÓïÑÔ£¬µ«ÊÇËûµÄÃæÏò¶ÔÏó²»ÊÇ»ùÓÚÀàµÄ£¬ÊÇ»ùÓÚÔÐ͵Ä;
* µ«ÊÇËûµÄÒ»Ð©ÌØÐÔ(º¯ÊýÊÇÊý¾Ý)£¬Ê¹µÃËü¿ÉÒÔÄ£Äâ»ùÓÚÀàµÄÃæÏò¶ÔÏ󣬵«ÊÇ JavaScript ²¢²»Ö§³ÖºÍ Java Ò»ÑùµÄÀ࣬
* Òò´Ë JavaScript ÖеÄ"Àà"¿ÉÒÔ³Æ×÷"αÀà"
*/
//
/**
* ¹¹Ô캯Êý: js ÖÐÓÃÀ´ºÍ new ÔËËã·ûÒ»ÆðʹÓõĺ¯Êý³Æ× ......
1. ¶¨ÒåÒ»¸öÓÃÓÚÊä³öJavaScript´úÂë µÄServletÀà¡£
package com.mycompany.response.servlet;
import java.io.IOException;
import java.io.PrintWriter;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServle ......
<html>
<body>
<script type="text/javascript">
//·½·¨Ò»
var num_arr= [];
for (var i = 0 ; i < 10 ; i ++)
{
num_arr[i] = i;
}
document.write(num_arr+'</br>');
//·½·¨¶þ
var obj_arr=new Array();
obj_arr[6]='ss';
document.write(obj_arr.len ......
Dynamic Script Elements ¶¯Ì¬½Å±¾ÔªËØ
The Document Object Model (DOM) allows you to dynamically create almost any part of an HTML document using JavaScript. At its root, the <script> element isn't any different than any other element on a page: references can be retrie ......
¼ÙÈçä¯ÀÀÆ÷À뿪ÁËJavaScript
¼ÙÈçä¯ÀÀÆ÷À뿪ÁË JavaScript£¬ÄÇô»¥ÁªÍøÉϾø´ó¶àÊýÍøÒ³¾ÍÎÞ·¨Õ¹Ê¾¡£µ«ÊǼ¤½øµÄÖ÷ÕŲ¢·ÇÒ»ÎÞÊÇ´¦£¬ÖÁÉÙËüÄÜ·ñ´Ù½øÎÒÃǶÔÊìÊÓÎ޶õÄÊÂÎ»»Ò»¸ö½Ç¶È×ö½øÒ»²½Ë¼¿¼¡£¼ÙÈçÓÃJavaÌæ»»JavaScript£¬»áÓÐʲôºÃ´¦£¿ºÃ´¦»òÐíÓÐÈý¸ö²ãÃæ£¬¶ÔÓÚÊÖ»úÓ¦ÓöøÑÔ£¬ÕâЩÓŵãÓÈÆä¿É¹ó¡£
1. Ô¤ÏȱàÒ룬ʼþÏì ......