When I first started my company, my JavaScript lineCodeI don't know how to write it. I need to ask some experienced colleagues for the window. Open method. After a period of development, I finally realized the JavaScript code and started to touch the door. In order to reduce the time of this pain, I 'd like to talk nonsense here. The following examples use JavaScript code in ASPnet as an example.
First, let's summarize the role of JavaScript code in Web development. On a web page, JavaScript has the following functions:
1. Write client verification, which will be used in 100%;
2. DOM object programming on the client page, which is used in 99%;
3. Programming of some windows and document objects, 99% used;
4. Ajax implementation;
Note: In fact, window and document are also DOM objects, but this part looks too big, unlike Dom, so take it as an example separately.
After talking about the role of Javascript in Web pages, let's talk about the overall understanding and grasp of JavaScript, which is conducive to writing JavaScript code.
Javascript is a language at the same level as C, Java, and C #, but it is an interpreted scripting language that is generally executed in the browser environment, that is, on the client; the CS script written by C # appears to be executed in the browser, but it is actually deployed on the server side, and the code written by C # is executed on the server side.
Javascript is a weak language and an object-oriented language. In web development, JavaScript operations on HTML elements are similar to the ASPNET model: All pages are composed of Dom controls (in the ASPNET model, all pages are composed of ASPnet controls ). What is a DOM control? Dom controls can be understood as an object element of HTML. For example, if table is an object, it is a Dom. Is tr Dom? Yes, because TR is also an object. In fact, as long as the relationship <> </> is met, it is a DOM object. According to the ASPNET rules, each control has its own attributes and methods, and the DOM control also has its own attributes and methods. In fact, during web development, the operation of the DOM control is just like the operation of the ASPNET control on the server side. Just find the corresponding attributes and methods of the control and program it. Simple? Is this super simple.
Another thing is how to find the attributes and methods of the DOM control? To solve this problem, you must first understand the relationship between the ASPNET Server Control and the DOM control. The relationship between them is actually a "" relationship. Vague, right? To put it bluntly, a server control is finally displayed in a browser as a client Dom control. Why? How is it changed? You don't need to know why yet. You just need to know that the ASPNET control cannot be recognized in the browser. Only HTML code can be recognized by the browser, therefore, the ASPNET control will eventually be "compiled" into HTML code, so the ordered HTML code will constitute the DOM control of the client. Well, it's easy to get things done here. I finally caught the essence: "dom control", there are a lotArticleWill use this term to speak. Remember him.
For the historical origins, basic syntax, definition and nature of Dom controls of JavaScript, we hope that readers can read this book and recommend the Bible-level book of javascript: "rhinoceros ". If there is no book, it doesn't matter. Search for Google. Google is a good thing. Just define it.
in the following section, I will write the "" Relationship Between the ASPNET control and the DOM control. How does the ASPNET control become a DOM control; the ASPnet control and Dom control are different.