2 Ways To Link JavaScript To HTML: JavaScript To HTML

How to link javascript to HTML?

For beginners, we will explain in an easy-to-understand manner what JavaScript can do.

JavaScript is a simple program for dynamically moving web pages on a browser, and we will carefully explain how it works, how it works, etc.

so that even those who are learning programming can understand it.

JavaScript is one of the most widely used and discussed programming language in the web development industry in recent years. if you don’t know what javascript is and what it can do, then remember to read it carefully.

What is JavaScript ?

JavaScript, abbreviated as JS, was originally used for front end of the website.(If you dont know what the font end is, please see the article about what is the font end and back end).it is a programming language for special effects/interactive effects in the effects.

JavaScript examples and their effects:


This sentence is used to Display pop-up window on the webpage.

How to link JavaScript to HTML?

How to add javascript to HTML? 2 ways to link JavaScript in HTML.one is to embed JavaScript code directly in the page, and the other is to link to external JavaScript files.(how to link javascript to html)

  1. Directly embed JavaScript code
    in the page (1) Insert a script tag anywhere on the page (behind the body part of the body part of the head), the necessary attribute type attribute of the tag, this attribute describes the type of the document

(2 ) js written statement within the script tag
for example: alert ( “to prompt content”) role is to pop up a prompt window on the page, play the role of reminders and warnings.

There is no difference between single quotation marks and double quotation marks in JavaScript, they are both used to represent strings.

It is best to add a semicolon to end each sentence after writing

<!Doctype html>
<meta charset="utf-8">
<script type="text/javascript>
alert("please listien carefully")


2. Link external JavaScript files.

If there are many JavaScript statements, these statements should be written in a separate js file. (1) Create a JavaScript file first, the extension is .js (2) Write the js code to be written into the Js file, and save the file. (3) Introduce JavaScript files into HTML files.

The script tag is a double tag tag Note: In a script tag that has imported an external js file, it cannot be at the beginning and end Write the Js command in the label.

Conventionally, the external js file is introduced first. If the file does not fully meet the programming needs, then add the script tag to the file to write the statement.

For example:

<!Doctype html> 
<meta charset="utf-8">
<script type="text/javascript" src="file1.js"></script>
<script type="text/javascript">
alert("Please listen carefully!!");

Javascript and What you can do with JavaScript?

At first

The closest thing isA program that runs on a browser that displays a website (client-side script)is. You can see the website without Javascript, but you can’t do various operations just by reading the text and photos. This is very inconvenient.

Therefore, by using JavaScript, which is one of the programming languages, you can enlarge the image on the browser to make it easier to see, or set up an input form to send a message.


JavaScript was born unexpectedly before the early 1990s when the Internet began to spread. 

Initially, it was developed specifically for the browser Netscape Navigator and was named LiveScript. After that, there was a tie-up with a company and it changed to the current name.

At that time, the programming language developed and popular by our partner companies was “Java”, and in line with this popularity, LiveScript was changed to JavaScript. 

The differences between the two will be summarized later.

Features as a programming language

When displaying a page on a browser, if JavaScript is used, it has the following features.

When using JavaScriptIf you don’t use JavaScript
(Example) Display of sentences and photosCan be changed, enlarged or movedDisplayed as specified in the HTML file
(Example) Enter characters in the form and sendYes
(the transmission itself is handled by another program)
Main operating locationsBrowser of user’s personal computer or smartphone– –
convenienceOverwhelmingly convenientinconvenience
Complexity (learning difficulty)Complex (requires language understanding)– –

Is it possible to switch JavaScript ON and OFF in the browser?

can. Even JavaScript, which has many benefits,If you want to stop the operation, you can turn it off.It’s not a complete solution, but the main reasons are:

  • Security measures (prevent attacks on JavaScript from the Internet side)
  • You can invalidate your own access information (stop the access analysis program made of JavaScript)
  • Hide ads (you can hide extra ads made with JavaScript)

By changing this setting, the content that was originally a merit will also be invalidated. for that reason,Be careful when switching to OFF.

Normally, JavaScript is ON by default in the browser, so unless you have a specific reason, you can usually leave it as it is.

JavaScript related terms

A group (library) of programs that apply JavaScript is prepared. We have a lot of website creators for the purpose of working more efficiently. Let me give you an example.

NameHow to readoverview
AjaxAjax-JavaScript library
-Uses the communication function of JavaScript to send and receive XML format data-
Examples of use are Google Maps, etc.
jQueryJQuery-JavaScript library
-A browser extension made of JavaScript that can be easily introduced
and is popular.-Examples of applications are menus and image display. Search etc.
JSONJasonDescription method for expressing data in text
DOMDomMechanism for accessing and operating HTML files, etc.

Difference between JavaScript and Java

I have summarized the differences from JavaScript in relation to Java introduced earlier. 

You might think it’s a similar programming language because it contains the common term Java. HoweverIt’s actually a completely different thing.

Published dateDecember 1995 (the name at that time was “LiveScript”)May 1995
Development companyNetscape CommunicationsSun Microsystems, Inc.
Executable fileSource codeJava bytecode output by the Java compiler
Variable processingdynamicstatic
Purpose of developmentMake website page creation easier and fasterWorks on any hardware
Field of useWebsite page creation
(systems and services running on a web browser, etc.)
Various large-scale systems
(business systems, web-related services such as SNS, Android smartphone applications, etc.)

Also Read : What is Digital Media? 8 things about digital media

Leave a Comment

Tom Cruise Biography in Details Instant Adsense Approval from Google Pro Tips