1, the use of prompt
<%@ Page language="C #"autoeventwireup="true"codefile="Default.aspx.cs"inherits="_default"%><! DOCTYPE html>"http://www.w3.org/1999/xhtml">"Server"><meta http-equiv="Content-type"Content="text/html; Charset=utf-8"/> <title></title>"Form1"runat="Server"> <div> <asp:label id="Label1"runat="Server"text="Label"></asp:Label> <asp:button id="Button1"runat="Server"text="Button"/> </div> </form></body>document.getElementById ("Button1"). onclick = function ()//Button1 Click events { varA = prompt ("Please enter the content");//accept the contents of the prompt value to adocument.getElementById ("Label1"). InnerHTML = A;//assign a value to Label1 return false;//prevents page refreshes. Without this, the page will go back to what it was like when the page was first loaded. }</script>View Code
2, JS in the combination of digital and text output results
<script>document.getElementById ("Button1"). onclick = function ()//Button1 Click events { varA ="Ten"; varb = -; varc = -; Alert (A+ B + c);//back to 102030Alert (b + C + a);//5010Alert (b + A + c);//201030Alert (parseint (a) + B);//Output 30, note the parseint () methodAlert (b.tostring () +a);//OutputAlert (b +""+C);//output 2030, pay attention to the middle "". }View Code
3, JS guarantee text box only number (IsNaN ())
<%@ Page language="C #"autoeventwireup="true"codefile="Default.aspx.cs"inherits="_default"%><! DOCTYPE html>"http://www.w3.org/1999/xhtml">"Server"><meta http-equiv="Content-type"Content="text/html; Charset=utf-8"/> <title></title>"Form1"runat="Server"> <div> <asp:label id="Label1"runat="Server"text="Label"></asp:Label> <asp:button id="Button1"runat="Server"text="Button"/> <asp:textbox id="TextBox1"runat="Server"></asp:TextBox> </div> </form></body>document.getElementById ("TextBox1"). onkeyup =function () {if(IsNaN ( This. Value))//"Not a pure number?" True means "not a number", false means a number { This. Value = This. VALUE.SUBSTR (0, This. value.length-1);//the value of the text box retains only the number part } }</script>View Code
4, JS under for (I in "AAA") {alert (i);}
<%@ Page language="C #"autoeventwireup="true"codefile="Default.aspx.cs"inherits="_default"%><! DOCTYPE html>"http://www.w3.org/1999/xhtml">"Server"><meta http-equiv="Content-type"Content="text/html; Charset=utf-8"/> <title></title>"Form1"runat="Server"> <div> <asp:label id="Label1"runat="Server"text="Label"></asp:Label> <asp:button id="Button1"runat="Server"text="Button"/> <asp:textbox id="TextBox1"runat="Server"></asp:TextBox> </div> </form></body>document.getElementById ("Button1"). onclick =function () {varA ="ASDFG"; for(Iincha) {alert (i);//pops up all index numbers of a 0,1,2,3,4 } }</script>View Code
5, JS under the establishment of the array, add and take value var al = new Array (); Number of arrays with length
<script> document.getElementById (function () { varNew Array (); // create an array of JS, equivalent to a set of C #, unlimited length, unlimited data types Al[0] = 1; // adding data to an array AL[1] = "2"; // adding data to an array var b = al[1]; // take one of the values in the array }</script>
View Code
6, JS functions function () {}
<script> functions aaa (A, B)//AAA is the function name A, B is the parameter to be added as required, do not limit the data type of AB alert (// EXECUTE statement // according to the specific situation to see if there is a need to Rerurn, there is on the written, no thanks. } function bbbb ( )// functions with no parameters bbb { Execute statement }</script>
View Code
7.DOM Get element mode
<script> var a = document.getElementById ("id value"); // get an element by ID, get an element var b = Document.getelementsbyclassname ("class value"); // Gets a bunch of elements by class, returns a collection var C = document.getElementsByTagName ("element name"); // get a bunch of elements by element name, return a collection // What is the element name? such as div img span input, note that the button is not var d = document.getelementsbyname ("Name value" ); // obtained by name, gets a bunch of elements, returns a collection, name is the used for the server. // After the two in practice is not practical, the two implementation of the effect, the first two can be achieved, and more prepared </script>
View Code
8, window.open () of the parameters
<script>window.open ("Page.html", "_blank", "height=100, width=400, Top=0, left=0, Toolbar=no, Menubar=no, Scrollbars=no, Resizable=no, Location=no, Status=no ")//the sentence is written in a line of code //parameter explanation: //window.open the command that pops up the new window; //the filename of the ' page.html ' pop-up window; //' _blank ' popup D to the new empty window //height=100 window height; //width=400 window width; //the pixel value of the Top=0 window from the top of the screen; //the pixel value of the left=0 window from the left side of the screen; //Toolbar=no whether the toolbar is displayed, yes is displayed; //Menubar,scrollbars represents the menu bar and scroll bar. //resizable=no Whether the window size is allowed to change, yes is allowed; //Location=no Whether the address bar is displayed, yes is allowed; //Status=no Whether the information in the status bar is displayed (usually the file is already open), yes is allowed;</script>View Code
9, Window.history
<script> window.history.back (); // back to an interface Window.history.forward (); // Move on to an interface Window.history.go (n); // n is of type int, 1 means backward one interface, 1 means moving forward one interface </script>
View Code
10, Window.location.href
<script> var a = window.location.href; Gets the address of the current page window.location.href ("http://www.baidu.com"); only on this page to reopen the Baidu page, if you want to open a new page, you must use window.open (); </script
View Code
Finish!!
Prompt IsNaN Array function DOM window.open/close/location/history