Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to use HTML to reference js

2025-01-17 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/01 Report--

This article mainly introduces how to use HTML to quote js, has a certain reference value, interested friends can refer to, I hope you can learn a lot after reading this article, the following let Xiaobian take you to understand.

I. the characteristics of JavaScript scripting language

JavaScript scripting language is a browser-oriented web scripting language. Scripting languages have the following features:

1. Execute on the client side. It runs entirely on the user's computer without going through the server.

2. Object-oriented. There are built-in objects, or you can manipulate browser objects directly.

3. Dynamic change. You can respond to the user's input or output directly to the user.

4. Easy to use. Although the JavaScript scripting language is simple, it can be quickly mastered by beginners.

5. Can only be used with HTML language. To be interpreted and executed through the browser.

2. How to add JavaScript script to HTML

The format of JavaScript is as follows:

JavaScript statement

Put the above statement between and of HTML, or you can put between and.

Example: display "Hello!" on the web page. .

Alert ("Hello!")

3. Execute the JavaScript script directly in the browser address bar

You can also enter JavaScript statements in the browser's address bar and execute them directly.

For example, enter: _ javascript:alert (2000075)

4. Call JavaScript file

You can save pure JavaScript statements in a separate "* .js" file and call them when needed.

Example: call the test.js file to display the prompt.

Call the test.js file

The contents of the test.js file are as follows:

Alert ("this is the called statement.")

V. Annotation sentence

The annotation section is used as an explanation, but the browser does not display it. No, that's fine.

In addition, the double slash "/ /" is the comment statement of JavaScript, and the statements that follow it are not executed.

VI. Use of variables

Declaration of variables: Var usename

Variable assignment: usename= "Li Guoqiang"

Example: display "Hello to Li Guoqiang" on the web page. .

Var usename

Usename= "Li Guoqiang"

Alert (usename + "Hello!")

7. Array

Definition of arrays: var name=new Array (5) uses new to generate arrays.

Array assignment: name [1] = "Marry"

Initialization of array: var name=new Array ("Marry", "Petty", "Mike", "Jphn")

Reference to the array: name [1]

Note: the first prime of the array starts with 1.

Operators and expressions

1. Algebraic operators: add (+), subtract (-), multiply (*), divide (/), take remainder (%).

2. Comparison operators: equal to (= =), not equal to (! =), greater than (>), less than (=), less than or equal to (

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report