JS Basic Knowledge Point Review

Source: Internet
Author: User

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

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.