C#-webform-js Knowledge: Basic part, BOM part, Dom part, JS event

Source: Internet
Author: User
Tags mathematical functions

---restore content starts---

First, the basic part:

1. What is JavaScript?

is a scripting language , is a weak type (language grammar is very casual), C # is strongly typed (language syntax is very strict) (Li brainstorming Lxc)

Advantages: JS execution Speed is fast

2. What is the relationship between JS and Java? It doesn't matter.

3, JS can do what things?

Ability to control browser BOM

Control Element DOM

JS can't do what?

Cannot manipulate files (read, create, delete)

Cannot Access database directly

Extension: node. JS-a development platform through which you can develop a regular web service side, a very lightweight running environment

Jquery.js-Front frame

4, JS is a process-oriented language also some people say JS has object-oriented, but he is not a purely object-oriented language

Second, the common dialog box

Alert ("string")-warning dialog box, popup string content

Confirm ()-Confirmation dialog box

Prompt ("", "")-Input dialog box

Third, JavaScript syntax

1. Basic Data type

String, Decimal, Integer, Date time, Boolean type

2. Variables: Only one type var (universal variable)

3, data type conversion string type highest precedence

<script type= "Text/javascript" >var a=10;var b= "ten"; var C=20;alert (A + b); alert (b + a); alert (A + C + B); alert ( A + C + parseint (b));</script>

4, text box digital verification (Li Brainstorming Lxc)

<script>    var txt1 = document.getElementById ("TextBox1");        Trigger    Txt1.onkeyup = function () {                if (IsNaN (This.value)) {            this.value = this.value.substr (0) when the key is lifted this.value.length-1);        }    };    Txt1.onchange = function () {};//triggers when loss    of focus//txt1.onkeydown = function () {};//button is triggered when pressed </script>

5. Operators with C #

6. Statements

Branch Statement If...else If...else

Loop statement for (int i=0;i<=k;i++) {}

7. Arrays

Similar to collections in C #, not fixed-length, non-fixed type

Assignment: Assign a value directly with an index without add

Empty: With a foreach loop, array[i]=null;

Quantity: Length;

8. Functions

No parameter no return, no return, no parameter, no return, no parameter returned type, direct return

Recursion: Self Tune Yourself

  

Iv. BOM Operation

1. window.open-Open Page

window.open ("page path", "Whether new form", "new form format");

New form format: width, height new form wide height left, top new form position

Open a new form is not able to change the contents of the Address bar

2, Opener: Open the source window of the current window, if the current window is the first time the browser opened, then opener is null;

Window.close ();

Window.opener.location.href= "";

Reopen the previous form and guide the URL, if it is a previous level URL, there is a refresh effect

: Click Button2 to close Button1 open form

3, window.navigate ("url"), jump to the target page

Window.moveto (x, y); Move page to coordinates

Window.resizeto (width,height); Change page length and width

Window.scrollto (x, y); scroll page to where

4, Window.history.back (); page back

Window.history.forward (); page forward

Window.history.go (n); page jump to

5, window.location.href= ""; reposition

alert (window.lacation.href); Popup Current URL

V. Operation of the DOM

1. Find the Element

Follow the ID to find document.getElementById ("");

An object was found.

Follow class to find Document.getelementsbyclassname ("");

An array was found.

Follow the name to find Document.getelementsbyname ("");

An array was found.

Search for document.getElementsByTagName ("") according to the element name;

An array was found.

2, the contents of the Operation element

InnerHTML

-Displays the effect of the element tag code after rendering it (such as hyperlink form)

-Remove all the code and content

InnerText

-no content is rendered, nothing is written and what is directly output

-When the value is taken, he will only take out the text messages that can be seen, not the HTML code.

Value

-12 form Elements queen, other elements have no right to use them

-The content operation of all form elements can be resolved not by value, and some elements require the above two mates, such as: Option,radio

3, the operation of the contents of the property (crud-additions and deletions)

Add, Modify properties: SetAttribute (property name, property value)

Lookup attribute: getattribute ("Property name")

Delete attribute: RemoveAttribute ("Property name")

4. Style of Operation elements (add and modify)-all style actions are added or changed inside the element code, with the highest priority

This.style.xxx

Get the immediate style:

This.offsetwidth/offsetheight/offsettop/offsetleft

5. Operating elements

Note: Line wrapping is also defaulted to an element

this.nextsibling; -Next sibling element of the current element

this.previoussibling; -Previous sibling element of the current element

This.parentnode; -The parent element of the current element

This.childnodes; -All of the elements of the current element

Create a new element

1, createelement 2, AppendChild ()

---restore content ends---

First, the basic part:

1. What is JavaScript?

is a scripting language , is a weak type (language grammar is very casual), C # is strongly typed (language syntax is very strict) (Li brainstorming Lxc)

Advantages: JS execution Speed is fast

2. What is the relationship between JS and Java? It doesn't matter.

3, JS can do what things?

Ability to control browser BOM

Control Element DOM

JS can't do what?

Cannot manipulate files (read, create, delete)

Cannot Access database directly

Extension: node. JS-a development platform through which you can develop a regular web service side, a very lightweight running environment

Jquery.js-Front frame

4, JS is a process-oriented language also some people say JS has object-oriented, but he is not a purely object-oriented language

Second, the common dialog box

Alert ("string")-warning dialog box, popup string content

Confirm ()-Confirmation dialog box

Prompt ("", "")-Input dialog box

Third, JavaScript syntax

1. Basic Data type

String, Decimal, Integer, Date time, Boolean type

2. Variables: Only one type var (universal variable)

3, data type conversion string type highest precedence

<script type= "Text/javascript" >var a=10;var b= "ten"; var C=20;alert (A + b); alert (b + a); alert (A + C + B); alert ( A + C + parseint (b));</script>

4. Text box Digital Verification

<script>    var txt1 = document.getElementById ("TextBox1");        Trigger    Txt1.onkeyup = function () {                if (IsNaN (This.value)) {            this.value = this.value.substr (0) when the key is lifted this.value.length-1);        }    };    Txt1.onchange = function () {};//triggers when loss    of focus//txt1.onkeydown = function () {};//button is triggered when pressed </script>

5. Operators with C #

6. Statements

Branch Statement If...else If...else

Loop statement for (int i=0;i<=k;i++) {}

7. Arrays

Similar to collections in C #, not fixed-length, non-fixed type

Assignment: Assign a value directly with an index without add

Empty: With a foreach loop, array[i]=null;

Quantity: Length;

8. Functions

No parameter no return, no return, no parameter, no return, no parameter returned type, direct return

Recursion: Self Tune Yourself

  

Iv. BOM Operation

1. window.open-Open Page

window.open ("page path", "Whether new form", "new form format");

New form format: width, height new form wide height left, top new form position

Open a new form is not able to change the contents of the Address bar

2, Opener: Open the source window of the current window, if the current window is the first time the browser opened, then opener is null;

Window.close ();

Window.opener.location.href= "";

Reopen the previous form and guide the URL, if it is a previous level URL, there is a refresh effect

: Click Button2 to close Button1 open form

3, window.navigate ("url"), jump to the target page

Window.moveto (x, y); Move page to coordinates

Window.resizeto (width,height); Change page length and width

Window.scrollto (x, y); scroll page to where

4, Window.history.back (); page back

Window.history.forward (); page forward

Window.history.go (n); page jump to

5, window.location.href= ""; reposition

alert (window.lacation.href); Popup Current URL

V. Operation of the DOM

1. Find the Element

Follow the ID to find document.getElementById ("");

An object was found.

Follow class to find Document.getelementsbyclassname ("");

An array was found.

Follow the name to find Document.getelementsbyname ("");

An array was found.

Search for document.getElementsByTagName ("") according to the element name;

An array was found.

2, the contents of the Operation element

InnerHTML

-Displays the effect of the element tag code rendering (such as hyperlinks)

-All the content and code will be removed.

InnerText

-Do not make any rendering of the content, what is written directly to output what (the hyperlink code is displayed)

-When the value is taken, it will only take out the text information that can be seen, and will not fetch the HTML code.

Value

-12 form Elements queen, other elements have no right to use them

-The content operation of all form elements can be resolved not by value, and some elements require the above two mates, such as Option,radio

3, the operation of the contents of the property (increase and deletion of check)

Add, modify SetAttribute ("attribute name", "attribute value");

Find get GetAttribute ("attribute name");

Delete removeattribute ("attribute name");

4, the operation of the elements of the style (increase and deletion of check)

This.style.xxx

5. Operating elements

Find the previous and next sibling levels

This.nextsibling

This.previoussibling

Find parent Element

This.parentnode

Find all child elements

This.childnodes

Create a new element

var odiv = document.createelement ("div");

document.getElementById ("Boss"). AppendChild (Odiv);

var odiv = "<div class= ' Div1 ' ></div>";

document.getElementById ("Boss"). InnerHTML + = Odiv;

remove element

This.remove ();

Six, JS events

1, toUpperCase ()-Convert to uppercase

2, toLowerCase ()-Convert to lowercase

3, substring (x, y)-intercept string, intercept from index x to index Y

4, substr (x, y)-intercept string, start at index x, intercept y length

5. Split (' x ')-string segmentation with X as tag

6, IndexOf ("string")-Returns the first index value of a string

7, Trim ()-Remove the space before and after

8, var d = new Date (); -Get current time

var d = new Date (2000,3,3); -Define Time

Alert (D.getfullyear ()); -Get the year in time

9. Mathematical functions with C #

10. Common events:

OnClick-click event

OnDblClick-Double-click event

Onmouseover,onmouseout-mouse hover, departure time

Onfocus-event when getting focus

Onblur-Event when the focus is lost

OnKeyUp-event when the key bounces

11, This.form.submit-form to submit

C#-webform-js Knowledge: Basic part, BOM part, Dom part, JS event

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.