Hello everyone, it has been a long time since the bloggers recently learned to drive at the driving school, which has delayed DHTML update schedules.
Now, let's get rid of it. Next we will introduce a core DHTML-JavaScript.
Javascript is a little dizzy at first, because there is a Java in the name, it seems very difficult to learn Java, it is not good to learn well that stuff for a few years, if you have such a mentality, you will be wrong. Javascript is a dynamic Web scripting language, and its relationship with Java is like the relationship between California beef noodles and Malaysian beef noodles, although there are beef noodles in the name, they all start from the noodle shop, but the flavor of the soup in the two kinds of noodles is different, of course, you cannot underestimate JavaScript, javascript is currently the most popular dynamic scripting language. The most dazzling jquery in web design is actually JavaScript encapsulation. The most popular Ajax technology in web design is implemented through the synthesis of JavaScript and other technologies,
Javascript can even be used to develop unity3d games. As a programmer, JavaScript must be fully mastered. The requirement level is much higher than that of CSS.
After talking about this, let's see where it is used?
Do you still remember the <SCRIPT> label I mentioned earlier in HTML? JavaScript code is here, and JavaScript code can also be encapsulated in a JS file, when jquery is used, it is referenced in the form of reference. This reference is most frequently used.
Javascrip is an independent programming language, but it is a weak type language. If you have C # or Java basics, learning this language should not be a problem, before learning JavaScript, programmers are better at understanding a language in C, C ++, C #, or Java. It is just a suggestion. Why is this suggestion, because many of their syntaxes are very similar.
The following describes how to use JavaScript code on an HTML page.
Method 1:
Write the script tag in the head tag and the JavaScript code in the script tag. The format is as follows:
<Head> <SCRIPT type = "text/JavaScript">
VaR Hello = "Hello ";
</SCRIPT>
"Var" is the data type in Javascript. The reason why Javascript is a weak language is that all data types in Javascript, including integer and string types, are replaced by VAR in a unified manner, the data type can be flexibly assigned values, as shown in the following code:
VaR num = false;
Num = "Am I wrong ?";
In Java and other languages, this phenomenon is absolutely not allowed, but it is completely possible in Javascript. The num value is the string to be assigned, whether it feels like JavaScript is really a bunker, huh, it is indeed a bunker.
Method 2:
The <SCRIPT> label is used to introduce a JS file into the head label of the HTML page. JavaScript code is directly written in the JS file, and the <SCRIPT> label cannot be added. The format is as follows:
<SCRIPT src = "Hello. js" type = "text/JavaScript">
</SCRIPT>
The value of the src attribute here is the path and file name of the JS file. After the code written in the JS file is referenced to the HTML page, during the operation, the operation is the same as that in the script label. For example, in the JS file, I define a var. When I introduce this JS file, I want to operate this var, you can directly assign values or perform operations to VaR, but the operation code must be written in the <SCRIPT> label and the type is text/JavaScript.
Well, Lori is a lot wordy. Let's take a look at this section. The next section will introduce functions in Javascript. functions should be the core of JavaScript, this is actually not an issue.