JS strengthening summary

Source: Internet
Author: User

A) Review the way the JavaScript Foundation (1) functions are defined *>> Normal mode function Add (num1,num2) {...} >> constructor way var add = new Function ("Num1", "num2 "," return num1+num2 "); *>> anonymous/Nameless way var add = function (num1,num2) {function Body} (2) Window object is what in JS, window represents the entire browser window (3) Window object Common Properties, methods, event A) Properties > >document object: A place where content is displayed in a white area in the browser >>status object: status bar in Browser >>location: Browser address block, commonly used property href, indicating the URL path of the address block input >>history: Browser history block, it is saved by the browser has visited the page >>screen: Browser on the Screen object >>navigator: Browser-related information, You can send the client browser related information to the server, at this point, the server will know, should output what kind of information to the client to see ... B) method >>alert (): Output content as a warning box >>open (): Opens a new browser window >>close (): Closes an open browser window ... C) Event >>onload: When the page loads, the system calls >>onunload: The browser unloads the page, the entire browser is closed >>onbeforeunload: triggered when the browser unloads the page, the entire browser is not closed Note: Our two onunload and onbeforeunload are the events supported in the early browsers ... (4) How to locate a form, form element, get the value of a form element a) to locate a form there are two ways first: the table sole name, that is window.docment. The Name property value of the form second: can be the Forms property, the first form, subscript is 0, and so on, That is, window.docment.forms[0]b) Form element form. form element name, or Window.document.forms[0].username C) Gets the value of the form element Form elements. The Value property, which is Window.documenT.forms[0].username.value * II) DOM Common API Combat (1) What is a DOM D document: HTML or XML two, which today refers specifically to an HTML O (object) object, which is manipulated in the way an object is, for example: an object. method (); the object. Attribute M (model) model, any document, in the DOM's view, is a inverted tree model (2) DOM features Dom is a rule for manipulating HTML or XML, a set of rules that cross-platform (Window/linux), cross-language (Js,vbs,java ), across browsers (Ie,firefox). Only if you manipulate the DOM standard API, you can do it in any browser, with the same effect. Dom API, there are some execution effect may be in a browser is this effect, it may be in the B browser is the effect, it is normal that each browser does not do the same with JS execution in the DOM eye, all documents are composed of nodes (3) node type >> document node ( Document): There is only one >> element node (divelement) >> text node (divtextelement) >> attribute node (divattrelement) (4) Common API see < > < > getElementById () getelementsbyname () getElementsByTagName () HasChild Nodes () NodeName nodetype=1 element node/2 attribute node/3 text node NodeValue replacechild () getattribute (): Returns the property value, which is a text string GetAttributeNode ( "Property name"): Returns the attribute node, which is an object SetAttribute () removeattribute () createelement () InnerHTML appendchild () createTextNode () InsertBefore () removechild (): Delete element can only be deleted by direct parent element, no self-deletion firstchild lastchild nextSibling previoussibling parentnode ShowModalDialog () showModelessDialog () * three) DOM application (1) Select Output dialog (2) and delete table (3) list box Move (4) Image box

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.