HTML DOM level as well as some of the pits # 14

In the first episode article " You may not know the front end of knowledge " column, backup Address: HTTPS: //github.com/justjavac / ...


API (Web pages or XML) = DOM + JavaScript (scripting language)

problem

Question from an unusual start.

Netizens wrote the following code:

function download() {
      console.log(1);
}
<a onclick="download()">下载</a>

When you click the button, but the error:

Uncaught TypeError: download is not a function

Very strange error message: downloadnot a function. If we devtools console execution $0.downloadget will be ""an empty string.

We try to <a>be replaced <button>, you can execute properly.

Reading

Let me answer: HTML 5 for <a>increasing the downloadproperty, so call on a download()will prompt download is not a function, because all of the properties are strings .

The same pit as well: If a control inside the form idset submit, form submission will lead to form.submit()error, and this error message is similar submit is not a function.

JUDGMENT

In fact there is no official standard DOM0 level.

Netscape DOM is the first to propose, and with the birth of JS is at the same time. Netscape2 browser first achieved DOM, defines the entrance to obtain a document of some elements, such as document.formsand document.images, later Browser for backward compatibility, also supports these interfaces. In the JS incident, we often refer to DOM events, but also defined at this stage . There are other more commonly used to access CSS, DOM traversal, and so on. . .

DOM (Document Object Model) boom can be traced back to the late 1990s, Microsoft and Netscape "browser wars", the two sides to a life and death in JavaScript and JScript, so large-scale browser gives powerful. Microsoft web technology adding a lot of exclusive things, namely, VBScript, ActiveX, and DHTML formats such as Microsoft's own, so a lot of web pages using a non-Microsoft platforms and the browser can not display properly.

In October 1998, DOM1 became a W3C Recommendation. DOM1 stage consists of two modules: DOM core (DOM Core) and DOM HTML. They were defined:

  • DOM core: the standard model for any structured document
  • DOM HTML: only the standard model for HTML documents

DOM1 like a newborn child, there must be all kinds of deficiencies. So all kinds of browsers to add new private API in the original basis, such as attachEventand addEventListener, so W3C launched the DOM level 2. The biggest change in this version is to add an event listener method has become unifiedaddEventListener , and adds a third argument. (On the third argument can look at my previous article # 6)

W3C DOM level 2 launched in 2000, after nine years until 2009, Microsoft released IE9 just follow this standard. WTF! ! !

And later launched a DOM3 and DOM 4.

Reference links

Guess you like

Origin www.cnblogs.com/homehtml/p/12201140.html