I am a half-way expert in j2ee, and I have never learned from the system. Many functions can be used, but I cannot tell the truth.
Jquery is often used in jsp files and is currently used for javascript.
If you have any comments or suggestions, please submit them more.
Bytes -----------------------------------------------------------------------------------------------------------------------------
Contains three parts: Date Format, url extraction and decomposition, and object.
<! 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">
<Head>
<Meta http-equiv = "Content-Type" content = "text/html; charset = gb2312"/>
<Title> JavaScript syntax </title>
</Head>
<Script type = "text/javascript">
<! --
Var thisDate = new Date ();
/* Date Format */
Document. writeln (thisDate. toString ());
Document. writeln ("<br/> ");
Document. write (thisDate. getFullYear () + "-" + thisDate. getMonth () + "-" + thisDate. getDay ());
Document. writeln ("");
Document. writeln (thisDate. getHours () + ":" + thisDate. getMinutes () + ":" + thisDate. getSeconds () + ". "+ thisDate. getMilliseconds ());
/* URL decomposition */
Document. write ("// Set a URL with parameters such as file: // E: /Documents % 20and % 20 Settings/simon/% E6 % A1 % 8C % E9 % 9D % A2/Untitled-1.html? Aa = 11 & bb = cc
Var url = document. URL. split ("? ");
Var param = url [1]. split ("&");
For (I = 0; I <param. length; I ++ ){
Var val = param [I]. split ("= ");
Document. write (val [0] + "=" + val [1]);
Document. write ("<br/> ");
}
// Open the new document object
Document. write ("Document. write ("<input type = 'button 'value = 'new document' onclick = 'newdocument ()'/> ");
Function newDocument (){
Document. open ();
Document. write ("New Document ");
Window. setTimeout (window. close (), "3000 ");
}
// Webpage loading progress window. When there is no content on the page, the page is refreshed too quickly. You can use onload to control the page.
// Var placeHolder2 = document.open('Untitled-2.html ', 'test', 'width = 300, height = 300 ');
// Javascript Object
/* Object
Attributes can be defined within an object, such as name and age. They can also be defined outside the object, such as addr.
The method can be defined in two ways. For details, see the definition of "say" and "ageAdd ".
*/
Function Person (){
This. name = 'a ';
This. age = 12;
This. say = sayPerson;
This. ageAdd = function (){
This. age ++;
}
}
Function sayPerson (){
Alert (this. name + "," + this. age + "," + this. addr );
}
Function newP (){
Var p = new Person ();
P. addr = "abcd ";
P. say ();
P. ageAdd ();
P. say ();
}
// Object 2 simple custom object internal functions
Function cHuman (){
Function sayHuman (attr ){
Return human [attr];
}
Var human = new Object ();
Human. userName = "abc ";
Human. userAge = 12;
Alert (sayHuman ("userAge "));
Alert (sayHuman ("userName "));
}
// Object 3
Function Simon () {this. userName; this. userAge ;}
// Simon. prototype. userName = "";
Simon. prototype. setUserName = function (userName) {this. userName = userName ;}
Simon. prototype. getUserName = function () {return this. userName ;}
Simon. prototype. setUserAge = function (userAge) {this. userAge = userAge ;}
Simon. prototype. getUserAge = function () {return this. userAge ;}
Function cSimon (){
Var simon = new Simon ();
Simon. setUserName ("Simon hahah ");
Simon. setUserAge (22 );
Alert (simon. getUserName () + "" + simon. getUserAge ());
With (simon) {// with usage
Alert (getUserName () + "," + getUserAge ());
}
Var p, str = "";
For (p in simon ){
Str + = p + "\ n ";
}
Alert (str );
}
// Object 4
Function cObj (){
Function Obj () {this. userName = "aa"; this. userAge = 55 ;}
Var obj = new Obj ();
Var p, str = "";
For (p in obj) {// for usage
Str + = p + "=" + obj [p] + "\ n ";
}
Alert (str );
}
// Object 5 array object
Function MyArr (){
This. length = arguments. length;
For (I = 0; I <this. length; I ++ ){
This [I] = arguments [I];
}
}
Function cMyArr (){
Var myArr = new MyArr ("abc", 12, '', 3.5, true );
Var str = "";
For (I = 0; I <myArr. length; I ++ ){
Str + = myArr [I] + ",";
}
Alert (str );
Var p;
Str = "";
For (p in myArr ){
Str + = p + "=" + myArr [p] + "\ n ";
}
Alert (str );
}
// Object 6 array object
Function MyArr2 (size ){
This. length = size;
For (I = 0; I <this. length; I ++ ){
This [I] = "";
}
}
Function cMyArr2 (){
Var myArr2 = new MyArr2 (6 );
MyArr2 [0] = "aa ";
MyArr2 [1] = 3;
MyArr2 [2] = 'dfadfa ';
MyArr2 [3] = true;
Myarr2. [5] = 0.4;
Var p, str = "";
For (p in myArr2) {// for usage
Str + = p + "=" + myArr2 [p] + "\ n ";
}
Alert (str );
}
// -->
</Script>
<Body onload = "placeHolder. close ();">
<Button value = "new person" onclick = "newP ()"> new person </button>
<Button value = "new person" onclick = "cHuman ()"> new Human </button>
<Button value = "new person" onclick = "cSimon ()"> new Simon </button>
<Button value = "new person" onclick = "cObj ()"> new Obj </button>
<Button value = "new person" onclick = "cMyArr ()"> new MyArr </button>
<Button value = "new person" onclick = "cMyArr2 ()"> new MyArr2 </button>
</Body>
</Html>