JavaScript: Basic syntax: basically consistent with C # syntax, type conversion: var a= parseint (value): var b = parsefloat (value);
IsNaN (value): Determines whether it is a number, is return false is not return true;
Function method:
// has a return value: <script > var ccc = test1 (5,6); Alert (CCC); function Test1 (b) { var c = A +B; Renturn C;} </script>
// no return value <script > test1 (); function test1 () { alert ('Hello word');} </script>
JavaScript DOM:
Windows objects:
window.open () window.close () Window.opener window.setinterval ()/window.settimeout ();
Adjustment page: window.navigate ("url"); Window.moverto (x, y); Window.resizeto (Wid.hei); Window.scrollto (x, y);
window.open ();:
<input type="button" value=" pushbutton 1" id="btn1 "/>;
<script>varOBTN1 = document.getElementById ("BTN1"); Obtn1.onclick=function () {window.open ("default2.aspx","_blank","width=400 height=400 left="+ ((window.screen.width/2)- $)+"top=""+ ((WINDOW.SCREEN.HEIGHT/2) -200) +");//Window.screen.width is the width of the screen} varOBTN2 = document.getElementById ("btn2"); Obtn2.onclick=function () {a.close ();} Obtn1.onclick=function () {Window.scrollto (0, $);}//downward to 200. Equivalent to anchor Point//Close the parent window widow.opener.close ();</script>
Window.history object:
Window.history.back (); Window.history.forward (); Window.history.go (n); Put a positive number forward a page, put negative numbers back a page;
Window.location object:
window.location.href= "url"; Jump page and window.open (); But the browser won't block him, and the Open browser will block it; It also gets the address of the current page;
Window.document object:
Get object:
<script> document.getElementById ("ID") Document.getelementsbyclassname ("class") document.getelementsbyname ( "name") document.getelementsbytagname (" Mark ")</script>
Action Object Properties:
Add property: Object. SetAttribute ("name", "value");
Remove attribute: Object. removeattribute ("name");
Gets the property value: Object. getattribute ("name");
Manipulating Object content:
object. Innerhtml= ""/object. InnerText = "";
innerHTML will compile the code that is written in it, and the text will show you what you are writing and will not compile.
Common elements:
Remove content: Object. innerhtml= ""/inner. Text= ""
Get content: Object. InnerHTML
JS Basic Knowledge Point Review