1. JavaScript中的對象
JavaScript是基於對象的,異於C++或Java的面向對象。
JavaScript的對象由屬性和方法組成。
JavaScript對象:JavaScript內部對象,由瀏覽器環境提供,創建新對象
操作對象的語句:For ... in: For(對象屬性名 in 已知對象名), with: with object{ ... }, this, New
對象屬性的引用: (1) . (2). 下標 (3). 字符串作下標
對象方法的引用:ObjectName.methods();
常用對象:
string: length;
anchor(), big(), Italics(), bold(), blink(), small(), fixed(), fontsize(size), fontcolor(color),
toLowerCase(), toUpperCase(), indexOf[charactor,fromIndex], substring(start,end)
math: E, LN10, LN2, PI, SQRT1-2, SQRT2;
abs(), sin(), cos(), asin(), acos(), tan(), atan(), round(), sqrt(), Pow(base, exponent)
Date: MyDate = New Date();
getYear(), ...
setYear(), ...
創建新對象
Function Object(屬性表)
This.prop1=prop1
This.prop2=prop2
...
This.meth=FunctionName1;
This.meth=FunctionName2;
...
用New對象的方法實現JavaScript中的數組
Function arrayName (size)
For (var X=0; X<=size;X++)
this[X]=0;
this.lenght=size;
Return this;
內部數組
anchors[]
links[]
Forms[]
Elements[]
Frames[]
anchors[]
使用瀏覽器內部對象:
navigator
windows
location
history
document (*)
document:
Links |
Anchor |
Form |
Method |
Prop |
鏈接對象 |
錨對象 |
窗體對象 |
方法 |
對象 |
document的attribute屬性:alinkcolor, linkcolor, VlinkColor,bgcolor, Fgcolor
document的基本元素:forms,anchors,links
2. JavaScript中的系統函數
test=eval("8+9+5/2"); //返回字符串表達式中的值
unEscape (string); //返回字符串ASCII碼
escape(character) //返回字符編碼
parseFloat(floustring); //返回實數
parseInt(numbestring ,radix); //返回不同進制的數