Professional Documents
Culture Documents
<head>
<title>111111111</title>
<script language="JavaScript">
function showAlert()
{ alert("");
</script>
</head>
<body onload="showAlert()">
</body>
</html>
0-1
0-1
<html>
<head>
<title>2222222222</title>
</head>
<body onload="showAlert()">
<script language="JavaScript">
alert("")
</script>
</body>
</html>
0-2
0-2
<html>
<head>
<title>2222222222</title>
</head>
</body>
</html>
=======================.js ===========================
alert("");
<body onload="showAlert()">
<script src=".js">
</script>
0-3
0-3
<script>
document.title = "";
//
//
with( document ){
write("numNull = " + numNull + "<BR>");
write("numNull * 10 = " + numNull*10 + "<BR>");
write("numUndef = " + numUndef + "<BR>");
write("numUndef * 10 = " + numUndef*10 + "<BR>");
}
</script>
1-2
1-2
<script>
document.title = "";
//30
//
//70
//
document.write("+<BR>");
document.write("\"70\"+30=" + convertAdd + "<BR>");
document.write("70+30=" + numberAdd + "<BR>");
document.write("<BR>");
document.write("\"70\"-30=" + convertSub + "<BR>");
document.write("70-30=" + numberSub + "<BR>");
</script>
1-5
1-5
<html>
<head>
<title></title>
</head>
<body>
<script language="JavaScript">
<!-var1 = "ABC";
document.write("var1 ");
if( typeof(var1) == "undefined" )
document.write("<br>");
else
document.write(" (" + typeof(var1) + ")<br>");
document.write("var2 ");
if( typeof(var2) == "undefined" )
document.write("<br>");
else
document.write(" (" + typeof(var2) + ")<br>");
// -->
</script>
</body>
</html>
1-6
1-6
<script>
document.title = "";
var variable = "";
localFunction();
//
//
function localFunction(){
var variable = "";
//
document.write("<BR>" + "" + "<BR>");
document.write(variable);
}
document.write("<BR>" + "" + "<BR>");
document.write(variable);
</script>
1-7
1-7
<script>
document.title = "";
var N1 = 10;
var N2 = 4;
numAdd = N1 + N2;
numSub = N1 - N2;
//numAdd
//numSub
2-2
2-2
<script>
document.title = "";
var B1 = 1;
var B2 = 0;
var chk1 = B1 ? "" : "";
var chk2 = B2 ? "true" : "false";
document.write("B1=1 , B2=0 <BR>");
document.write("chk1 = B1?'':'' chk1" + chk1 + "<BR>");
2-3
2-3
<script>
document.title = "";
var N1 = 1;
var N2 = 2;
var N3 = '3';
2-4
2-4
<script>
document.title = "";
var aA = pA = aS = pS = 10;
var aftPlus = aA++;
var prePlus = ++pA;
var aftMinus = aS--;
var preMinus = --pS;
with( document ){
write("aA=pA=aS=pS=10 <BR>");
write("aftPlus=aA++");
write("aftPlus=" , aftPlus, ", aA=", aA, "<BR>");
write("prePlus=++pA");
write("prePlus=" , prePlus, ", pA=", pA, "<BR>");
write("aftMinus=aS--");
write("aftMinus=" , aftMinus, ", aS=", aS, "<BR>");
write("preMinus=--pS");
write("preMinus=" , preMinus, ", pS=", pS);
}
</script>
2-5
2-5
<script>
<!-
document.title = "";
var t = true;
//ttrue
var f = false;
//ffalse
with( document ){
}
-->
</script>
2-6
2-6
<script>
<!-document.title = "this";
//n
function calFunction( n ){ this.num = n * 5 }
//10numObj
numObj = new calFunction(10);
document.write("10( this.num=*5 ) <BR>");
document.write("numObj.num = " + numObj.num);
-->
</script>
2-7 this
2-7 this
<script>
document.title = "newdelete";
//100numObj
with( document ){
write("numObj=new Number(100)<BR>");
write("numObj = " + numObj + "<BR><BR>");
delete numObj;
write("delete numObj<BR>");
if( typeof(numObj) == "undefined" )
write("numObj = " + "");
else
write("numObj = " + numObj + "<BR>");
}
</script>
2-8 newdelete
2-8 newdelete
<script>
<!-document.title = "typeof";
with( document ){
write("<LI> 123.45 ", typeof(123.45) );
write("<LI> \"ABC\" ", typeof("ABC") );
write("<LI> (new Number()) ", typeof(new Number()) );
2-9 typeof
2-9 typeof
<script>
document.title = "if~else";
var now = new Date();
var sec = now.getSeconds();
//now
//sec
3-1
if_else
3-1
if_else
<Script>
document.title = "switch";
var now = new Date();
var sec = now.getSeconds();
//now
//sec
</Script>
//10
num = Math.floor( sec/10 );
switch( num ){
case 0:
document.write( sec + " < 10" );
break;
case 1:
document.write( "9 < " + sec + " < 20" );
break;
case 2:
document.write( "19 < " + sec + " < 30" );
break;
default:
document.write( sec + " > 29" );
3-1
switch
3-1
switch
<Script>
</Script>
3-2
for_in
3-2
for_in
<Script>
<!-document.title = "for";
document.write(" <BR>");
for( i=1; i<4; i++ ){
document.write("i = ", i, "<BR>");
}
document.write("<BR>");
document.write(" <BR>");
for( j=3; j>0; j-- ){
document.write("j = ", j, "<BR>");
}
-->
</Script>
3-2
for
3-2
for
<script>
<!-document.title = "";
for(i=1; i<10; i++){
//
for(j=1; j<=i; j++){
//*
if(j<i)
else
//
}
//
document.write(" ");
//*
document.write("*");
}
document.write("<BR>");
-->
</script>
3-2
3-2
<script>
<!-
document.title = "";
document.write("*");
document.write("<BR>");
}
-->
</script>
3-2
3-2
<Script>
<!-document.title = "for";
document.write("ij<BR><BR>");
//
for( i=1; i<6; i++ ){
//
for( j=1; j<6; j++ )
document.write("i=" + i + " " +
"j=" + j +
" ");
document.write("<BR>");
//
}
-->
</Script>
3-2
for
3-2
for
<Script>
<!-document.title = "breakcontinue";
var i = 0;
var j = 0;
document.write("i = j = 1~10 <BR><BR>");
document.write("i5 <BR>");
while( i < 10 ){
i++;
if ( i > 5 ) break;
document.write("i = ", i, "<BR>");
}
document.write("<BR>");
document.write("j6 <BR>");
while( j < 10 ){
j++;
if ( j < 6 ) continue;
document.write("j = ", j, "<BR>");
}
//i5
//j6
-->
</Script>
3-3
breakcontinue
3-3
breakcontinue
<script>
document.title = "while";
var now = new Date();
var sec = now.getSeconds();
var getSec = sec;
var sum = 0;
//now
//sec
3-3
while
3-3
while
<Script>
<!-document.title = "whiledo while";
var i = j = 1;
document.write("while <BR>");
while( i < 6 ){
document.write("i = ", i, "<BR>");
i++;
}
document.write("<BR>");
document.write("do while <BR>");
do{
document.write("j = " ,j ,"<BR>");
j++;
}while( j < 6 )
-->
</Script>
3-3
whiledo_while
3-3
whiledo_while
<script>
<!-document.title = "";
for(i=9; i>0; i--){
for(j=1; j<=i; j++){
if(j<i)
else
//
//*
//
document.write(" ");
//*
document.write("*");
}
document.write("<BR>");
//
}
-->
</script>
3-4
3-4
<script>
<!-document.title = "";
for(i=1; i<10; i++){
//
//*
document.write("<BR>");
//
}
-->
</script>
3-4
3-4
<script>
<!-
document.title = "";
document.write("*");
document.write("<BR>");
}
-->
</script>
//
//*
//
3-4
3-4
<Script>
<!--
document.title = "";
for( i=1; i<9; i++ ){
//
for( j=1; j<9; j++ ){
//
if( i== 1){
//
document.write("*");
}else if( i== 8){
//
document.write("*");
}else{
//
if( j==1 || j== 8 )
//
document.write("*");
else
//
document.write(" ");
}
}
document.write("<BR>");
//
}
-->
</Script>
3-4
3-4
<HTML>
<HEAD>
<TITLE></TITLE>
</HEAD>
<script>
var arr = new Array("00","11","22","33","44","55","66",
"77","88","99","AA","BB","CC","DD","EE","FF");
function showAlert( color ){
alert(""+color);
}
document.write("<P>");
document.write("<table border=1><tr>");
for( var i=0; i<arr.length; i++ ){
color = arr[i]+arr[i]+arr[i];
document.write("<td bgcolor="+color+" title="+
color+"><a onClick='showAlert(\""+color+
"\")'><img height=8 width=8 border=0></td>");
}
document.write("</tr></table>");
</script>
</HTML>
5-1
5-1
<html>
<head>
<title></title>
</head>
<body>
<script language="JavaScript">
<!-arr = new Array("0","1");
document.write("<br>");
document.write(arr[0]+" "+ arr[1] + "<br><br>");
delete arr;
document.write("delete<br>");
if(typeof(arr) == "undefined")
document.write("");
else
document.write(arr[0]+" "+ arr[1]);
// -->
</script>
</body>
</html>
5-1
5-1
<html>
<head>
<title></title>
</head>
<body>
<script language="JavaScript">
<!-arr = new Array("0","1","2");
with( document ){
write("<font color='blue'></font><br>");
write(arr[0] + "<br>");
write(arr[1] + "<br>");
write(arr[2]);
}
// -->
</script>
</body>
</html>
5-1
5-1
<script>
document.title = "concatjoin";
var aheadLetter = new Array("A", "B", "C");
var behindLetter = new Array("X", "Y", "Z");
//concat
arrConcat = aheadLetter.concat( behindLetter );
//join/
arrJoin = arrConcat.join("/");
with( document ){
write( "A,B,C<BR> X,Y,Z<BR>" );
write( "" + arrConcat + "<BR>" );
write( "/ " + arrJoin + "<BR>" );
}
</script>
5-2
concatjoin
5-2
concatjoin
<script>
document.title = "length";
var weekData = new Array("","","","",
"","","");
</script>
5-2
length
5-2
length
<script>
document.title = "sortreverse";
function arrSort( n ){
//
weekData = new Array( "1","3","5","2","4","6" );
//n
if( n == 1 )
//
document.myForm.showText.value = weekData.sort();
else
//
document.myForm.showText.value = weekData.reverse();
}
</script>
<FORM NAME="myForm">
<FONT SIZE="4">1,3,5,2,4,6</FONT><BR>
<INPUT TYPE="button" VALUE="" onClick="arrSort(1)">
<INPUT TYPE="button" VALUE="" onClick="arrSort(2)">
<INPUT TYPE="text" NAME="showText"
STYLE="font-size:14pt" SIZE="8">
</FORM>
5-2
sortreverse
5-2
sortreverse
<html>
<head>
<title></title>
</head>
<body>
<script language="JavaScript">
<!-arr = new Array();
arr[""] = "";
arr[""] = "google";
arr[""] = "openfind";
document.write("" +
arr[""] + "<br>");
document.write("" +
arr[""] + "<br>");
document.write("" +
arr[""]);
// -->
</script>
</body>
</html>
5-3
5-3