JavaScript definition and writing
Since JavaScript is a client-side script, this means that users may use various devices to open web pages. In other words, the written JavaScript code may work in various browsers. The difference from server-side script is that Users may use a browser that cannot support a certain version of JavaScript to execute your Code. Therefore, when writing code, it is recommended to use standard common writing methods, try to avoid some convenient shorthands, and then finish writing. The code of. Should be tested in various browsers as much as possible. It is easier to catch bugs and modify them first to avoid unexpected situations after the official release. The following simple definitions and writing methods.
To start a JavaScript grammar,
to let the browser know that a JavaScript code is about to start, you can use the following writing method.
<!--
... JavaScript code...
-->
</script>
The current mainstream browsers support this writing method, which is also the writing method stipulated by the W3C . Of course, if you encounter a very old browser, it may not work. If it is such a problem, the solution is very simple. Change the line <script type="text/JavaScript"> to <script language="javascript"> to solve it.
Insert a small piece of JavaScript in a web page.
Sometimes a simple small grammar does not need to be declared in the entire paragraph. It only needs to be inserted into a certain part of the HTML or CSS web page. The following writing methods can be used.
The code to be operated is wrapped by the two tags <script language="javascript"> and </script>, and it can be easily inserted into the web page.
Post a Comment
0 Comments