JavaScript ½âÎö JSON Êý¾Ý
JSON £¨JavaScript Object Notation£©Ò»ÖÖ¼òµ¥µÄÊý¾Ý¸ñʽ£¬±Èxml¸üÇáÇÉ¡£ JSON ÊÇ JavaScript ÔÉú¸ñʽ£¬ÕâÒâζ×ÅÔÚ JavaScript Öд¦Àí JSON Êý¾Ý²»ÐèÒªÈκÎÌØÊâµÄ API »ò¹¤¾ß°ü¡£
JSONµÄ¹æÔòºÜ¼òµ¥£º ¶ÔÏóÊÇÒ»¸öÎÞÐòµÄ“‘Ãû³Æ/Öµ’¶Ô”¼¯ºÏ¡£Ò»¸ö¶ÔÏóÒÔ“{”£¨×óÀ¨ºÅ£©¿ªÊ¼£¬“}”£¨ÓÒÀ¨ºÅ£©½áÊø¡£Ã¿¸ö“Ãû³Æ”ºó¸úÒ»¸ö“:”£¨Ã°ºÅ£©£»“‘Ãû³Æ/Öµ’ ¶Ô”Ö®¼äʹÓÓ,”£¨¶ººÅ£©·Ö¸ô¡£¾ßÌåϸ½Ú²Î¿¼http://www.json.org/json-zh.html
¾Ù¸ö¼òµ¥µÄÀý×Ó£º
js ´úÂë
function showJSON() {
var user =
{
"username":"andy",
"age":20,
"info": { "tel": "123456", "cellphone": "98765"},
"address":
[
{"city":"beijing","postcode":"222333"},
{"city":"newyork","postcode":"555666"}
]
}
alert(user.username);
alert(user.age);
alert(user.info.cellphone);
alert(user.address[0].city);
alert(user.address[0].postcode);
}
Õâ±íʾһ¸öuser¶ÔÏó£¬ÓµÓÐusername, age, info, address µÈÊôÐÔ¡£
ͬÑùÒ²¿ÉÒÔÓÃJSONÀ´¼òµ¥µÄÐÞ¸ÄÊý¾Ý£
Ïà¹ØÎĵµ£º
deleteÖ»ÄÜɾ³ý¿ª·¢Õ߶¨ÒåµÄÊôÐÔ»ò·½·¨£¬ÔʼµÄECMAScript·½·¨²»ÄÜɾ³ý£¬ÒòΪ²»ÊÇ¿ª·¢Õ߶¨ÒåµÄ£¬±ÈÈ磺toString()¡£
var o = new Object;
o.name = "Nicholas";
delete o.name;
&n ......
±Õ°ü£º
ECMAScriptÖ§³Ö±Õ°ü¡£Ëùν±Õ°ü£¬¾ÍÊǺ¯ÊýÄÜʹÓú¯ÊýÍⶨÒåµÄ±äÁ¿¡£
var iBaseNum = 10;
function addNumbers(iNum1, iNum2)
{
function doAddition()
......
<!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" lang="gb2312">
<head>
<head>
<title> ¹ØÓÚarguments,callee,callerµÈµÄ²âÊÔ &l ......
JavaScript¶ÁÈ¡TxtÎļþ
<html>
<head>
<title>new page</title>
<script>
GetHeader(src) {
var ForReading=1;
var fso=new ActiveXObject("Scripting.FileSystemObject");
var f=fso.OpenTextFile(src,ForReading);
return(f.ReadAll());
}
var arr=GetHe ......
ÀûÓÃjsÀ´¶¯Ì¬´´½¨±í¸ñÓÐÁ½ÖÖ¸ñʽ£¬appendChild()ºÍinsertRow¡¢insertCell()¡£Á½ÖÖ·½Ê½Æäʵ²î²»¶à£¬µ«µÚÒ»ÖÖÓпÉÄÜÔÚIEÉÏÓÐÎÊÌ⣬ËùÒÔÍƼö´ó¼ÒʹÓõڶþÖÖÁË£¬Ö±½Ó˵°É¡£
1¡¢inserRow()ºÍinsertCell()º¯Êý
insertRow()º¯Êý¿ÉÒÔ´ø²ÎÊý£¬ÐÎʽÈçÏ£º
insertRow(index)£ºindex´Ó0¿ªÊ¼
Õâ¸öº¯Êý½«ÐÂÐÐÌí¼Óµ½indexµÄÄÇһР......