Java Web基礎知識day 03——javascript知識
javascriptは通称jsです
JavaScript , 、 、 ,
。 JavaScript , ,
:
ECMAScript:js ( ...)
BOM:
DOM:
:
html
html
:
js ,
js .js
js html
1:
js , head
2: js
script src
js :
var = ;
var ;
= ;
:
var
, ,
js :
:(5 )
Null
String
Number
Boolean
Undefined
typeof , ,
typeof | ;
null, typeof object
typeof
undefined - Undefined
boolean - Boolean
number - Number
string - String
object - Null
:
//
js:
:
1:
function ( ){
;
}
:
( )
js :
:
: onclick
: onsubmit form onsubmit="return ()" boolean
: onload
:★
onfocus
onblur
:★
onsubmit
onchange
:★
onload
( )
onclick
( )
ondblclick:
onmousedown:
onmouserup:
onmousemove:
onmouserover:
onmouserout:
( )
onkeydown:
onkeyup:
onkeypress:
js :
1:
js :
1:
var obj=documnet.getElementById("id ");
value
obj.value;
obj.innerHTML;
:
1:
function ( ){
;
}
2:
var =function( ){
;
}
js :
1:
2:
document.getElementById("id ").onclick=function( ){....}
document.getElementById("id ").onclick=
:
a. 2 js html
b. 2 js onload .
bom window
:
var id=setInterVal(code, ):
var id=setTimeout(code, ):
:
clearInterval(id);
claerTimeout(id);
String
String String
substring(0,endIndex);
:
:
: > >= < <=
java
, , 3>"2"
, , false 3>"hello"
, ascii
== ===
== :
===: ,
:
if java
for while java
switch java ( ,switch . )
/
:
1.css html
3
2.css :
id class
3.js
js html
4.
5.
2
6.
onclick onload onsubmit
7.
2
8. 2
9.for while if
bom( )
5
window:
location: ( )
history:
window :
(frame iframe ), HTML window ,
window 。
:
window
window.location location
window.history history
...
alert("...."):
confirm(" ?"): :boolean
prompt(" "): :
setInterval(code, ):
setTimeout(code, ): .
:
setInterval(showAd,4000);
serInterval("showAd()",4000);
clearInterval(id):
clearTimeout(id):
open(url):
close():
location:
:
href: url( )
location.href; url
location.href="..."; url a
history:
back();
forward():
★go(int)
go(-1) back()
go(1) forward()
dom( )
html , , (document )
(Node)
document
element
attribute
text
:
document :
:
document.getElementById("id "):
document.getElementsByTagName(" "): ( )
document.getElementsByClassName("class "): class ( )
document.getElementsByName("name "): name ( )
value
dom .value;
dom .value="";
dom .innerHTML;
dom .innerHTML="";
style
dom .style. ;
dom .style. ="";
dom .
/
htmldom js htmldom xml dom
xml dom document
xml dom element
appendChild(dom ):
:
:
new Array();// 0
new Array(size);//
new Array(e1,e2..);//
var arr4=["aa","bb"];
:
length
:
:( )
:
pop():
push():
shift():
unshift():
:
join( ):
:
concat(): , 。
:
sort();
reverse();
:
String Number Boolean ,
Array:
String:
:
new String( | );//
String( | );//
:
substring(start,end):[start,end)
substr(start,size):
charAt(index): 。
indexOf(""):
replace():
split():
:length
Boolean:
:
new Boolean( | );
Boolean( | );
0 true
Number
:
new Number( | );
Number( | );
:
null====>0
fale====>0 true====>1
=====>
NaN
Date:
new Date();
:
toLocalString()
RegExp:
:
/ /
/ /
new RegExp(" ")
new RegExp(" "," ")
:
i:
g:
:
test() : boolean
Math:
Math. |
Math.PI
Math.random() [0,1)
:
★
decodeURI() URI。
encodeURI() URI。
Number():
String():
parseInt():
parseFloat():
eval() JavaScript , 。