2008年8月14日 星期四

body's event

onload:
when page is loaded

onresize:
when browser is resized

style object

each element of web page has a style object

style.height:

style.width:

document object

document.body.clientHeigth:
client window height

document.body.clientWidth:
client window width

document.getElementById("elementName")

document.cookie:
set cookie:
ex:
document.cookie="name1=peter;expires=1/1/2000;";

how to clear cookie:
set it value to "" & expiration data to -1

2008年6月12日 星期四

string method

indexOf()
find the pattern in the string
ex:
"abcdef".indexof("bc");

getElementById

getElementById
get html element 
ex:
html element:
input type="text", id="test",  name="abc"
javascript:
document.getElementById("test").value
access data from value

math methods

NaN:
not a number

parseInt():
convert test to integer
ex:
parseInt("1");

parseFloat()

isNaN():
ex:
var a=3;
isNaN(a);

toFixed():
ex:
a=3.333;
a.toFixed(2);
---> a=3.33

alert

show an alert box:
ex:
alert("hello");