JavaScript Advanced Programming Learning Summary 3

Source: Internet
Author: User
Tags ssl connection

The DOM2 level is just based on the DOM1 level by adding new methods and new attributes to enhance the existing type, node type change: LocalName (name without namespace prefix), NamespaceURI (namespace URI or null), prefix ( namespace prefix)

The DOM2 Class View module adds a property named DefaultView that holds a pointer to the window that owns the given document.

The DOM2-level traversal and scope modules define two types that are used to assist in the sequential traversal of the DOM structure: Nodeiterator and Treewalker. and the range var range = Document.createrange () in the DOM, and to select a part of the document by scope, you can use Selectnode () or selectnodecontent ()

The DOM3 level also enhances the existing types, but also introduces some new types

Isdefaultnamespace (NamespaceURI): Returns True if the specified NamespaceURI is the default namespace of the current node

Lookupnamespaceuri (prefix): Returns the prefix namespace

LookupPrefix (NamespaceURI): Returns the prefix for a given NamespaceURI

In addition, two methods of auxiliary comparison nodes were introduced: Issamenode () and Isequalnode ()

DOM3 also provides a new method for adding additional data to the DOM node Setuserdata (key, value, function) to get the data getuserdata (key);

determining element size

functionGetboundingclientrect (Element) {if (typeof Arguments.callee.offset! = "Number") {var scrolltop =Document.documentElement.scrollTop;var temp = document.screateelement ("div" scrolltop; Document.body.removeChild (temp); temp = Span style= "COLOR: #0000ff" >null;} var rect = Element.getboundingclientrect (); var offset = Arguments.callee.offset; return {left:rect.left + Offset, right:rect.right + offset, top:rect.top + offset, Bottom:rect.bottom + offset}; 

When working with the value of a text box, it is best not to use DOM methods, because modifications to the Value property do not necessarily reflect in the DOM.

Select some text in the text box

function SelectText (textbox, StartIndex, Stopindex) {    if (textbox.setselectionrange) {       Textbox.setselectionrange (StartIndex, stopindex);    ifvar range = textbox.createtextrange (); Range.collapse (true); Range.movestart ("character" , StartIndex); Range.moveend ("character", Stopindex- startIndex); Range.Select ();} text.focus ();}     

Formdata facilitates the serialization of forms and the creation of the same data as the form format (for transmission over XHR). This is reflected in the fact that the request header is not explicitly set on the Xhr object, the Xhr object is able to recognize that the incoming data type is an instance of Formdata and configures the appropriate header information. The basic idea of cors is to have the browser communicate with the server using a custom HTTP header to determine whether the request or response should succeed or fail.

Cross-Domain technology: (1) Image Ping, (2) JSONP

To ensure the security of URLs accessed through XHR, it is a common practice to verify that the sending requestor has access to the appropriate resources, there are two ways to choose, 1) require an SSL connection to access the resources that can be requested by the XHR, 2) require that each request be accompanied by a verification code calculated by the corresponding algorithm

JavaScript Advanced Programming Learning Summary 3

Related Article

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.