Home  >  Article  >  Web Front-end  >  How to do outreach in javascript

How to do outreach in javascript

PHPz
PHPzOriginal
2023-04-27 15:37:401269browse

JavaScript is the most commonly used scripting language in the field of web design. In web pages, if you want to use JavaScript, there are generally two ways - inline and outbound. This article will mainly introduce how JavaScript is used for outreach.

What is external linking

Simply put, external linking is a method of referencing external JavaScript files in web pages. In an HTML document, you can use the

Among them, the type attribute indicates the script language type, and the src attribute points to the external JavaScript file path. Next, we will use a simple example to illustrate how to externally link JavaScript files in HTML files.

Example

Suppose we want to reference an external JavaScript file in an HTML file. The file name is "external.js" and the directory is in the "js" directory. The steps are as follows:

  1. Create an HTML file named "external.html". The code in the file is as follows:




JavaScript 外联

In the above code, we define a button click event and call a function named "myFunction()". At the end of the HTML code, we introduce the "js/external.js" file through the