It workers 2022-06-23 17:39:31 阅读数:334
Summary Javascript Practical statements , For beginners to learn quickly , I believe it will be of great help to you .
Remember a little : Better believe than have no book . Learning focuses on learning methods , The following is for reference only !
1. document.write( " "); Output statement
2.JS The note in is //
3. Conventional HTML The document order is :document- >html- >(head,body)
4. In a browser window DOM The order is :window- >(navigator,screen,history,location,document)
5. Get the names and values of the elements in the form :document.getElementById( " Of the elements in the form ID ").name( or value)
6. To lower case JS: document.getElementById( "output ").value = document.getElementById( "input ").value.toUpperCase();
7.JS The value type in :String,Number,Boolean,Null,Object,Function
8.JS Convert the character type in to numeric type :parseInt(),parseFloat()
9.JS Convert numbers in to characters :( " " Variable )
10.JS The length of the string in is :(length)
11.JS The characters in are connected with characters .
12.JS The comparison operators in are :== be equal to ,!= It's not equal to , >, >=, <. <=
13.JS The variable is declared in the :var To make a statement
14.JS The structure of the decision sentence in :if(condition){}else{}
15.JS The circular structure in :for([initial expression];[condition];[upadte expression]) {inside loop}
16. The command to abort the loop is :break
17.JS Function definition in :function functionName([parameter],…){statement[s]}
18. When more than one appears in the file form On form . It can be used document.forms[0],document.forms[1] Instead of .
19. window : open windows window.open(), Close a window :window.close(), The window itself :self
20. shape B Column settings :window.status= " character ";
21. Pop up message :window.alert( " character ");
22. eject _ Recognition frame :window.confirm();
23. Pop up the input prompt box :window.prompt();
24. Specifies the location of the currently displayed link :window.location.href= "URL "
25. Take out 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. How to get elements :document.getElementById()
30. Set the value of all text type members in the form to null :
var form = window.document.forms[0]
for (var i = 0; i <form.elements.length;i ){
if (form.elements.type == "text "){
form.elements.value = " ";
}
}
31. The check button is on JS To decide whether to select :document.forms[0].checkThis.checked (checked Property represents whether to select return TRUE or FALSE)
32. Radio button group ( The name of the radio button must be the same ): Take the length of the radio button group document.forms[0].groupName.length
33. The radio button group is also used to determine whether it is selected or not checked.
34. The value of the drop-down list box :document.forms[0].selectName.options[n].value (n Sometimes use the name of the drop-down list box and add .selectedIndex Come on _ Set the selected value )
35. Definition of string :var myString = new String( "This is lightsword ");
36. String to uppercase :string.toUpperCase(); String to lowercase :string.toLowerCase();
37. Return string 2 In string 1 Where in :String1.indexOf( "String2 ")!=-1 It means that we didn't find .
38. Take a character at the specified position in the string :StringA.charAt(9);
39. Take out the substring of the specified start and end point in the string :stringA.substring(2,6);
40. Mathematical functions :Math.PI( Return the PI ),Math.SQRT2( Back to the prescription ),Math.max(value1,value2) Returns the most significant value of two numbers ,Math.pow(value1,10) return
value1 To the tenth power of ,Math.round(value1) Round function ,Math.floor(Math.random()*(n 1)) return S Number of machines
41. Define a date type variable :var today = new Date();
42. Date function list :dateObj.getTime() Get time ,dateObj.getYear() Get the year ,dateObj.getFullYear() Get a four digit year ,dateObj.getMonth() have to
To month ,dateObj.getDate() Day by day ,dateObj.getDay() Get a few dates ,dateObj.getHours() Get hours ,dateObj.getMinutes() obtain
branch ,dateObj.getSeconds() Get seconds ,dateObj.setTime(value) Setup time ,dateObj.setYear(val) Set year ,dateObj.setMonth(val) Set up
month ,dateObj.setDate(val) Set day ,dateObj.setDay(val) Set the day of the week ,dateObj.setHours Set hours ,dateObj.setMinutes(val) Set up
branch ,dateObj.setSeconds(val) Set seconds [ pay attention to : This date and time is from 0 Starting meter ]
43.FRAME Is represented by : [window.]frames[n].ObjFuncVarName,frames[ "frameName "].ObjFuncVarName,frameName.ObjFuncVarName
44.parent On behalf of the father's object ,top Represents the top object
45. The parent window that opens the child window is :opener
46. Represents the current location to which it belongs :this
47. When called in hyperlinks JS Function :(javascript :) To start with a function name
48. Don't execute this in old browsers JS: <!– //– >
49. Reference to a file like JS: <script type= "text/javascript " src= "aaa.js " > </script >
50. Specifies that... Is displayed in browsers that do not support scripts HTML: <noscript > </noscript >
51. When hyperchains and onCLICK Events are sometimes , The old version of the browser turned to a.html, Otherwise to b.html. example : <a href= "a.html " >dfsadf </a >
52.JS Ran ǘ rhyme
Yes :Array,Boolean,Date,Error,EvalError,Function,Math,Number, Object,RangeError,ReferenceError,RegExp,String,SyntaxError, TypeErr
or,URIError
53.JS Line breaks in : n
54. Window full screen size : <script >function fullScreen(){ this.moveTo
(0,0); this.outerWidth=screen.availWidth;this.outerHeight=screen.availHeight;} window.maximize=fullScreen; </script >
55.JS Medium all Representing all the elements below it
56.JS The order of focus in :document.getElementByid( " Form Elements ").tabIndex = 1
57.innerHTML The value of is the value of the form element : Such as <p id= "para " > "how are <em >you </em > " </p >, be innerHTML The value is :how are <em >you </em>
58.innerTEXT The value is the same as above , It's just that you can't <em > This kind of thinking allows the environment Falcon .
59.contentEditable Can set whether the element can be modified ,isContentEditable Returns whether the status can be modified B.
60.isDisabled Determine whether it is a prohibition B.disabled Set the forbidden status B
61.length Get the length , Returns an integer value
62.addBehavior() It's a kind of JS The external function file called has an extension of .htc
63.window.focus() Make the current window before all windows .
64.blur() Losing focus . And FOCUS() contrary .
65.select() The element is selected B.
66. Prevent users from entering text into the text box :
67. The number of elements that appear in the page :document.all.tags( "div( Or other HTML I'm sorry ) ").length
68.JS There are two kinds of form output : model B And nonmodular B.window.showModaldialog(),window.showModeless()
69. shape B Column text settings :window.status= ' written words ', Default state B Column text settings :window.defaultStatus = ' written words . ';
70. add to favorites :external.AddFavorite( "http://www.dannyg.com ";, "jaskdlf ");
71.JS Do not do any operation when encountering script error in :window.onerror = doNothing; The syntax for specifying an error handle is :window.onerror = handleError;
72.JS Specifies the parent window of the currently open window :window.opener, Support opener.opener… More than that, go on .
73.JS Medium self Refers to the current window
74.JS Medium shape B The column shows hot :window.status= " heat "
75.JS Medium top Refers to the top-level framework in a frameset
76.JS Close the current window in the :window.close();
77.JS Whether or not _ Recognition box :if(confirm( "Are you sure? ")){alert( "ok ");}else{alert( "Not Ok ");}
78.JS Window redirection in :window.navigate( "http://www.aseoe.com";);
79.JS Print in :window.print()
80.JS The prompt input box in the :window.prompt( "message ", "defaultReply ");
81.JS Window scroll bar in :window.scroll(x,y)
82.JS Scroll to the location of the window in the :window.scrollby
83.JS Set the time interval in :setInterval( "expr ",msecDelay) or setInterval(funcRef,msecDelay) or setTimeout
84.JS Module in B Displayed in the IE4 That's ok , stay NN Not in the middle :showModalDialog( "URL "[,arguments][,features]);
85.JS Handle used before exiting from the :function verifyClose() {event.returnValue= "we really like you and hope you will stay longer. ";}}
window.=verifyClose;
86. The file handle used when the form is first called :onload()
87. File handle called when the form is closed :onunload()
88.window.location Properties of : protocol(http:),hostname(www.example.com),port(80), host(www.example.com:80),pathname
( "/a/a.html "),hash( "#giantGizmo ", Jump to the corresponding anchor ),href( All the information )
89.window.location.reload() Refresh current page .
90.window.history.back() Back to previous page ,window.history.forward() Back to next page ,window.history.go( Back to page , You can also use the URL)
91.document.write() Output that doesn't wrap ,document.writeln() Line feed output
92.document.body.noWrap=true; Prevent link text from breaking .
93. Variable name .charAt( Number one ), Take the character of the first digit of the variable .
94. "abc ".charCodeAt( Number one ), Returns the number of characters ASCii Code value .
95. String connection :string.concat(string2), Or use = Connect
96. Variable .indexOf( " character ", The starting position ), Go back to where it first appeared ( from 0 Start calculating )
97.string.lastIndexOf(searchString[,startIndex]) The last location .
98.string.match(regExpression), Determine whether the characters match .
99.string.replace(regExpression,replaceString) Replace existing string .
100.string.split( Separator ) Returns an array of stored values .
101.string.substr(start[,length]) Take the string from bit to length .
102.string.toLowerCase() Make all strings lowercase .
103.string.toUpperCase() Make all characters uppercase .
104.parseInt(string[,radix( Represents the base )]) Cast to integer .
105.parseFloat(string[,radix]) Cast to floating point .
106.isNaN( Variable ): Is the test numeric .
107. The key word of defining constant :const, The key to the definition of a word is :var
版权声明:本文为[It workers]所创,转载请带上原文链接,感谢。 https://qdmana.com/2022/01/202201061942102534.html