JavaScript Common statements
1.document.write (""); Output statement
The comment in 2.JS is//
3. The traditional order of HTML documents is:
Document->html-> (Head,body)
4. The DOM order in a browser window is:
Window-> (navigator,screen,history,location,document)
5. Get the names and values of the elements in the form:
DOCUMENT.GETELEMENTBYIDX_X ("ID number of element in form"). Name (or value)
6. A lowercase to uppercase JS:
document.getelementbyidx_x ("Output"). Value=document.getelementbyidx_x ("Input"). Value.touppercase ();
Value types in 7.JS:
String, Number,Boolean,Null,Object,Function
The character type in 8.JS is converted to a numeric type:
parseint (), parsefloat ()
The numbers in 9.JS are converted into character types:
("" variable)
The length of the string in 10.JS is:
(length)
The characters in 11.JS are connected to the word typeface using the number.
The comparison operators in 12.JS are:
= = equals,! = does not equal, >,>=,<.<=
Declare variables in 13.JS using:
var to make a declaration
The structure of judgment statements in 14.JS:
if(condition) {}Else{}
Loop structure in 15.JS:
for([initial expression]; [Condition]; [Upadte expression]) {Inside loop}
16. The Circular abort command is:
Break
function definitions in 17.JS:
functionfunctionname ([parameter],...) {Statement[s]}
18. When multiple form forms appear in a file, you can use document.forms[0],document.forms[1] instead.
19. Window:
Open Window window.open (), close a window: window.close (), window itself: Self
20. Settings for the status bar:
window.status= "character";
21. Popup Message:
Window.alert ("character");
22. Pop-Up Confirmation box:
Window.confirm ();
23. Pop-up input prompt box:
Window.prompt ();
24. Specify the location of the currently displayed link:
window.location.href= "URL"
25. Remove the number of all forms in the form:
Document.forms.length
26. Close the output stream of the document:
Document.close ();
27. String Append connector: =
28. Create a document element:
Document.createelement_x (), document.createTextNode ()
29. Ways to get the elements:
Document.getelementbyidx_x ()
30. Set the value of the members of all text types in the form to be null:
varform = Window.document.forms[0]
for(vari = 0; I<form.elements.length;i) {
if(Form.elements.type = = "Text") {
Form.elements.value = "";
}
}
31. Check the button in JS to determine whether to select:
Document.forms[0].checkthis.checked
(The Checked property represents whether to return true or False for a check)
32. Radio button Group (the name of the radio button must be the same):
The length of the radio button group to take Document.forms[0].groupname.length
33. Radio button Group to determine whether to be selected is also used checked.
34. The value of the drop-down list box:
Document.forms[0].selectname.options[n].value
(n sometimes use the drop-down list box name plus. SelectedIndex to determine the selected value)
35. Definition of the string:
varMyString =New String("This is Lightsword");
36. Turn the string into uppercase:
string. toUpperCase (); The string is converted to lowercase:string. toLowerCase ();
37. Returns the position where the string 2 appears in string 1:
String1.indexof ("String2")!=-1 the description was not found.
38. Take a character from the specified position in the string:
Stringa.charat (9);
39. Remove the substring in the string that specifies the start and end points:
Stringa.substring (2,6);
40. Mathematical Functions:
Math.PI(return pi), Math.sqrt2 (return to root), Math.Max(value1,value2) returns two number of
Most in the value, Math.POW(value1,10) Returns the 10-time value1, Math.round(value1) Rounding function,
Math. Floor(Math.random () * (n 1)) returns the random number
41. Define a Date type variable:
varToday =NewDate();
42. List of date functions:
Dateobj.gettime () Gets the time, dateobj.getyear () Gets the year, Dateobj.getfullyear () gets a four-digit year,
Dateobj.getmonth () Get month, dateobj.getDate() Get day, Dateobj.getday () Get date a few,
Dateobj.gethours () Gets the Hour, dateobj.getminutes () gets points, dateobj.getseconds () gets seconds,
Dateobj.settime (value) set time, Dateobj.setyear (Val) set year,
Dateobj.setmonth (Val) Set the month, Dateobj.setdate (Val) set the day,
Dateobj.setday (val) sets the day of the week, Dateobj.sethours sets the hour, Dateobj.setminutes (Val) sets the points,
Dateobj.setseconds (val) Set seconds [Note: This date time starts from 0]
The 43.FRAME is represented in the following way:
[Window.] Frames[n]. objfuncvarname,frames["FrameName"]. Objfuncvarname,framename.objfuncvarname
44.parent represents the parent object, top represents the topmost object
45. Open the child window's parent window as: opener
46. Indicates the location currently belongs to: this
47. When invoking the JS function in the hyperlink: (JavaScript:) to start with the name of the Add function
48. Do not perform this js:< in the old browser!--// -
49. Refer to a file-type Js:<script type= "Text/javascript" src= "Aaa.js" ></script>
50. Specify the html:<noscript></noscript> that is displayed in browsers that do not support scripting
51. When hyperlinks and onclick events are sometimes, the old version of the browser turns to a.html, otherwise it turns to b.html.
Example: <a href= "a.html" onclick= "location.href= ' b.html '; return false" >dfsadf</a>
The 52.JS built-in objects are:
Array,Boolean,Date, Error,evalerror,
Function, Math, Number,Object, Rangeerror,referenceerror,
RegexpString, Syntaxerror,typeerror,urierror
Line break in 53.JS: \ n
54. Window Full Screen Size:
<script>functionFullscreen () {This.moveto (0,0); this.outerwidth=screen.availwidth;
This.outerheight=screen.availheight;} Window.maximize=fullscreen;</script>
All in 55.JS represents all elements of its lower layer
Focus order in 56.JS: document.getelementbyidx_x ("form Element"). TabIndex = 1
The value of 57.innerHTML is the value of the form element:
such as <p id= "para" > "How is <em>you</em>" </P>, then the value of innerHTML is: how is <em>you</em>
The value of 58.innerTEXT is the same as above, except that the <em> is not displayed.
59.contentEditable can set whether the element can be modified, iscontenteditable returns whether the state can be modified.
60.isDisabled determines whether the status is forbidden. Disabled setting the Forbidden State
61.length get length, return integral type value
62.addBehavior () is a JS called external function file whose extension is. htc
63.window.focus () causes the current window to precede all windows.
64.blur () refers to the loss of focus. In contrast to focus ().
65.select () refers to elements that are selected.
66. Prevent users from entering text into the text box:
Onfocus= "This.blur ()"
67. Remove the number of occurrences of the element in the page:
Document.all.tags ("div (or other HTML tag)"). length
The 68.JS is divided into two form outputs: modal and non-modal.
window.showModalDialog (), window.showmodeless ()
69. Settings for status bar text:
window.status= ' text ', the default status bar text setting: Window.defaultstatus = ' text. ';
70. Add to Favorites:
External. Addfavorite ("http://meil.cnblogs.com";, "Jaskdlf");
Do not do anything when you encounter a script error in 71.JS:
Window.onerror = doNothing; The syntax for specifying an error handle is: Window.onerror = handleError;
Specifies the parent window of the currently open window in 72.JS:
Window.opener, Support Opener.opener ... The multiplicity of continuation.
The self in 73.JS refers to the current window
74.JS status bar display content: window.status= "Content"
Top in 75.JS refers to the topmost frame in the frame set.
Close the current window in 76.JS: Window.close ();
The box for confirmation in 77.JS:if(Confirm ("Is you sure?")) {Alert ("OK");}Else{alert ("not OK");}
Window redirection in 78.JS: Window.navigate ("http://meil.cnblogs.com";);
Print in 79.JS: window.Print()
Prompt input box in 80.JS: Window.prompt ("message", "defaultreply");
Window scroll bar in 81.JS: Window.Scroll (x, y)
window in 82.JS scroll to position: Window.scrollby
Set time interval in 83.JS: setinterval ("expr", Msecdelay) or setinterval (Funcref,msecdelay) or settimeout
Modal display in 84.JS in IE4 line, not in nn: ShowModalDialog ("URL" [, Arguments][,features]);
Handle used before exiting in 85.JS:
functionVerifyclose () {event.returnvalue= "We really like you and hope you'll stay longer.";}} Window.=verifyclose;
86. File handle used when the form is first called: onload ()
87. File handle called when the form is closed: onunload ()
Properties of the 88.window.location:
Protocol (http:), hostname (www.example.com), port (+), host (WWW.EXAMPLE.COM:80),
Pathname ("/a/a.html"), hash ("#giantGizmo", refers to jump to the corresponding anchor), href (All information)
89.window.location.reload () refreshes the current page.
90.window.history.back () returns to the previous page, Window.history.forward () returns to the next page,
Window.history.go (return to page or use the URL you have visited)
91.document.write () output with no newline, Document.writeln () line-wrapping output
92.document.body.nowrap=true; Prevent link text from wrapping.
93. Variable name. charAt (the first few), take the character of the variable.
94. "ABC". charCodeAt (the first few), returns the ASCII value of the first few characters.
95. String Connection:string. Concat (string2), or connect with =
96. Variable. IndexOf ("character", starting position), returns the first occurrence of the position (calculated starting from 0)
97.stringThe last occurrence of the. lastIndexOf (Searchstring[,startindex]) position.
98.string. Match (Regexpression) to determine if the characters match.
99.stringReplace the existing string with. Replace (regexpression,replacestring).
100.string.Split(delimiter) returns an array of stored values.
101.string.substr(Start[,length]) takes a string from the first to the specified length.
102.string. toLowerCase () makes the string all lowercase.
103.string. toUpperCase () makes all characters uppercase.
104.parseInt (string[, Radix (on behalf of the system)]) Cast to integral type.
105.parseFloat (string[, Radix]) Cast to floating-point type.
106.isNaN (variable): The test is a numeric type.
107. Define the keywords for the constants:Const, define the keyword for the variable:var
JS Common statements