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: download
not a function. If we devtools console execution $0.download
get 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 download
property, 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 id
set 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.forms
and 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 attachEvent
and 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
- DOM Overview - Web API Interface | MDN
- Document Object Model (DOM) - Web API Interface | MDN
- Explore the key features of DOM Level 3 Core Part 1 Part 2
- DOM Level | GCidea's blog