Home  >  Article  >  Web Front-end  >  More than 100 practical compilations of javascript functions and basic writing methods_javascript skills

More than 100 practical compilations of javascript functions and basic writing methods_javascript skills

WBOY
WBOYOriginal
2016-05-16 17:43:47921browse

1.document.write(""); is the output statement
2. The comment in JS is //
3. The traditional HTML document sequence 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.getElementById("The name of the element in the form ID number").name (or value)
6. A lowercase to uppercase JS: document.getElementById("output").value = document.getElementById("input").value.toUpperCase();
7. Value types in JS: String, Number, Boolean, Null, Object, Function
8. Convert character type to numerical type in JS: parseInt(), parseFloat()
9. Convert numbers into characters: ("" variable)
10. The length of a string in JS is: (length)
11. Characters in JS are connected using numbers.
12.JS The comparison operators in are: == equal to, != not equal to, >, >=, <.>13. To declare variables in JS, use: var to declare
14. Judgment statements in JS Structure: if(condition){}else{}
15. Loop structure in JS: for([initial expression];[condition];[upadte expression]) {inside loop}
16. Loop aborted The command is: break
17. Function definition in JS: function functionName([parameter],...){statement[s]}
18. When multiple forms appear in the 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. Status Column settings: window.status="Character";

21. Pop-up prompt message: window.alert("Character");
22. Pop-up confirmation box: window.confirm();
23. Pop up the input prompt box: window.prompt();
24. Specify the location of the currently displayed link: window.location.href="URL"
25. Get the number of all forms in the form: document.forms.length
26. Close the document’s output stream: document.close();
27. String append connector: =
28. Create a document element: document.createElement(), document.createTextNode()
29. Method to get the element: document.getElementById()
30. Set the value of all text members in the form to empty:
var form = window.document.forms[ 0]
for (var i = 0; i
49. Quote a file-style JS:

51. When there are both hyperlinks and ONCLICK events, the old version of the browser will redirect to a.html, otherwise it will redirect to b.html. Example: dfsadf

52.JS The built-in objects are: Array, Boolean, Date, Error, EvalError, Function, Math, Number, Object, RangeError, ReferenceError, RegExp, String, SyntaxError, TypeError, URIError
53. Line break in JS: n
54. Window full screen size:

55. all in JS represents all elements below it

56. Focus order in JS: document.getElementByid("Form Element").tabIndex = 1 57.The value of innerHTML is the value of the form element: such as "how are

you

"<script>function fullScreen(){ this.moveTo(0,0);this.outerWidth=screen.availWidth;this.outerHeight=screen.availHeight;}window.maximize=fullScreen;</script>, then the value of innerHTML is: how are you
58. The value of innerTEXT is the same as above, except that the tag will not be displayed.
59.contentEditable can Set whether the element can be modified, isContentEditable returns the status of whether it can be modified.
60.isDisabled determines whether it is a prohibited state. disabled sets the prohibited state
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() puts the current window in front of all windows.
64.blur() means losing focus. With FOCUS () on the contrary.
65.select() means that the element is selected.
66. Prevent the user from entering text in the text box: onfocus="this.blur()"
67. Remove the element in The number of occurrences in the page: document.all.tags("div (or other HTML tags)").length
68. There are two types of form output in JS: modal and non-modal.window.showModaldialog (), window.showModeless()
69. Status bar text setting: window.status='text', default status bar text setting: window.defaultStatus = 'text.';

70 .Add to favorites: external.AddFavorite("http://www.google.com","Google");
71. Do nothing when encountering a script error in JS: window.onerror = doNothing; The syntax for specifying an error handle is: window.onerror = handleError;
In 72.JS, specify the parent window of the currently opened window: window.opener, which supports multiple continuations of opener.opener....
In 73.JS The self refers to the current window
74. The status bar display content in JS: window.status="content"
75. The top in JS refers to the top-most frame in the frame set
76. Close the current window in JS: window.close();
77. Ask whether to confirm the box in JS: if(confirm("Are you sure?")){alert("ok");}else{alert ("Not Ok");}
78.Window redirection in JS: window.navigate("http://www.google.com");
79.Print in JS: window.print ()
Prompt input box in 80.JS: window.prompt("message","defaultReply");
Window scroll bar in 81.JS: window.scroll(x,y)
82.Scroll the window to the position in JS: window.scrollby
83.Set the time interval in JS: setInterval("expr",msecDelay) or setInterval(funcRef,msecDelay) or setTimeout
84.Module in JS The state is displayed in IE4, but not in NN: showModalDialog("URL"[,arguments][,features]);
85. The handle used before exiting in JS: function verifyClose(){event.returnValue=" we really like you and hope you will stay longer.";}} window.onbeforeunload=verifyClose;
86. The file handle used when the form is called for the first time: onload()
87. When the form File handle called when closing: onunload()
Properties of 88.window.location: protocol(http:),hostname(www.example.com),port(80),host(www.example.com:80 ), pathname("/a/a.html"), hash("#giantGizmo", refers to jumping to the corresponding anchor), href (all information)
89.window.location.reload() refresh Current page.
89-1.parent.location.reload() refreshes the parent object (for frames)
89-2.opener.location.reload() refreshes the parent window object (for single-open windows)
89-3.top.location.reload() refreshes the top object (for multiple windows)

90.window.history.back() returns to the previous page, window.history.forward () Return to the next page, window.history.go (return to the page, you can also use the visited URL)
91.document.write() output without line breaks, document.writeln() line break output
92.document.body.noWrap=true; Prevent link text from wrapping.
93.Variable name.charAt(number), take the character of the variable.
94."abc" .charCodeAt(number), returns the ASCii code value of which character.
95. String connection: string.concat(string2), or use = to connect
96. Variable.indexOf("Character ", starting position), returns the position of the first occurrence (calculated from 0)
97.string.lastIndexOf(searchString[,startIndex]) the position of the last occurrence.
98.string.match( regExpression), determine whether the characters match.
99.string.replace(regExpression,replaceString) replaces the existing string.
100.string.split (separator) returns an array storage value.
101. string.substr(start[,length]) takes the string from the digit to the specified length.
102.string.toLowerCase() makes the string all lowercase.
103.string.toUpperCase() Make all characters uppercase.
104.parseInt(string[,radix (representing base)]) is forced to be converted to an integer type.
105.parseFloat(string[,radix]) is forced to be converted to a floating point type .
106.isNaN (variable): Test whether it is a numeric type.
107. Keywords for defining constants: const, keywords for defining variables: var

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn