Twitter Facebook Google+ LinkedIn Pinterest Tumblr Reddit

Javascript Usage

Javascript Usage

It contains information about questions such as where to write the JavaScript codes required for the use of JavaScript commands, how to use them.

Since JavaScript commands run on the browser, we need to add JavaScript codes to our web page.

There are several ways to add JavaScript code to a web page.

JavaScript codes can be written between <script> and </script> tags.

<script>
      alert("Sirnode says hello to you!");
</script>

HTML attributes such as onmouseover, which indicates that the HTML element is clicked, can be written on the onclick HTML element.

<button onclick="alert('Welcome to Sir Node')">Click Me My friend</button>

After the JavaScript codes are written to the external .js file, the <script> tag can be written by specifying the file name in the src property.

JavaScript codes ( javascript-usage.js )

 alert("Welcome to Sir Node!");

HTML codes

 <script src="javascript-usage.js"> </script>

NOTE: The codes in the external JavaScript file are written without the <script> and </script> tags.

Written JavaScript codes can be inserted into <head> or <body> tags.

<!DOCTYPE html>
<html lang="tr">
<head>
  <meta charset="UTF-8">
  <title>Hello Sir Node</title>
</head>
<body>
  <script>
    alert("Sirnode says hello to you!");
  </script>
</body>
</html>

NOTE: Long JavaScript commands can slow the page opening.

If the codes in the page or in external JavaScript files are added to the end of the <body> tag, the page will open faster.

If you want to download tutorial files you can go Sir Node GitHub repository.

You can find the other Sir Node JavaScript Tutorials here…

If you want to learn more details about javascript, you can go here.

If you want to download a code editor(Visual Studio Code), you can go here.