JavaScript basic knowledge

xiaoxiao2021-03-19  230

Every item is a tip skill in JS, but it is very practical!

1.Document.write (""); output statement

2. JS in JS is //

3. Traditional HTML document order is: Document-> HTML -> (Head, Body)

4. The DOM order in a browser window is: Window -> (Navigator, Screen, History, Location, Document)

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

6. A lowercase. JS: Document.getElementByid ("OUTPUT"). Value = Document.GtelementByid ("i

NPUT "). Value.touppercase ();

7. Value in JS Type: String, Number, Boolean, Null, Object, Function

8. The character type injs converted into a value: parseint (), PARSEFLOAT ()

Digital conversion in 9.js transition into a word: (" variable)

10. The string length injs is: (Length)

11. The characters in JS are connected to characters.

12. The comparison operator injs is: == equal to,! = Not equal,>,> =, <. <=

13. JS Declared Variable Use: VAR to make a declaration

14. Judgment statement structure injs: if (condition) {} else {}

15. Circular structure in JS: for ([Initial Expression]; [Condition]; [Upadte Expression]) {inside loop}

16. The loop suspension is: BREAK

17. The function definition in JS: function functionName ([parameter], ...)

18. When multiple FORM forms appear in the file. You can replace it with Document.Forms [0], Document.Forms [1].

19. Window: Open Window.Open (), close a window: window.close (), window itself: Self

20. Settings of the status bar: window.status = "characters";

21. Pop-up prompt information: Window.alert ("character");

22. Popup confirmation box: window.confirm ();

23. Pop-up input prompt box: window.prompt ();

24. Specify the location of the current display link: window.location.href = "url"

25. Remove all forms in the form: Document.Forms.Length

26. Close the output stream of the document: Document.close ();

27. String appended connection: =

28. Create a document element: Document.createElement (), Document.createTextNode ()

29. Method for obtaining an element: Document.GtelementByid ()

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

Var form = window.document.forms [0]

For (var i = 0; i I I == "text") {

Form.efficient.value = ""

}

}

31. The check button determines in JS whether it is selected: Document.Forms [0] .Checkthis.checked (Checked property represents whether it is selected

Return true or false)

32. Single selection button group (the name of the radio button must be the same): Take the length of the single-selection button group Document.Forms [0] .Groupname.length

33. The radio button group determines whether it is checked or uses checked.34. The value of the drop-down list box: Document.Forms [0] .SelectionName.Options [n] .value (n Sometimes using the drop-down list box name plus .sel

EcTedIndex is determined to be selected)

35. Definition of a string: var myString = New String ("this is lightsword");

36. String strings to uppercase: string.touppercase (); string to turn down: string.tolowercase ();

37. Returns the string 2 The location appears in the string 1: string1.indexof ("string2")! = - 1 shows that it is not found.

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

39. Remove the substrings of the starting point and end point in the string: stringa.substring (2, 6);

40. Mathematical functions: Math.pi (return rounding rate), Math.SQRT2 (return to the beginning), Math.max (Value1, Value2) Returns the most in the two numbers

On the value, Math.Pow (Value1, 10) returns to Value1 ten times, Math.Round (Value1) rounded the function, Math.Floor (Math.ra

Ndom () * (n 1)) Returns the number of random

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

42. Date function list: dateobj.gettime () get time, Dateobj.Getyear () gets the year, Dateobj.Getfullyear () get

The four years old, Dateobj.getMonth () gets the month, dateobj.getdate () gets the date, DateObj.getday () gets the date, DAT

EOBJ.GETHOURS () gets the hour, Dateobj.getminutes () gets a division, Dateobj.getSeconds () gets second, Dateobj.Setti

ME (value) Setting time, Dateobj.Setyear (VAL) Set the year, Dateobj.SetMonth (VAL) set the month, Dateobj.Setdate (VA

l) Setting the day, DateObj.setday (VAL) Set the day, DateObj.sethours Setup Hour, DateObj.Setminutes (VAL) settings,

DateObj.setseconds (VAL) Setting Second [Note: This date time starts from 0]

43. Frame expression: [WINDOW.] Frames [n] .objfuncvarname, frames ["framename"]. Objfuncvarn

AME, FRAMENAME.OBJFUNCVARNAME

44.Parent represents the father object, TOP represents the top object

45. The parent window of the open sub-window is: Opener

46. ​​Represents the current location: this

47. When calling the JS function in the hyperlink, use: (javascript :) to start after adding a number of functions

48. This JS is not implemented in the old browser:

49. Reference a file type JS:

50. Specify HTML displayed in the browser that does not support scripts:

51. When the ultra-chain and an onclick event are sometimes, the old version of the browser turns to A.html, otherwise steering B.html. Example: DFSADF

52.JS's built-in objects include: Array, Boolean, Date, Error, Evalerror, Function, Math, Number, Object, RangeError,

ReferenceError, Regexp, String, SyntaxError, Typeerror, Urierror

53. js 换 换: / n

54. Window full screen size:

55. All of the all of JS represents all the elements of the lower layer

56. Focus order in JS: Document.GetElementByid ("Form Element") .tabINDEX = 1

57.NNerhtml value is the value of the form element:

"How are you"

, The value of innerhtml is: how are you58.innerText value is the same, but does not display this tag.

59.ContenTedITable can set whether the element can be modified, and iscontentedTETETETETABLE returns the state of whether it can modify.

60.ISDISABLED Judging whether it is forbidden status. Disabled settings for disabling status

61.Length acquisition length, return to an integer value

62.Addbehavior () is an external function file of JS calls its extension .htc

63.Window.focus () makes the current window before all windows.

64.Blur () refers to the focus. Conversely with FOCUS ().

65. SELECT () means elements to select a state.

66. Prevent users from entering the text in the text box: οnfοcus = "this.blur ()"

67. Remove the number of elements appear in the page: Document.all.tags ("DIV (or other HTML tag)"). Length

68.JS is divided into two form output: modal and non-modular .Window.showModalDialog (), window.showmodeless ()

69. Settings of the status bar text: window.status = 'text', the default status bar text setting: window.defaultstatus = 'text.';

70. Add to Favorites: External.Addfavorite ("

http://www.dannyg.com "t;" jaskdlf ");

71. The script error does not do when you encounter a script error: window.onerror = donothing; specifies the syntax of the error handle: Window.on

Error = HandleError;

72.JS specifies the parent window of the current open window: Window.opener, supports the multi-continuation of Opener.opener ...

73. The self refers to the current window.

74.JS in the status bar display content: window.status = "content"

75. TOP in JS refers to the top-level frame of the frameset

76.JS close the current window: window.close ();

77. JS proposes whether to confirm the box: IF ("Are you Sure?") ELSE {Alert ("not ok");}

78.And window redirection: window.navigate ("

http://www.sina.com.cn "t;);

79. Print in JS: Window.Print ()

The prompt input box in 80.js: Window.Prompt ("Message", "DefaultReply");

81. The window roller strips in JS: Window.Scroll (x, y)

82. The window in the 82.js is scrolled to the location: window.scrollby

83. Setting time interval in JS: SetInterval ("expr", msecdelay) or setInterval (funcref, msecdelay) or settimeou

t

The modal display in the 84.js is in IE4 line, not in NN: ShowModalDialog ("URL" [, arguments] [, features]);

85. Handle used before exiting: function verifyclose () {Event.ReturnValue = "We real like you and ho

PE you will stay longer. ";} }window.οnbefοreunlοad = verifyclose;

86. File handle used when the form is called: OnLoad ()

87. File handle called when the form is closed: onunload ()

88. Attribute of Window.Location: protocol (http :), hostname

Example.com), Port (80), Host (E

Xample.com:80), Pathname ("a/a.html"), hash("#giantgizmo ", refers to the corresponding anchor), HREF (all letters

interest)

89.Window.Location.Reload () refreshes the current page.

90.Window.history.back () Returns the previous page, Window.history.Forward () Returns Next, Window.history.go (Return

Sequence, you can also use the accessed URL)

91.Document.write () Unsharddline output, Document.writeln () wrap output

92. Document.body.nowrap = true; prevents link text folding.

93. Variable name .Charat (second), take the first few characters of this variable.

94. "ABC" .CHARCODEAT (Section 1), returns the ASCII code value of the first character.

95. String connection: string.concat (string2), or use = connection

96. Variable .indexof ("character", starting position), return the first position (starting from 0)

97.String.lastIndexof (SearchString [, StartIndex]) The last appearance.

98.String.match (regexpression), determine whether the characters match.

99.String.Replace (replacestring) Replaces the existing string.

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

101.String.substr (start [, length]) takes a string from the first few to the specified length.

102.String.tolowerCase () makes all strings to lowercase.

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

104.Parseint (String [, Radix)]) Force converted into integers.

105.Parsefloat (String [, RADIX]) is forcibly converted into floating point.

106.isnan: The test is a value type.

107. Define constants Keywords: const, define variable keywords: var

转载请注明原文地址:https://www.9cbs.com/read-130136.html

New Post(0)