Common JS written test statements

Source: Internet
Author: User
Tags exit in mathematical functions

Common JavaScript statements: 107

1. Document. Write (""); Output statement

2. Comments in JS are //

3. The traditional HTML document sequence is: Document-> HTML-> (Head, body)

4. the DOM sequence in a browser window is: window-

> (Navigator, screen, history, location, document)

5. Get the name and value of the element in the form: Document. getelementbyid ("ID of the element in the form"). Name (or value)

6. javascript: Document. getelementbyid ("output"). value =

Document. getelementbyid ("input"). value. touppercase ();

7. value types in JS: String, number, Boolean, null, object, Function

8. Convert the numeric type in JS to the numeric type: parseint (), parsefloat ()

9. convert numbers in JS to numeric: ("" variable)

The string length in 10. JS is: (length)

11. The characters in JS are connected to the characters and use delimiter.

12. The comparison operators in JS include: = equals ,! = Not equal to,>, >=, <. <=

13. Declare variables in. js using: var for declaration

14. js judgment statement structure: If (condition) {} else {}

15. Loop Structure in JS: For ([initial expression]; [condition]; [upadte

Expression]) {inside loop}

16. The command for loop abort is break.

17. Function Definition in JS: function functionname ([parameter],...) {statement [s]}

18. When multiple form forms appear in the file, you can use document. Forms [0], document. Forms [1] instead.

19. Window: open window. open (), close a window: window. Close (), the window itself: Self

20. Window. Status = "character ";

21. Window. Alert ("character ");

22. The confirmation box is displayed: window. Confirm ();

23. Window. Prompt ();

24. Specify the position of the currently displayed link: window. Location. href = "url"

25. Retrieve 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 (), document. createtextnode ()

29. method for getting the element: Document. getelementbyid ()

30. Set the value of all text members in the form to NULL:

VaR form = terraform Doc ument. Forms [0]

For (VAR I = 0; I <form. elements. length; I ){

If (Form. elements. type = "text "){

Form. elements. value = "";

}

}

31. Check whether the check button is selected in JS: Document. Forms [0]. Checkthis. Checked

(The checked attribute indicates whether to return true or false if selected)

32. Single-choice button group (the names of Single-choice buttons must be the same): Take the length of Single-choice button Group document. Forms [0]. groupname. Length

33. The single-choice button group also uses checked to determine whether it is selected.

34. Value of the drop-down list box: Document. Forms [0]. selectname. Options [N]. Value

(N sometimes adds. selectedindex to the name of the drop-down list box to determine the value to be selected)

35. String definition: var mystring = new string ("this is lightsword ");

36. Convert string to uppercase: String. touppercase (); Convert string to lowercase: String. tolowercase ();

37. Return the position where string 2 appears in string 1: string1.indexof ("string2 ")! =-1 indicates no.

38. Take a character at the specified position in the string: stringa. charat (9 );

39. Retrieve the substring of the specified start point and end point in the string: stringa. substring );

40. mathematical functions: math. pi (returns the circumference rate), math. sqrt2 (return to the initiator), math. max (value1, value2) returns the most value of the two numbers, math. pow (value1, 10) returns

 

The tenth power of value1, math. Round (value1) Rounding function, math. Floor (math. Random () * (N

1) returns the number of hosts.

41. Define a date variable: var today = new date ();

42. Date function list: dateobj. gettime () get time, dateobj. getyear () Get year, dateobj. getfullyear () get four-digit year, dateobj. getmonth () Get

 

By month, dateobj. getdate () gets the day, dateobj. getday () gets the date, dateobj. gethours () gets the hour, dateobj. getminutes () gets

 

Minute, dateobj. getseconds () to get the second, dateobj. settime (value) to set the time, dateobj. setyear (VAL) to set the year, dateobj. setmonth (VAL) to set

 

Month, dateobj. setdate (VAL) setting day, dateobj. setday (VAL) setting day of the week, dateobj. sethours setting hour, dateobj. setminutes (VAL) Setting

 

Minute, dateobj. setseconds (VAL) sets the second [Note: this date and time start from 0]

43. Frame representation: [window.] frames [N]. objfuncvarname, frames ["framename

"]. Objfuncvarname, framename. objfuncvarname

44. Parent indicates the parent object, and top indicates the top object.

45. Open the parent window of the Child Window: Opener

46. indicates the current location: This

47. When calling JS functions in a hyperlink, use the following name to start with: (javas alias :).

48. Do not execute this Js in the old browser: <! -- // -->

49. Reference a file-Type JS: <s connector type = "text/javas connector" src = "AAA. js">

</S response>

50. Specify the HTML displayed in a browser that does not support scripts: <Nos details> </NOS details>

51.when there are both superlinks and onclicktasks, the browser turns to a.html, And the browser turns to B .html if there is no. For example: <a href = "a.html

"> Dfsadf </a>

52. js internal creation object

Include: array, Boolean, date, error, evalerror, function, math, number, object, rangeerror, referenceerror, Regexp, String, syntaxerror, typeerr

 

Or, urierror

Line feed in 53. JS: \ n

54. Full Screen Window Size: <s leading> function fullscreen () {This. moveTo

(0, 0); this. outerwidth = screen. availwidth; this. outerheight = screen. availheight;} window. Maximize = fullscreen;

</S response>

All in 55. js represents all the elements in its lower layer.

56. js focus sequence: Document. getelementbyid ("form element"). tabindex = 1

57. The value of innerhtml is the value of the form element, for example, <p id = "para"> "How are <em> You </em>"

</P>, the value of innerhtml is: how are <em> You </em>

2. 58. The value of innertext is the same as the above, but it does not display the <em> mark.

59. contenteditable: You can set whether the element can be modified, and iscontenteditable returns whether the element can be modified.

60. isdisabled: determines whether it is a forbidden region. Disabled: sets a forbidden region.

61. length gets the length and returns an integer value.

62. addbehavior () is an external function file called by JS. Its extension is. HTC.

63. Window. Focus () before all windows.

64. Blur () indicates losing focus. Opposite to focus.

65. Select () indicates that the element is selected.

66. Prevent users from entering text in the text box:

67. Retrieve the number of elements that appear on the page: Document. All. Tags ("Div (or other HTML tags)"). Length

68. JS is divided into two types of form output: module outputs and non-module outputs. Window. showmodaldialog (), window. showmodeless ()

 

69. Text settings in the text bar: window. Status = 'text

', Default text settings in the shape bar: window. defaultstatus = 'text .';

70. Add to favorites: External. AddFavorite ("http://www.dannyg.com";, "jaskdlf

");

71. js does not perform any operation when it encounters a script error: window. onerror = donothing;

Syntax for specifying the error handle: window. onerror = handleerror;

72. js specifies the parent window of the window currently opened: window. opener. Multiple continuation of opener. opener... is supported.

73. Self in. js refers to the current window.

74. js content bar shows content: window. Status = "content"

75. Top in JS refers to the top-level framework in the framework set.

76. Close the current window in JS: window. Close ();

If (confirm ("Are you sure? ") {Alert (" OK

");} Else {alert (" not OK ");}

Window redirection in 78. JS: window. navigate ("http://www.sina.com.cn ";);

79. js print: window. Print ()

Window. Prompt ("message", "defaultreply ");

Window scroll bar in 81. JS: window. Scroll (x, y)

82. JS: window. scrollby

Set the interval in 83. JS: setinterval ("expr

", Msecdelay) or setinterval (funcref, msecdelay) or setTimeout

The module metadata in 84. JS is displayed in ie4, but not in NN: showmodaldialog ("url

"[, Arguments] [, features]);

Handle used before exit in 85. JS: function verifyclose () {event. returnvalue = "We

Really like you and hope you will stay longer .";}}

Window. = verifyclose;

86. file handle used when the form is called for the first time: onload ()

87. file handle called when the form is closed: onUnload ()

88. Properties of window. Location:

Protocol (HTTP :), hostname (www.example.com), Port (80), 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 () refresh the current page.

90. window. history. back () returns the previous page, window. history. forward () returns the next page, window. history. go (return the page number, or use the accessed URL)

 

91.doc ument. Write () output without line feed, document. writeln () line feed output

92.doc ument. Body. nowrap = true; prevents link text from being broken.

93. variable name. charat (nth digit), which is the nth character of the variable.

94. "ABC". charcodeat (NTH), returns the ASCII value of the nth character.

95. String connection: String. Concat (string2), or use = to connect

96. Variable. indexof ("character", starting position), returns the first occurrence location (starts from 0)

97. String. lastindexof (searchstring [, startindex.

98. String. Match (regexpression) to determine whether the character matches.

99. String. Replace (regexpression, replacestring) to replace the existing string.

100. String. Split (separator) returns an array storage value.

101. String. substr (start [, length]) takes the string from the nth digit to the specified length.

102. String. tolowercase () converts all strings to lowercase.

103. String. touppercase () converts all characters to uppercase.

104. parseint (string [, Radix (representing hexadecimal)]) is forcibly converted to an integer.

105. parsefloat (string [, Radix]) is forcibly converted to floating point type.

106. isnan (variable): test whether it is Numeric.

107. Define the key word of a constant: const, and the key word of a variable: VaR

 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.